CreateHostGroup - Create a host group
Creates a host group by calling the Yunxiao OpenAPI.
|
Applicable editions |
Central edition, Region edition |
Endpoint and authorization information
- Obtain the endpoint: Replace {domain} in the API request syntax.
- Obtain a personal access token.
- Obtain the organizationId: Required only for the Central edition. Go to the Basic Information page in the Organization Management console to obtain the organization ID.
|
Product |
Resource |
Required permission |
|
Pipeline |
Host group |
Read and write |
Request syntax
Central edition
POST https://{domain}/oapi/v1/flow/organizations/{organizationId}/hostGroups
Region edition
POST https://{domain}/oapi/v1/flow/hostGroups
Request headers
|
Parameter |
Type |
Required |
Description |
Example value |
|
x-yunxiao-token |
string |
Yes |
Your personal access token. |
pt-0fh3****0fbG_35af****0484 |
Request parameters
|
Parameter |
Type |
Location |
Required |
Description |
Example value |
|
organizationId |
string |
path |
|
The organization ID. |
5ebbc0228123212b59xxxxx |
|
type |
string |
query |
Yes |
The host group type. Only ECS is supported. |
ECS |
|
envId |
string |
query |
No |
The environment ID. |
0 |
|
name |
string |
query |
Yes |
The host group name. |
Host group |
|
serviceConnectionId |
integer |
query |
Yes |
The service connection ID. |
123 |
|
tagIds |
string |
query |
No |
The tag IDs, separated by commas. |
12,234 |
|
ecsType |
string |
query |
No |
The ECS type. Only ECS_ALIYUN is supported. |
ECS_ALIYUN |
|
ecsLabelKey |
string |
query |
No |
The ECS label key. |
ecs |
|
ecsLabelValue |
string |
query |
No |
The ECS label value. |
ecs |
|
aliyunRegion |
string |
query |
No |
The Alibaba Cloud region. |
cn-beijing |
|
machineInfos |
string |
query |
No |
The machine information in JSON format, including the Alibaba Cloud region ID (aliyunRegionId), machine serial number (machineSn), instance name (instanceName), hostname, and IP address (ip). |
[{"aliyunRegionId":"cn-beijing","machineSn":"i-sssssss","instanceName":"ceshi","ip":"120.0.0.0"}] |
Request examples
Central edition
curl -X 'POST' \
'https://{domain}/oapi/v1/flow/organizations/5ebbc0228123212b59xxxxx/hostGroups?type=ECS&envId=0&name=Host%20group&serviceConnectionId=123&tagIds=12,234&ecsType=ECS_ALIYUN&ecsLabelKey=ecs&ecsLabelValue=ecs&aliyunRegion=cn-beijing&machineInfos=[{"aliyunRegionId":"cn-beijing","machineSn":"i-sssssss","instanceName":"ceshi","ip":"120.0.0.0"}]' \
-H 'Content-Type: application/json' \
-H 'x-yunxiao-token: pt-0fh3****0fbG_35af****0484'
Region edition
curl -X 'POST' \
'https://{domain}/oapi/v1/flow/hostGroups?type=ECS&envId=0&name=Host%20group&serviceConnectionId=123&tagIds=12,234&ecsType=ECS_ALIYUN&ecsLabelKey=ecs&ecsLabelValue=ecs&aliyunRegion=cn-beijing&machineInfos=[{"aliyunRegionId":"cn-beijing","machineSn":"i-sssssss","instanceName":"ceshi","ip":"120.0.0.0"}]' \
-H 'Content-Type: application/json' \
-H 'x-yunxiao-token: pt-0fh3****0fbG_35af****0484'
Response parameters
|
Parameter |
Type |
Description |
Example value |
|
- |
integer |
The host group ID. |
123 |
Response example
123
Error codes
For more information, see Error code center.