Creating an Environment
Function
This API is used to create an environment.
Authorization Information
Each account has all of the permissions required to call all APIs, but IAM users must have the required permissions specifically assigned.
- If you are using role/policy-based authorization, see the required permissions in Permissions and Supported Actions.
- If you are using identity policy-based authorization, the permission listed below is required.
Action
Access Level
Resource Type (*: required)
Condition Key
Alias
Dependencies
servicestage:environment:create
write
-
-
-
environment *
-
URI
POST /v3/{project_id}/cas/environments
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| project_id | Yes | String | Definition Tenant's project ID. See Obtaining a Project ID. Constraints N/A Range N/A Default Value N/A |
Request
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| Content-Type | Yes | String | Definition Message body type (or format). Constraints N/A Range application/json;charset=utf8 Default Value N/A |
| X-Auth-Token | Yes | String | Definition API calling can be authenticated using a token or AK/SK. If you use a token, this parameter is mandatory and must be set to the token. For details about how to obtain the token, see Authentication. Constraints N/A Range N/A Default Value N/A |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| config_mode | No | String | Definition Parameter configuration mode. Range
Default Value N/A |
| name | Yes | String | Definition Environment name. Range The value contains 2 to 64 characters consisting of letters, digits, hyphens (-), or underscores (_). It starts with a letter and ends with a letter or digit. Letters are case sensitive. Default Value N/A |
| deploy_mode | No | String | Definition Environment type. Range
To use a custom server in the created environment, select virtualmachine or mixed. Default Value N/A |
| type | No | String | Definition Whether the Kubernetes environment is of the HA type. Range
Default Value N/A |
| resource_create_mode | No | String | Definition Resource configuration mode. Range
To use a custom server in the created environment, select none. Default Value N/A |
| resources | No | Array of objects | Definition Resource list. See Table 4. |
| description | No | String | Definition Environment description. Range The value can contain up to 128 characters. Default Value N/A |
| enterprise_project_id | No | String | Definition Enterprise project ID. If this parameter is not set, the default enterprise project is default and the ID is 0. Constraints An enterprise project can be configured only after the enterprise project function is enabled. Range N/A Default Value N/A |
| vpc_id | Yes | String | Definition VPC ID. To obtain this value, use either of the following methods:
Range N/A Default Value N/A |
| labels | No | Array of objects | Definition Label. You can use TMS to filter resources by labels. See Table 6. Constraints Each environment can have a maximum of 20 labels. |
| environment_azs | No | Array of objects | Definition List of AZs. Constraints When type is set to high, you need to set two AZs. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| id | Yes | String | Definition Resource ID. (To ensure that the API can be called properly, enter the correct resource ID.) Range N/A Default Value N/A |
| name | No | String | Definition Resource name. Range N/A Default Value N/A |
| type | Yes | String | Definition Resource type. Range
Default Value N/A |
| parameters | No | Map<String, String> | Definition Resource parameters. See Table 5. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| kube_config | No | String | Definition Kubernetes connection configuration file. This parameter is required when the resource type is custom_k8s. Range N/A Default Value N/A |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| key | Yes | String | Definition Label name. Labels are used to identify cloud resources. When you have multiple cloud resources of the same type, you can use labels to classify them based on usage, owner, or environment. Range The value contains 1 to 36 characters, including digits, letters, underscores (_), or hyphens (-). Default Value N/A |
| value | Yes | String | Definition Label value. Range The value contains 1 to 43 characters, including digits, letters, underscores (_), periods (.), or hyphens (-). Default Value N/A |
Response
| Parameter | Type | Description |
|---|---|---|
| id | String | Definition Environment ID. Range N/A |
| name | String | Definition Environment name. Range N/A |
| description | String | Definition Environment description. Range N/A |
| project_id | String | Definition Project ID. Range N/A |
| enterprise_project_id | String | Definition Enterprise project ID. Range N/A |
| deploy_mode | String | Definition Environment type. Range
|
| vpc_id | String | Definition VPC ID. Range N/A |
| creator | String | Definition Environment creator. Range N/A |
| create_time | Integer | Definition Environment creation time. Range N/A |
| update_time | Integer | Definition Environment update time. Range N/A |
| labels | Array of objects | Definition Label. You can use TMS to query resources by labels. See Table 8. |
| type | String | Definition Whether the Kubernetes environment is of the HA type. Range
|
| resource_create_mode | String | Definition Resource configuration mode. Range
|
| config_mode | String | Definition Configuration mode. Range
|
| env_status | String | Definition Non-real-time environment resource status. Range
|
Example Request
Create a VM environment env-test. The ID of the VPC where the environment is located is 0c72428b-cd6c-4283-a560-210d3edb49f7.
{
"name": "env-test",
"description": "",
"enterprise_project_id": "0",
"vpc_id": "0c72428b-cd6c-4283-a560-210d3edb49f7",
"labels": [
{
"key": "aaaaa",
"value": "a5"
}
],
"deploy_mode": "virtualmachine"
} Example Response
{
"id": "c93a5313-d141-4b9f-97ce-b4ce2b3988bd",
"name": "test",
"description": "",
"project_id": "13ae26238d724e54947af3e0fcbef9c3",
"enterprise_project_id": "0",
"vpc_id": "0c72428b-cd6c-4283-a560-210d3edb49f7",
"creator": "ss-test",
"create_time": 1681384236023,
"update_time": 1681384236023,
"deploy_mode": "virtualmachine",
"labels": []
} Status Code
| Status Code | Description |
|---|---|
| 200 | OK |
| 400 | Bad Request |
| 404 | Not Found |
| 500 | Internal Server Error |
Error Code
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot