CreateEnvironments - Create environments
Applicable versions | Central version, Region version |
Endpoint and authorization information
Obtain the endpoint and use it to replace {domain} in the API request syntax.
Obtain the organization ID. This parameter is required only for the Central version. Go to the Basic Information page in the Organization Management console to obtain your organization ID.
Product | Resource | Required permission |
Application Delivery | Environment | Read and write |
Request syntax
Central version
POST https://{domain}/oapi/v1/appstack/organizations/{organizationId}/apps/{appName}/envsRegion version
POST https://{domain}/oapi/v1/appstack/apps/{appName}/envsRequest headers
Parameter | Type | Required | Description | Example |
x-yunxiao-token | string | Yes | Personal access token. | pt-0fh3****0fbG_35af****0484 |
Request parameters
Parameter | Type | Location | Required | Description | Example |
appName | string | path | Yes | Application name. | my-web-service |
organizationId | string | path |
| Organization ID. | ec766e63aee3437d9a51f334d6exe671 |
| - | object | body | No | Create environment request. | |
deployGroupName | string | body | No | Deployment group name. | deploy-group-name |
description | string | body | No | Environment description. | description |
displayName | string | body | No | Environment display name. | display-name |
| labelList | array | body | Yes | List of labels. | |
| - | object | body | No | AppStack label. | |
displayName | string | body | No | Label display name. Used for descriptive purposes only and not used in label matching. | Test label key |
displayValue | string | body | No | Label display value. Used for descriptive purposes only and not used in label matching. | Test label value |
extraMap | object | body | No | Label extension attribute map. You can use this to store custom extension fields when defining a label. | {} |
name | string | body | No | Label name. Must contain only lowercase letters, hyphens, and digits, and must start and end with a lowercase letter or digit. | demo-label |
namespace | string | body | No | Label namespace. Determines the scope of the label. | default |
value | string | body | No | Label value. Must contain only lowercase letters, hyphens, and digits, and must start and end with a lowercase letter or digit. | demo-label-value |
name | string | body | Yes | Environment name. | env-name |
| profiles | array | body | No | List of variable groups. | |
| - | object | body | No | Generic variable group model. | |
displayName | string | body | No | Variable group display name. | Development variable group |
name | string | body | No | Variable group identifier. | dev |
type | string | body | No | Variable group type. | GLOBAL |
replicasManagement | string | body | No | Replica count control mode. Possible values: [SYSTEM USER]. | SYSTEM |
resourcePoolName | string | body | Yes | Resource pool name. | default |
resourceType | string | body | Yes | Resource type. Possible values: [KUBERNETES HOST BePending]. | KUBERNETES |
| rolloutStrategies | array | body | No | List of deployment strategies. | |
| - | object | body | No | Deployment strategy. | |
batchMode | string | body | No | Batch mode. Possible values: [ConfirmFirstBatch Auto Manual]. | ConfirmFirstBatch |
| batchSteps | array | body | No | List of batch details. | |
| - | object | body | No | Batch detail. | |
type | string | body | Yes | Batch type. Possible values: [WEIGHT REPLICAS]. | WEIGHT |
value | string | body | Yes | Batch value. | 90 |
batches | string | body | No | Number of batches. | 2 |
deployType | string | body | No | Deployment type. Possible values: [Rolling Batch Recreate]. | Batch |
locator | string | body | Yes | Deployment resource coordinate. | aaa.bbb.ccc |
targetReplicas | number | body | No | Target replica count. | 3 |
timeOutMS | number | body | No | Timeout duration. | 60000 |
Request examples
Central version
curl -X 'POST' \
'https://{domain}/oapi/v1/appstack/organizations/ec766e63aee3437d9a51f334d6exe671/apps/my-web-service/envs' \
-H 'Content-Type: application/json' \
-H 'x-yunxiao-token: pt-0fh3****0fbG_35af****0484' \
--data '
{
"deployGroupName": "deploy-group-name",
"description": "description",
"displayName": "display-name",
"labelList": [
{
"displayName": "Test label key",
"displayValue": "Test label value",
"extraMap": {},
"name": "demo-label",
"namespace": "default",
"value": "demo-label-value"
}
],
"name": "env-name",
"profiles": [
{
"displayName": "Development variable group",
"name": "dev",
"type": "GLOBAL"
}
],
"replicasManagement": "SYSTEM",
"resourcePoolName": "default",
"resourceType": "KUBERNETES",
"rolloutStrategies": [
{
"batchMode": "ConfirmFirstBatch",
"batchSteps": [
{
"type": "WEIGHT",
"value": "90"
}
],
"batches": "2",
"deployType": "Batch",
"locator": "aaa.bbb.ccc",
"targetReplicas": 3,
"timeOutMS": 60000
}
]
}'Region version
curl -X 'POST' \
'https://{domain}/oapi/v1/appstack/apps/my-web-service/envs' \
-H 'Content-Type: application/json' \
-H 'x-yunxiao-token: pt-0fh3****0fbG_35af****0484' \
--data '
{
"deployGroupName": "deploy-group-name",
"description": "description",
"displayName": "display-name",
"labelList": [
{
"displayName": "Test label key",
"displayValue": "Test label value",
"extraMap": {},
"name": "demo-label",
"namespace": "default",
"value": "demo-label-value"
}
],
"name": "env-name",
"profiles": [
{
"displayName": "Development variable group",
"name": "dev",
"type": "GLOBAL"
}
],
"replicasManagement": "SYSTEM",
"resourcePoolName": "default",
"resourceType": "KUBERNETES",
"rolloutStrategies": [
{
"batchMode": "ConfirmFirstBatch",
"batchSteps": [
{
"type": "WEIGHT",
"value": "90"
}
],
"batches": "2",
"deployType": "Batch",
"locator": "aaa.bbb.ccc",
"targetReplicas": 3,
"timeOutMS": 60000
}
]
}'Response parameters
Parameter | Type | Description | Example |
| - | object | AppStack environment model. | |
appName | string | Unique name of the application to which the environment belongs. | my-web-service |
creatorId | string | User ID of the environment creator. | bd9e3c6d-624f-4580-af7d-c5e26f1ed0f0 |
deployGroupName | string | Unique name of the deployment group. | k8s-dev |
description | string | Environment description. | This is a development environment for demonstration purposes. |
descriptiveName | string | Environment display name. | Staging environment |
gmtCreate | string | Environment creation time. | 2024-09-01 00:00:00 |
| labelList | array | List of labels. | |
| - | object | AppStack label. | |
displayName | string | Label display name. Used for descriptive purposes only and not used in label matching. | Test label key |
displayValue | string | Label display value. Used for descriptive purposes only and not used in label matching. | Test label value |
extraMap | object | Label extension attribute map. You can use this to store custom extension fields when defining a label. | {} |
name | string | Label name. Must contain only lowercase letters, hyphens, and digits, and must start and end with a lowercase letter or digit. | demo-label |
namespace | string | Label namespace. Determines the scope of the label. | default |
value | string | Label value. Must contain only lowercase letters, hyphens, and digits, and must start and end with a lowercase letter or digit. | demo-label-value |
lockBy | string | User ID of the user currently locking the environment. | bd9e3c6d-624f-4580-af7d-c5e26f1ed0f0 |
name | string | Unique environment name. Must contain only lowercase letters, hyphens, and digits, and must start and end with a lowercase letter or digit. | dev |
replicasManagement | string | Replica management mode. | USER |
resourcePoolName | string | Unique name of the resource pool. | default |
| rolloutStrategies | array | Deployment strategy. | |
| - | object | Deployment strategy. | |
batchMode | string | Batch mode. Possible values: [ConfirmFirstBatch Auto Manual]. | ConfirmFirstBatch |
| batchSteps | array | List of batch details. | |
| - | object | Batch detail. | |
type | string | Batch type. Possible values: [WEIGHT REPLICAS]. | WEIGHT |
value | string | Batch value. | 90 |
batches | string | Number of batches. | 2 |
deployType | string | Deployment type. Possible values: [Rolling Batch Recreate]. | Batch |
locator | string | Deployment resource coordinate. | aaa.bbb.ccc |
targetReplicas | number | Target replica count. | 3 |
timeOutMS | number | Timeout duration. | 60000 |
state | string | Environment state. Possible values: [NEW DEPLOYING RUNNING ERROR]. | my-web-service |
variableGroupName | string | Unique name of the variable group. | dev |
| variableGroups | array | Variable groups. | |
| - | object | Generic variable group model. | |
displayName | string | Variable group display name. | Development variable group |
name | string | Variable group identifier. | dev |
type | string | Variable group type. | GLOBAL |
Response example
{
"appName": "my-web-service",
"creatorId": "bd9e3c6d-624f-4580-af7d-c5e26f1ed0f0",
"deployGroupName": "k8s-dev",
"description": "This is a development environment for demonstration purposes.",
"descriptiveName": "Staging environment",
"gmtCreate": "2024-09-01 00:00:00",
"labelList": [
{
"displayName": "Test label key",
"displayValue": "Test label value",
"extraMap": {},
"name": "demo-label",
"namespace": "default",
"value": "demo-label-value"
}
],
"lockBy": "bd9e3c6d-624f-4580-af7d-c5e26f1ed0f0",
"name": "dev",
"replicasManagement": "USER",
"resourcePoolName": "default",
"rolloutStrategies": [
{
"batchMode": "ConfirmFirstBatch",
"batchSteps": [
{
"type": "WEIGHT",
"value": "90"
}
],
"batches": "2",
"deployType": "Batch",
"locator": "aaa.bbb.ccc",
"targetReplicas": 3,
"timeOutMS": 60000
}
],
"state": "my-web-service",
"variableGroupName": "dev",
"variableGroups": [
{
"displayName": "Development variable group",
"name": "dev",
"type": "GLOBAL"
}
]
}Error codes
For more information about API-related error codes, see Error Code Center.