UpdateEnvComputationResource - Associate a computation resource

Updated at:

Applicable editions

Central Edition, Region Edition

Service endpoint and authorization

  • Get service endpoint: Replace {domain} in the API request syntax.
  • Get Personal Access Token.
  • Get the organization ID: Required only for Central Edition. Go to the Organization Management console and find the organization ID on the Basic Information page.

Product

Resource

Required permission

AppStack

environment

Read/write

Request syntax

Central Edition

POST https://{domain}/oapi/v1/appstack/organizations/{organizationId}/apps/{appName}/envs/{envName}:updateComputationResource

Region Edition

POST https://{domain}/oapi/v1/appstack/apps/{appName}/envs/{envName}:updateComputationResource

Request headers

Parameter

Type

Required

Description

Example value

x-yunxiao-token

string

Yes

The personal access token.

pt-0fh3****0fbG_35af****0484

Request parameters

Parameter

Type

Location

Required

Description

Example value

appName

string

path

Yes

The application name.

my-web-service

envName

string

path

Yes

The environment name.

dev

organizationId

string

path

  • Yes for Central Edition

  • No for Region Edition

The organization ID.

ec766e63aee3437d9a51f334d6exe671

-

object

body

No

The request body to associate an environment with a computation resource.

deployGroupName

string

body

Yes

The unique name of the deployment group.

test-deploy-group

resourceType

string

body

Yes

The type of the computation resource. The resource can be a Kubernetes cluster or a host cluster. Valid values: KUBERNETES and HOST.

KUBERNETES

Request examples

Central Edition

curl -X 'POST' \
  'https://{domain}/oapi/v1/appstack/organizations/ec766e63aee3437d9a51f334d6exe671/apps/my-web-service/envs/dev:updateComputationResource' \
  -H 'Content-Type: application/json' \
  -H 'x-yunxiao-token: pt-0fh3****0fbG_35af****0484' \
  --data '
    {
        "deployGroupName": "test-deploy-group",
        "resourceType": "KUBERNETES"
    }'

Region Edition

curl -X 'POST' \
  'https://{domain}/oapi/v1/appstack/apps/my-web-service/envs/dev:updateComputationResource' \
  -H 'Content-Type: application/json' \
  -H 'x-yunxiao-token: pt-0fh3****0fbG_35af****0484' \
  --data '
    {
        "deployGroupName": "test-deploy-group",
        "resourceType": "KUBERNETES"
    }'

Response parameters

Parameter

Type

Description

Example value

-

object

The AppStack environment model.

appName

string

The unique name of the application that contains the environment.

my-web-service

creatorId

string

The ID of the user who created the environment.

bd9e3c6d-624f-4580-af7d-c5e26f1ed0f0

deployGroupName

string

The unique name of the deployment group.

k8s-dev

description

string

The description of the environment.

This is a development environment for demonstration purposes.

descriptiveName

string

The display name of the environment.

Test Environment

gmtCreate

string

The creation time of the environment.

2024-09-01 00:00:00

labelList

array

A list of labels.

-

object

An AppStack label.

displayName

string

The display name of the label. This is for descriptive purposes only and is not used for matching.

Test Label Key

displayValue

string

The display value of the label. This is for descriptive purposes only and is not used for matching.

Test Label Value

extraMap

object

A map of extended attributes for the label. You can use this to store custom fields when defining a label.

{}

name

string

The name of the label. It must contain only lowercase letters, digits, and hyphens (-). It must start and end with a lowercase letter or digit.

demo-label

namespace

string

The namespace of the label, which determines its scope.

default

value

string

The value of the label. It must contain only lowercase letters, digits, and hyphens (-). It must start and end with a lowercase letter or digit.

demo-label-value

lockBy

string

The ID of the user currently locking the environment.

bd9e3c6d-624f-4580-af7d-c5e26f1ed0f0

name

string

The unique name of the environment. It must contain only lowercase letters, digits, and hyphens (-). It must start and end with a lowercase letter or digit.

dev

replicasManagement

string

The replica management mode.

USER

resourcePoolName

string

The unique name of the resource pool.

default

rolloutStrategies

array

The rollout strategies.

-

object

A rollout strategy.

batchMode

string

The batch mode. Valid values: ConfirmFirstBatch, Auto, and Manual.

ConfirmFirstBatch

batchSteps

array

A list of batch steps.

-

object

A batch step.

type

string

The type of the batch step. Valid values: WEIGHT and REPLICAS.

WEIGHT

value

string

The value of the batch step.

90

batches

string

The number of batches.

2

deployType

string

The deployment type. Valid values: Rolling, Batch, and Recreate.

Batch

locator

string

The location of the deployment resource.

aaa.bbb.ccc

targetReplicas

number

The target number of replicas.

3

timeOutMS

number

The timeout period, in milliseconds.

60000

state

string

The state of the environment. Valid values: NEW, DEPLOYING, RUNNING, and ERROR.

RUNNING

variableGroupName

string

The unique name of the variable group.

dev

variableGroups

array

The variable groups.

-

object

The common variable group model.

displayName

string

The display name of the variable group.

Development Variable Group

name

string

The identifier of the variable group.

dev

type

string

The type of the variable group.

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": "Test 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": "RUNNING",
    "variableGroupName": "dev",
    "variableGroups": [
        {
            "displayName": "Development Variable Group",
            "name": "dev",
            "type": "GLOBAL"
        }
    ]
}

Error codes

For a list of API error codes, see the Error Code Center.