更新时间:2024-07-05 GMT+08:00
示例2:根据主机集群id查询主机集群详情
前提
用户已经创建软件开发生产线项目,并且项目下有主机集群。
总体思路
先通过api查看所有的主机集群列表,并获得想要查看的主机集群group_id,使用该group_id在本api中查询该主机集群的详细信息,步骤如下:
- 查询用户的所有主机集群。
- 查询某个主机集群的详细信息。
步骤1:查询用户所有主机集群
- 接口信息:
URI:GET /v2/host-groups
- 请求示例:
GET https://{endpoint}/v2/host-groups?region_name=ap-southeast-3&project_id=6039d4480efc4dddb178abff98719913&offset=1&limit=10&sort_key=create_time&sort_dir=DESC
- 响应示例:
{ "total" : 1, "host_groups" : [ { "name" : "testwyk", "description" : "11122211", "os" : "linux", "nick_name" : "AB边账号", "id" : 200001291, "group_id" : "ab7647b0863c4e969c8949d38d591339", "region_name" : "ap-southeast-3", "project_id" : "6039d4480efc4dddb178abff98719913", "permission" : { "can_view" : true, "can_edit" : true, "can_delete" : true, "can_add_host" : true, "can_manage" : true }, "created_by" : { "user_id" : "6baa7454109d47c192f22078fe6cda20", "user_name" : "devcloud_devcloud_l00490255_01" }, "updated_by" : { "user_id" : "6baa7454109d47c192f22078fe6cda20", "user_name" : "devcloud_devcloud_l00490255_01" }, "auto_connection_test_switch" : 0, "slave_cluster_id" : "", "created_time" : "2021-04-01 17:05:53", "updated_time" : "2021-04-21 14:29:14", "host_count" : 1, "project_name" : null } ] }
步骤2:查询主机集群详情
- 接口信息:
URI:GET /v2/host-groups/{group_id}
- 请求示例:
GET https://{endpoint}/v2/host-groups/ab7647b0863c4e969c8949d38d591339
- 响应示例:
{ "name" : "test", "description" : "11122211", "os" : "linux", "region_name" : "ap-southeast-3", "project_id" : "6039d4480efc4dddb178abff98719913", "created_by" : { "user_id" : "6baa7454109d47c192f22078fe6cda20", "user_name" : "devcloud_devcloud_l00490255_01" }, "updated_by" : { "user_id" : "6baa7454109d47c192f22078fe6cda20", "user_name" : "devcloud_devcloud_l00490255_01" }, "permission" : { "can_view" : true, "can_edit" : true, "can_delete" : true, "can_add_host" : true, "can_manage" : true }, "auto_connection_test_switch" : 0, "slave_cluster_id" : "", "nick_name" : "AB边账号", "group_id" : "ab7647b0863c4e969c8949d38d591339", "created_time" : "2021-04-01 17:05:53", "updated_time" : "2021-04-21 14:29:14", "host_count" : 1 }
父主题: 应用示例