Skip to content

RESTful API For Host

Echo edited this page Apr 27, 2018 · 7 revisions
获取指定主机信息
Request
GET /saltshaker/api/v1.0/host/h-dcf2af4c389411e881ef000c298454d8

Response
HTTP/1.1 200 OK
Content-Type: application/json

{
    "data": {
        "id": "h-dcf2af4c389411e881ef000c298454d8",
        "tag": "",
        "groups": [
            "group01",
            "group03"
        ],
        "minion_id": "10.11.1.10",
        "product_id": "p-b4aaef1e322611e8ab56000c298454d8"
    },
    "status": true,
    "message": ""
}
获取指定产品的主机列表
Request
GET /saltshaker/api/v1.0/host?product_id=p-b4aaef1e322611e8ab56000c298454d8

Response
HTTP/1.1 200 OK
Content-Type: application/json

{
   "data": [
       {
            "id": "h-dcf2af4c389411e881ef000c298454d8",
            "tag": "",
            "group_id": [],
            "minion_id": "10.11.1.10",
            "product_id": "p-b4aaef1e322611e8ab56000c298454d8"
        },
        {
            "id": "h-dcf2af4d389411e881ef000c298454d8",
            "tag": "",
            "group_id": [],
            "minion_id": "119.45.44.44",
            "product_id": "p-b4aaef1e322611e8ab56000c298454d8"
        }
    ],
    "status": true,
    "message": ""
}
添加主机 说明:主机不能直接添加,能添加的主机是与key里面的数据对比的,添加key中存在而主机中不存在的缺失数据
Request
POST /saltshaker/api/v1.0/host

POST Body
{
      "tag": "ok",
      "minion_id": "100.11.1.10",
      "product_id": "p-b4aaef1e322611e8ab56000c298454d8"
}
Response
HTTP/1.1 200 OK
Content-Type: application/json

{
    "status": true,
    "message": ""
}
删除主机 说明:主机不能直接删除,能删除的主机是与key里面的数据对比的,删除key中不存在而主机中存在的脏数据
Request
DELETE /saltshaker/api/v1.0/host/h-dcf2af4d389411e881ef000c298454d8

Response
HTTP/1.1 200 OK
Content-Type: application/json

{
    "status": true,
    "message": ""
}
修改主机
Request
PUT /saltshaker/api/v1.0/groups/g-42fcb22e28fa11e8a7e3000c298454d8
PUT Body
{
    "tag": "error",
    "product_id":"p-b4aaef1e322611e8ab56000c298454d8",
    "minion_id":"10.10.10.1"
}
Response
HTTP/1.1 200 OK
Content-Type: application/json

{
    "status": true,
    "message": ""
}