主机资源列表¶
说明¶
- 管理主机资源
1、主机资源列表、新增主机资源API¶
请求方式: GET(查询) POST(新增) DELETE(批量删除)
请求地址: /api/project/host/source/
Content-Type:
新增数据的时候需要指定Content-Type,以下对Content-Type进行说明:
application/x-www-form-urlencoded —— 表示通过表单方式提交
application/json —— 表示传入数据为json格式字符串
查询参数:
参数 | 数据类型 | 是否必须 | 说明 |
offset | int | 否 | 数据起始位置 |
limit | int | 否 | 查询条数 |
输入参数(新增):
参数 | 数据类型 | 是否必须 | 说明 |
name | string | 是 | 名称 |
description | string | 否 | 描述 |
inventory | int | 否 | inventory |
source_type | string | 是 | 来源类型 |
source_type_name | string | 否 | 来源类型中文名称(只读) |
project | int | 否 | 自动化项目 |
host_file | string | 否 | 主机文件 |
url | string | 否 | API地址 |
method | string | 否 | 请求方式 |
header | string | 否 | 头信息 |
params | string | 否 | 参数模板 |
source_script | string | 否 | 脚本内容 |
regions | string | 否 | 地域 |
credential | int | 否 | 凭据 |
state | string | 否 | 状态 |
输出参数:
参数 | 数据类型 | 是否必须 | 说明 |
id | int | 是 | host id |
name | string | 是 | 名称 |
description | string | 否 | 描述 |
inventory | int | 否 | inventory |
source_type | string | 是 | 来源类型 |
source_type_name | string | 否 | 来源类型中文名称(只读) |
project | int | 否 | 自动化项目 |
host_file | string | 否 | 主机文件 |
url | string | 否 | API地址 |
method | string | 否 | 请求方式 |
header | string | 否 | 头信息 |
params | string | 否 | 参数模板 |
source_script | string | 否 | 脚本内容 |
regions | string | 否 | 地域 |
credential | int | 否 | 凭据 |
state | string | 否 | 状态 |
批量删除参数:
参数 | 数据类型 | 是否必须 | 说明 |
pk | string | 与pk[]不能都为空 | 主键,多个主键用半角逗号隔开。通过http body传入 |
pk[] | array | 与pk不能都为空 | 主键数组。通过http body传入 |
排序:
参数 | 数据类型 | 是否必须 | 说明 |
ordering | string | 否 |
|
GET返回数据例子:
{
"count": 18,
"next": null,
"previous": null,
"results": [
{
"id": 24,
"name": "999",
"description": "888",
"inventory_name": "提交ooo",
"source_type": "script",
"host_file": "",
"url": "",
"method": "",
"header": "",
"params": "",
"source_script": "{}{}",
"inventory": 117,
"project": null,
"source_type_name": "自定义脚本",
"credential": null,
"regions": ""
},
{
"id": 23,
"name": "阿里云服务器99",
"description": "",
"inventory_name": "wgwwb",
"source_type": "restapi",
"host_file": "",
"url": "555",
"method": "post",
"header": "",
"params": "",
"source_script": "{}",
"inventory": 107,
"project": null,
"source_type_name": "Rest Api",
"credential": null,
"regions": ""
},
]
}
新增主机资源返回数据例子:
{
"id": 20,
"name": "bdebdsb",
"description": "",
"inventory_name": "dvdf",
"source_type": "script",
"host_file": "",
"url": "",
"method": "",
"header": "",
"params": "",
"source_script": "",
"inventory": 94,
"project": null,
"source_type_name": "自定义脚本",
"credential": null,
"regions": ""
},
2、获取单个主机资源,修改主机资源、删除主机资源 API¶
请求方式: GET(查询) PUT(修改) PATCH(修改) DELETE(删除)
请求地址: /api/project/host/source/1/
请求地址中1为主机资源的id
输入/输出参数: 见章节1中输入和输出参数说明,修改数据时输入参数均为非必须
返回数据例子:
{
"id": 1,
"name": "阿里云服务器",
"description": "",
"source_type": "script",
"host_file": "",
"url": "",
"method": "",
"header": "",
"params": "",
"source_script": "{}",
"inventory": null,
"project": null,
"source_type_name": "自定义脚本",
"credential": null,
"regions": ""
}