Updated on 2025-02-14 GMT+08:00

Creating an Environment

Function

This API is used to create an environment.

URI

POST /v1/{project_id}/cae/environments

Table 1 Path parameter

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. See Obtaining a Project ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token.

Maximum characters: 16,384

X-Enterprise-Project-ID

No

String

Enterprise project ID.

  • When an environment is created, it will be bound with an enterprise project ID.
  • Enter 0 or up to 36 characters in UUID format with hyphens (-).
  • If this parameter is not specified or set to 0, resources in the default enterprise project are queried.
NOTE:

For more information about enterprise projects and how to obtain enterprise project IDs, see Enterprise Management User Guide.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

api_version

Yes

String

API version. Fixed value: v1.

Enumerated value:

  • v1

kind

Yes

String

API type. Fixed value: Environment.

Enumerated value:

  • Environment

metadata

Yes

metadata object

Request data.

Table 4 metadata

Parameter

Mandatory

Type

Description

annotations

No

map<string, object>

Additional parameters for creating an environment.

  • vpc_id: ID of the VPC bound to the created environment.
  • group_name: name of the SWR organization bound to the created environment.
  • type: environment type, which can only be exclusive.

name

Yes

String

Environment name.

Response Parameters

Status code: 200

Table 5 Response body parameters

Parameter

Type

Description

job_id

String

Job ID.

Example Request

Create environment test, and bind it to a VPC and organization cae-test.

POST https://{endpoint}/v1/{project_id}/cae/environments

{
  "api_version" : "v1",
  "kind" : "Environment",
  "metadata" : {
    "annotations" : {
      "vpc_id" : "9b320498-6c39-4fe7-a758-79636dd68a82",
      "group_name" : "cae-test",
      "type" : "exclusive"
    },
    "name" : "test"
  }
}

Example Response

Status code: 200

The request is successful.

{
  "job_id" : "xxx"
}

Status Code

Status Code

Description

200

The request is successful.

Error Code

For details, see Error Codes.