Creating an Environment

Function

Environment is a collection of infrastructures, covering computing, storage, and networks, used for application deployment and running. ServiceStage enables you to add multiple Elastic Load Balance (ELB), Relational Database Service (RDS), and Distributed Cache Service (DCS) instances to Cloud Container Engine (CCE) clusters in the same Virtual Private Cloud (VPC) to set up an environment, such as the development environment, test environment, production-like environment, and production environment. Networks in an environment can communicate with each other. You can manage resources and deploy services by environment, simplifying infrastructure O&M.

This API is used to create an environment.

URI

POST /v2/{project_id}/cas/environments

Table 1 Path parameters

Parameter

Type

Mandatory

Description

project_id

String

Yes

Tenant's project ID.

Request Parameters

Request parameters

Table 2 Request parameters

Parameter

Type

Mandatory

Description

name

String

Yes

Environment name.

alias

String

No

Environment alias.

description

String

No

Environment description.

enterprise_project_id

String

No

Enterprise project ID.

charge_mode

String

No

Billing mode. Value: provided, on_demanded, and monthly. Default: provided, indicating that provided resources are used and no fees are charged.

vpc_id

String

Yes

VPC ID.

base_resources

Array of objects

Yes

Basic resources. See Table 3.

optional_resources

Array of objects

No

Optional resources. See Table 3.

Table 3 resources parameters

Parameter

Type

Mandatory

Description

id

String

Yes

Resource ID.

type

String

Yes

Basic resources: CCE, Cloud Container Instance (CCI), Elastic Cloud Server (ECS), and Auto Scaling (AS).

Optional resources: RDS, DCS, ELB, and other services.

Response Parameters

Response parameters

Table 4 Response parameters

Parameter

Type

Description

id

String

Environment ID.

name

String

Environment name.

alias

String

Environment alias.

description

String

Environment description.

project_id

String

Project ID.

enterprise_project_id

String

Enterprise project ID.

charge_mode

String

Billing mode.

vpc_id

String

VPC ID.

base_resources

Array of objects

Basic resources. See Table 5.

optional_resources

Array of objects

Optional resources. See Table 5.

creator

String

Creator.

create_time

Integer

Creation time.

update_time

Integer

Update time.

Table 5 resource

Parameter

Type

Description

id

String

Resource ID.

type

String

Basic resources: CCE, CCI, ECS, and AS.

Optional resources: RDS, DCS, ELB, and other services.

Example

Example request

{
    "name": "dev-env", 
    "description": "develop environment", 
    "enterprise_project_id": "0", 
    "charge_mode": "provided", 
    "vpc_id": "b9b8f9ad-1a2e-403d-83f1-cb71a3c06df8", 
    "base_resources": [
        {
            "id": "b6862a62-d916-11e9-bdf1-0255ac101fd9", 
            "type": "cce"
        }
    ], 
    "optional_resources": [
        {
            "id": "default", 
            "type": "cse"
        }
    ]
}

Example response

{
    "id": "ea011e01-2eb5-453f-87bf-874e4a855abe", 
    "name": " environment_name", 
    "alias": null, 
    "description": "develop environment", 
    "project_id": "bf8523d898b64e4eb956e3be3555ca16", 
    "enterprise_project_id": "0", 
    "charge_mode": "provided", 
    "vpc_id": "b9b8f9ad-1a2e-403d-83f1-cb71a3c06df8", 
    "base_resources": [
        {
            "id": "b6862a62-d916-11e9-bdf1-0255ac101fd9", 
            "type": "cce"
        }
    ], 
    "optional_resources": [
        {
            "id": "default", 
            "type": "cse"
        }
    ], 
    "creator": "string", 
    "create_time": 1578984198394, 
    "update_time": 1578984198394
}

Status Code

Table 6 Status codes

HTTP Status Code

Description

200

OK

400

Bad Request

404

Not Found

500

Internal Server Error

Error code must be in the format of SVCSTG.00100.[Error_ID]. Example: SVCSTG.00100400. See Error Codes of Application Management APIs.