查询指定模板和目录
此接口用于获取指定路径下的资源模板和模板目录。支持通过参数指定获取路径的深度,默认路径深度为最深,即递归的获取指定路径下的所有模板。
接口描述
通信协议:HTTP
URL:GET /api/v1/provision-template/path-label/tree
传参方式:query
请求参数
字段名 | 类型 | 是否必填 | 说明 |
---|---|---|---|
path | string | 是 | 所要获取的父路径 |
level | number | 否 | 指定获取路径的深度,默认深度为最深 |
model | string | 否 | 指定获取模板的模式,其中 simple 代表简略信息;full 代表详细信息。默认为 simple |
响应参数
ProvisionTmplTree
字段名 | 类型 | 说明 |
---|---|---|
name | string | 当前模板名称 |
realpath | string | 当前模板全路径 |
childCount | number | 当前模板下的子模板数量 |
data? | ProvisionTmplDetail | 当前模板的详细信息,当指定 model=full 时,会返回该字段 |
children | { [key: string]: ProvisionTmplTree } | 子模板信息,格式同当前模板 |
ProvisionTmplDetail
字段名 | 类型 | 说明 |
---|---|---|
id | string | 模板 ID |
name | string | 名称 |
kind | string | 类型。folder 代表模板目录;service 代表资源模板 |
hostname | string | 用户配置的容器主机名称 |
node | Node | node 信息数组 |
createdTime | string | 当前模板创建时间 |
updatedTime | string | 当前模板更新时间 |
请求示例
curl --location --request GET 'http://localhost:3001/api/v1/provision-template/path-label/tree?path=/example/a/aa&model=full'
响应示例
{
"status": 200,
"message": "success",
"data": {
"name": "",
"realpath": "",
"children": {
"a": {
"name": "a",
"realpath": "/a",
"children": {
"aa": {
"name": "aa",
"realpath": "/a/aa",
"children": {
"aab": {
"name": "aab",
"realpath": "/a/aa/aab",
"children": {},
"childCount": 0,
"data": {
"id": "0759a53d4310468dada78c28677d33f6",
"name": "aab",
"kind": "folder",
"realpath": "/a/aa/aab"
}
},
"tailf-0x3": {
"name": "tailf-0x3",
"realpath": "/a/aa/tailf-0x3",
"children": {},
"childCount": 0,
"data": {
"id": "085c650b5f5d422e8bcee3d5c87cad58",
"name": "tailf-0x3",
"kind": "service",
"realpath": "/a/aa/tailf-0x3"
}
},
"aac": {
"name": "aac",
"realpath": "/a/aa/aac",
"children": {
"tailf-0x4": {
"name": "tailf-0x4",
"realpath": "/a/aa/aac/tailf-0x4",
"children": {},
"childCount": 0,
"data": {
"id": "2e2b022ab85746b793a835e6e3fa2f56",
"name": "tailf-0x4",
"kind": "service",
"realpath": "/a/aa/aac/tailf-0x4"
}
},
"tailf-latest-5tUak01Y9wVesfMU": {
"name": "tailf-latest-5tUak01Y9wVesfMU",
"realpath": "/a/aa/aac/tailf-latest-5tUak01Y9wVesfMU",
"children": {},
"childCount": 0,
"data": {
"id": "1ab26ffd2206433db9b4d49242e0622b",
"name": "tailf-latest-5tUak01Y9wVesfMU",
"kind": "service",
"realpath": "/a/aa/aac/tailf-latest-5tUak01Y9wVesfMU"
}
}
},
"childCount": 2,
"data": {
"id": "85de48f78147415e800a6f8984ebcdb5",
"name": "aac",
"kind": "folder",
"realpath": "/a/aa/aac"
}
}
},
"childCount": 3,
"data": {
"id": "1b677192776240e0af524fb33c64dfc9",
"name": "aa",
"kind": "folder",
"realpath": "/a/aa"
}
},
"ab": {
"name": "ab",
"realpath": "/a/ab",
"children": {},
"childCount": 0,
"data": {
"id": "8f00f53dbc4842eb8bbc5b652501dd2d",
"name": "ab",
"kind": "folder",
"realpath": "/a/ab"
}
}
},
"childCount": 2,
"data": {
"id": "2cea35be48ee41f1810d3c1cd7dc7999",
"name": "a",
"kind": "folder",
"realpath": "/a"
}
},
"b": {
"name": "b",
"realpath": "/b",
"children": {
"tailf-0x2": {
"name": "tailf-0x2",
"realpath": "/b/tailf-0x2",
"children": {},
"childCount": 0,
"data": {
"id": "ecb291506c334216a39b873dda23a90c",
"name": "tailf-0x2",
"kind": "service",
"realpath": "/b/tailf-0x2"
}
}
},
"childCount": 1,
"data": {
"id": "5a18b87216754d5da72dd7c074ed5f0e",
"name": "b",
"kind": "folder",
"realpath": "/b"
}
},
"tailf-0x05": {
"name": "tailf-0x05",
"realpath": "/tailf-0x05",
"children": {},
"childCount": 0,
"data": {
"id": "4143beb9c0934fccbab196e2df7cafe5",
"name": "tailf-0x05",
"kind": "service",
"realpath": "/tailf-0x05"
}
},
"tailf-0x06": {
"name": "tailf-0x06",
"realpath": "/tailf-0x06",
"children": {},
"childCount": 0,
"data": {
"id": "05b38aa7b0f34537b231cce91062b417",
"name": "tailf-0x06",
"kind": "service",
"realpath": "/tailf-0x06"
}
}
},
"childCount": 4
},
"fieldErrors": null
}
错误码
具体请参见 错误码说明。