Help Center/ ServiceStage/ API Reference/ Historical APIs/ Application Management V2 APIs/ Component/ Modifying Component Information Based on the Component ID
Updated on 2024-10-16 GMT+08:00

Modifying Component Information Based on the Component ID

Function

This API is used to modify component information based on the component ID.

URI

PUT /v2/{project_id}/cas/applications/{application_id}/components/{component_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.

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

name

No

String

Application component name.

The value contains 2 to 64 characters consisting of letters, digits, hyphens (-), and underscores (_). It starts with a letter and ends with a letter or digit. Letters are case insensitive.

description

No

String

Description.

The value can contain up to 128 characters.

source

No

Object

Source of the code or software package. See Table 4.

build

No

Object

Build. See Table 8.

Table 4 source

Parameter

Mandatory

Type

Description

kind

Yes

String

Type. Option: source code or artifact software package.

spec

Yes

Object

For details about the source code, see Table 5. For details about the artifact software package, see Table 6.

Table 5 code spec

Parameter

Mandatory

Type

Description

repo_type

No

String

Code repository type. Value: GitHub, BitBucket, or GitLab.

repo_url

No

String

Code repository URL. Example: https://github.com/example/demo.git.

repo_ref

No

String

Code branch or tag. Default value: master.

repo_auth

No

String

Authorization name, which can be obtained from the authorization list.

Table 6 artifact spec

Parameter

Mandatory

Type

Description

storage

No

String

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

type

No

String

Type.

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

url

No

String

Address of the software package or source code.

auth

No

String

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

properties

No

Object

Other attributes of the software package. You need to add these attributes only when you set storage to obs. See Table 7.

webUrl

No

String

Address of a software repository.

Table 7 artifact spec properties

Parameter

Mandatory

Type

Description

endpoint

No

String

OBS endpoint address. Example: https://obs.region_id.external_domain_name.com.

bucket

No

String

Name of the OBS bucket where the software package is stored.

key

No

String

Object in the OBS bucket, which is usually the name of the software package. If there is a folder, the path of the folder must be added. Example: test.jar or demo/test.jar.

Table 8 build

Parameter

Mandatory

Type

Description

parameters

No

Map<String, Object>

See Table 9. This parameter is provided only when no ID is available during build creation.

Table 9 parameters

Parameter

Mandatory

Type

Description

build_cmd

No

String

Compilation command. By default:

  1. When build.sh exists in the root directory, the command is ./build.sh.
  2. When build.sh does not exist in the root directory, the command varies depending on the OS. Example:
    • Java and Tomcat: mvn clean package
    • Node.js: npm build

dockerfile_path

No

String

Address of the Docker file. By default, the Docker file is in the root directory (./).

artifact_namespace

No

String

Build archive organization. Default value: cas_{project_id}.

cluster_id

Yes

String

ID of the cluster to be built.

node_label_selector

No

Map<String, String>

key: label key. value: label value.

cluster_name

No

String

Name of the cluster to be built.

use_public_cluster

No

Boolean

Whether to use the public cluster:

  • true
  • false

cluster_type

No

String

Type of the cluster to be built.

Response

Table 10 Response parameters

Parameter

Type

Description

id

String

Application component ID.

name

String

Application component name.

status

Integer

Value: 0 or 1.

0: Normal.

1: Being deleted.

runtime

String

Runtime system.

category

String

Application component category. Example: Webapp, MicroService, or Common.

sub_category

String

Application component sub-category.

Webapp sub-categories include Web.

MicroService sub-categories include Java Chassis, and Spring Cloud.

Common sub-category can be empty.

description

String

Description.

project_id

String

Project ID.

application_id

String

Application ID.

source

Object

Source of the code or software package. See Table 11.

build

Object

Build. See Table 15.

create_time

Integer

Creation time.

update_time

Integer

Update time.

creator

String

Creator.

Table 11 source

Parameter

Type

Description

kind

String

Type.

spec

Object

For details about the source code, see Table 12. For details about the artifact software package, see Table 13.

Table 12 code spec

Parameter

Type

Description

repo_type

String

Code repository type. Value: github, bitbucket, or gitlab.

repo_url

String

Code repository URL. Example: https://github.com/example/demo.git.

repo_ref

String

Code branch or tag. Default value: master.

repo_auth

String

Authorization name, which can be obtained from the authorization list.

Table 13 spec

Parameter

Type

Description

storage

String

Storage mode.

type

String

Type.

url

String

Address of the software package or source code.

auth

String

Authentication mode.

properties

Object

Other attributes of the software package. You need to add these attributes only when you set storage to obs. See Table 14.

Table 14 artifact spec properties

Parameter

Type

Description

endpoint

String

OBS endpoint address. Example: https://obs.region_id.external_domain_name.com.

bucket

String

Name of the OBS bucket where the software package is stored.

key

String

Object in the OBS bucket, which is usually the name of the software package. If there is a folder, the path of the folder must be added. Example: test.jar or demo/test.jar.

Table 15 build

Parameter

Type

Description

id

String

Type.

parameters

Map<String, Object>

See Table 16.

Table 16 parameters

Parameter

Type

Description

build_cmd

String

Compilation command.

dockerfile_path

String

Address of the Docker file.

artifact_namespace

String

Build archive organization.

cluster_id

String

ID of the cluster to be built.

node_label_selector

Map<String, String>

key: label key. value: label value.

Example Request

Modify the component information corresponding to the specified component ID as follows: Change the component name to test-micro, set the component software package source to the fusionweather-1.0.0.jar package in the test-soft bucket of OBS, and specify the cce-test cluster as the component to build a cluster.

{
	"name": "test-micro",
	"description": "",
	"source": {
		"kind": "artifact",
		"spec": {
			"storage": "obs",
			"type": "package",
			"url": "obs://test-soft/fusionweather-1.0.0.jar",
			"auth": "iam",
			"webUrl": "",
			"properties": {
				"bucket": "test-soft",
				"endpoint": "https://obs.region_id.development.com:443",
				"key": "fusionweather-1.0.0.jar"
			}
		}
	},
	"build": {
		"parameters": {
			"artifact_namespace": "ns",
			"use_public_cluster": false,
			"cluster_id": "523498f1-36c4-11eb-ae36-0255ac1000c2",
			"cluster_name": "cce-test",
			"cluster_type": "VirtualMachine"
		}
	},
}

Example Response

{
	"id": "1cfdda6f-84cd-4ead-8e09-628fabf662e2",
	"name": "test-micro",
	"runtime": "Java8",
	"category": "MicroService",
	"sub_category": "Java Chassis",
	"description": "",
	"project_id": "e7d2e9c589e5445e808a8ff0d1235aca",
	"application_id": "4d92833a-fa05-4fc0-a761-e67620022310",
	"source": {
		"kind": "artifact",
		"spec": {
			"storage": "obs",
			"type": "package",
			"url": "obs://test-soft/fusionweather-1.0.0.jar",
			"auth": "iam",
			"properties": {
				"bucket": "test-soft",
				"endpoint": "https://obs.region_id.development.com:443",
				"key": "fusionweather-1.0.0.jar"
			}
		}
	},
	"build": {
		"id": "zpdkj42b3rnko8bmyojzt1ng828ubychw13j8flv",
		"parameters": {
			"artifact_namespace": "ns",
			"cluster_id": "523498f1-36c4-11eb-ae36-0255ac1000c2"
		}
	},
		"status": 0,

	"creator": "ss-test",
	"create_time": 1610331760105,
	"update_time": 1610519881943
}

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.