Help Center/ CodeArts Deploy/ API Reference/ APIs/ Environment Management/ Creating an Environment Under an Application
Updated on 2023-11-28 GMT+08:00

Creating an Environment Under an Application

Function

This API is used to create an environment for an application.

URI

POST /v1/applications/{application_id}/environments

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

application_id

Yes

String

Application ID.

Minimum: 32

Maximum: 32

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

project_id

Yes

String

Project ID. For details, see Obtaining a Project ID.

name

Yes

String

Environment name.

deploy_type

Yes

Integer

Deployment type. 0: host; 1: kubernetes.

Default: 0

Enumeration values:

  • 0

  • 1

os

Yes

String

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

Default: linux

Enumeration values:

  • windows

  • linux

description

No

String

Environment description.

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

status

String

Response status.

id

String

Environment ID.

Example Requests

https://{endpoint}/v1/applications/43943381f7764c52baae8e697720873f/environments

{
  "project_id" : "55837d272adf4eee90319800e2da6961",
  "name" : "Environment name",
  "deploy_type" : 0,
  "description" : "Environment Description",
  "os" : "linux"
}

Example Responses

Status code: 200

OK: The request is successful.

{
  "status" : "success",
  "id" : "140ca97e701d4c4c93c5932d5bdb32ec"
}

Status Codes

Status Code

Description

200

OK: The request is successful.

Error Codes

See Error Codes.