Help Center> CodeArts Deploy> API Reference> APIs> Host Management> Creating a Host (Recommended)
Updated on 2023-11-28 GMT+08:00

Creating a Host (Recommended)

Function

This API is used to create a host in a specified host cluster.

URI

POST /v1/resources/host-groups/{group_id}/hosts

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

group_id

Yes

String

Host cluster ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

Content-Type

Yes

String

Message body type (format). Possible values: application/json;charset=utf-8 application/json

Default: application/json;charset=utf-8

Enumeration values:

  • application/json;charset=utf-8

  • application/json

X-Auth-Token

Yes

String

User token. It can be obtained by calling an IAM API. The value of X-Subject-Token in the response header is the user token.

Minimum: 0

Maximum: 20000

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

host_name

Yes

String

Host name.

Minimum: 3

Maximum: 128

ip

Yes

String

Enter an elastic IP address, for example, 161.17.101.12.

port

Yes

Integer

SSH port, for example, 22.

os

Yes

String

Operating system: Windows or Linux, which must be the same as that of the host cluster.

Enumeration values:

  • windows

  • linux

as_proxy

Yes

Boolean

Whether a proxy host is used.

proxy_host_id

No

String

Proxy ID.

authorization

Yes

HostAuthorizationBody object

Log in to the host for authentication by password or key.

install_icagent

No

Boolean

Application Operations Management (AOM) is enabled for free to provide metric monitoring, log query, and alarm functions. (The ICAgent is automatically installed and supports only Huawei Cloud Linux hosts.)

Table 4 HostAuthorizationBody

Parameter

Mandatory

Type

Description

username

Yes

String

Username. The value can contain letters, digits, and hyphens (-).

Minimum: 3

Maximum: 128

password

No

String

Password. When the authentication type is 0, the password is mandatory.

private_key

No

String

Key. When the authentication type is 1, the key is mandatory.

Minimum: 1

Maximum: 5000

trusted_type

Yes

Integer

Authentication type. 0 indicates password authentication, and 1 indicates key authentication.

Enumeration values:

  • 0

  • 1

Response Parameters

Status code: 200

Table 5 Response body parameters

Parameter

Type

Description

status

String

Status.

id

String

Host ID.

Example Requests

When creating a host, you need to enter the basic information about the host, including the host name, IP address, port number, username, and password.

https://{endpoint}/v1/resources/host-groups/ab7647b0863c4e969c8949d38d591339/hosts

{
  "host_name" : "100.101.28.215",
  "ip" : "100.101.28.215",
  "port" : "22",
  "os" : "linux",
  "as_proxy" : false,
  "proxy_host_id" : "",
  "authorization" : {
    "username" : "root",
    "password" : "*****",
    "private_key" : "",
    "trusted_type" : 0
  },
  "install_icagent" : true
}

Example Responses

Status code: 200

OK: The request is successful.

{
  "status" : "success",
  "id" : "300d6d2e53624d0da08b182099ad10f7"
}

Status Codes

Status Code

Description

200

OK: The request is successful.

Error Codes

See Error Codes.