Updated on 2024-10-16 GMT+08:00

Modifying a Component Instance

Function

This API is used to modify a component instance.

URI

PUT /v2/{project_id}/cas/applications/{application_id}/components/{component_id}/instances/{instance_id}

Table 1 Path parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Tenant's project ID. See Obtaining a Project ID.

application_id

Yes

String

Application ID. See Obtaining All Applications.

component_id

Yes

String

Component ID. See Obtaining All Components of an Application.

instance_id

Yes

String

Component instance ID. See Obtaining All Component Instances.

Request

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

Content-Type

Yes

String

Message body type (format). Default value: application/json;charset=utf8.

X-Auth-Token

Yes

String

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 a token, see Obtaining a User Token.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

version

Yes

String

Application component version that meets version semantics. Example: 1.0.1.

flavor_id

No

String

Resource specifications, which can be obtained by using the API in Obtaining All Supported Flavors of Application Resources.

If you need to customize resource specifications, the format is CUSTOM-xxG:xxm-xxm:xxGi-xxGi. Where:

  • xxG: storage capacity allocated to a component instance. It is a reserved field. You can set it to a fixed number.
  • xxm-xxm: the maximum and minimum number of CPU cores allocated to a component instance.
  • xxGi-xxGi: the maximum and minimum memory allocated to a component instance.

For example, CUSTOM-10G:0.5m-0.25m:1.6Gi-0.8Gi indicates that the maximum number of CPU cores allocated to a component instance is 0.5, the minimum number of CPU cores is 0.25, the maximum memory is 1.6 Gi, and the minimum memory is 0.8 Gi.

artifacts

No

Map<String, Object>

Artifact. key indicates the component name. In the Docker container scenario, key indicates the container name. See Table 4.

configuration

No

Object

Configuration parameters, such as environment variables, deployment configurations, and O&M monitoring. By default, this parameter is left blank. See Table 4 in Creating an Application Component Instance.

description

No

String

Description.

The value can contain up to 128 characters.

external_accesses

No

Array of objects

Access mode. See Table 5.

refer_resources

No

Array of objects

Deployed resources. See Table 6.

Table 4 artifact

Parameter

Mandatory

Type

Description

storage

Yes

String

Storage mode. Value: swr (software repository), swr (image), obs, or codearts.

type

Yes

String

Type.

  • VM-based deployment supports package.
  • Container-based deployment supports package and image.

url

Yes

String

Software package or image address. For a component deployed on a VM, this parameter is the software package address. For a component deployed based on a container, this parameter is the image address or component name:v${index}. The latter indicates that the component source code or the image automatically built using the software package will be used.

auth

Yes

String

Authentication mode. Value: iam or none. Default value: iam.

version

No

String

Version number.

properties

No

Map<String,String>

Property information.

Table 5 external_accesses

Parameter

Mandatory

Type

Description

id

No

String

Access type ID.

protocol

Yes

String

Protocol. Value: http or https.

address

Yes

String

Access address. Example: www.example.com.

forward_port

Yes

Integer

Port for listening to an application component process.

type

No

String

Type.

status

No

String

Status.

create_time

No

Integer

Creation time.

update_time

No

Integer

Update time.

Table 6 refer_resources

Parameter

Mandatory

Type

Description

id

Yes

String

Resource ID.

type

Yes

String

Resource type. Example: rds or dcs.

refer_alias

No

String

Application alias. This parameter is available only when type is set to dcs. Value: "distributed_session", "distributed_cache", or "distributed_session, distributed_cache" (default).

parameters

No

Map<String, Object>

Reference resource parameter.

Response

Table 7 Response parameter

Parameter

Type

Description

job_id

String

Job ID, which is used to query information about the created job.

Example Request

Modify the application component instance. Change the artifact to the test-micro image package in the SWR image repository swr.roma-dev-1.roma.development.com/ns1/examples:v2. Change the deployment resources to the CCE resource whose ID is 523498f1-36c4-11eb-ae36-0255ac1000c2 and the professional microservice engine cse.

{
	"description": "",
	"artifacts": {
		"test-micro": {
			"storage": "swr",
			"type": "image",
			"url": "swr.roma-dev-1.roma.development.com/ns1/examples:v2", 
			"auth": "iam",
			"version": "1.0.0",
			"properties": {}
		}
	},
	"refer_resources": [
		{
			"id": "523498f1-36c4-11eb-ae36-0255ac1000c2",
			"type": "cce",
			"parameters": {
				"namespace": "default"
			}
		},
		{
			"id": "default",
			"type": "cse"
		}
	],
	"version": "1.0.2"
}

Example Response

{
    "job_id": "JOB66761060-f209-407c-a093-4df6f531b9dc"
}

Status Code

Status Code

Description

200

OK

400

Bad Request

404

Not Found

500

Internal Server Error

Error Code

The error code format is SVCSTG.00100.[Error_ID], for example, SVCSTG.00100400. For details, see ServiceStage Error Codes.