Updated on 2025-02-14 GMT+08:00

Updating a Component

Function

This API is used to update a component.

URI

PUT /v1/{project_id}/cae/applications/{application_id}/components/{component_id}

Table 1 Path parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. See Obtaining a Project ID.

application_id

Yes

String

Application ID.

component_id

Yes

String

Component ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token.

Maximum characters: 16,384

X-Enterprise-Project-ID

No

String

Enterprise project ID.

  • When an environment is created, it will be bound with an enterprise project ID.
  • Enter 0 or up to 36 characters in UUID format with hyphens (-).
  • If this parameter is not specified or set to 0, resources in the default enterprise project are queried.
NOTE:

For more information about enterprise projects and how to obtain enterprise project IDs, see Enterprise Management User Guide.

X-Environment-ID

Yes

String

Environment ID.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

api_version

Yes

String

API version. Fixed value: v1.

Enumerated value:

  • v1

kind

Yes

String

API type. Fixed value: Component.

Enumerated value:

  • Component

metadata

No

UpdateComponentRequestMetadata object

Request data.

spec

No

UpdateComponentRequestSpec object

Component specifications.

Table 4 UpdateComponentRequestMetadata

Parameter

Mandatory

Type

Description

name

Yes

String

Component name.

annotations

No

Map<String,String>

Additional parameter for updating a component. Only version is supported. This parameter is mandatory.

Table 5 UpdateComponentRequestSpec

Parameter

Mandatory

Type

Description

runtime

No

String

Language or runtime.

Enumerated values:

  • Docker
  • Java8
  • Java11
  • Java17
  • Tomcat8
  • Tomcat9
  • Python3
  • Nodejs8
  • Nodejs14
  • Nodejs16
  • Php7

source

No

Source object

Source information.

build

No

Build object

Build information.

resource_limit

Yes

ResourceLimit object

Instance specifications.

replica

No

Integer

Number of instances.

Table 6 Source

Parameter

Mandatory

Type

Description

code

No

Repo object

Source code repository information.

type

Yes

String

Source type.

Enumerated values:

  • image
  • code
  • softwarePackage

sub_type

No

String

Source subtype.

  • If type is code, sub_type indicates a code repository, such as GitLab, GitHub, or Bitbucket.
  • If type is softwarePackage, sub_type indicates a software package repository, such as BinObs or BinDevCloud (CodeArts Release Repo).

Enumerated values:

  • BinObs
  • BinDevCloud
  • GitLab
  • GitHub
  • Bitbucket

url

Yes

String

URL.

  • If type is image, url indicates an image address.
  • If type is code, url indicates a Git address.
  • If type is softwarePackage, url indicates a software package address.
Table 7 Repo

Parameter

Mandatory

Type

Description

auth_name

No

String

Authorization name.

branch

No

String

Branch.

namespace

No

String

Namespace, which must be Base64-encoded.

Table 8 Build

Parameter

Mandatory

Type

Description

archive

Yes

Archive object

Place where build products are archived for management.

parameters

Yes

map<string, object>

Additional parameters. Options:

  • base_image: base image address.
  • build_cmd: custom build command.
  • dockerfile_path: custom dockerfile path.
  • dockerfile_content: custom dockerfile content.
  • artifact_name: product to be run after the Java multi-module build. The value ends with .jar.
Table 9 Archive

Parameter

Mandatory

Type

Description

artifact_namespace

No

String

SWR organization for product management.

Table 10 ResourceLimit

Parameter

Mandatory

Type

Description

cpu_limit

Yes

String

CPU limit.

Enumerated values:

  • 500m
  • 1000m
  • 2000m

memory_limit

Yes

String

Memory limit.

Enumerated values:

  • 1Gi
  • 2Gi
  • 4Gi

Response Parameters

None

Example Request

  • Change the component code source to a source code repository: Set the component name to demo, version to 1.0.0, and runtime to Java8, and select source code repository GitLab.
    PUT https://{endpoint}/v1/{project_id}/cae/applications/{application_id}/components/{component_id}
    
    {
      "api_version" : "v1",
      "kind" : "Component",
      "metadata" : {
        "name" : "demo",
        "annotations" : {
          "version" : "1.0.0"
        }
      },
      "spec" : {
        "runtime" : "Java8",
        "build" : {
          "archive" : {
            "artifact_namespace" : "xxx"
          },
          "parameters" : {
            "base_image" : "xxx",
            "dockerfile_path" : "xxx"
          }
        },
        "source" : {
          "type" : "code",
          "sub_type" : "GitLab",
          "url" : "https://xxx:8090/xxx/cae-frontend.git",
          "code" : {
            "branch" : "master",
            "auth_name" : "gitlab-xxx",
            "namespace" : "em1n"
          }
        },
        "resource_limit" : {
          "cpu_limit" : "500m",
          "memory_limit" : "1Gi"
        },
        "replica" : 1
      }
    }
  • Change the component code source to an image: Set the component name to demo, version to 1.0.0, and runtime to Docker, and select image cae-demo.
    PUT https://{endpoint}/v1/{project_id}/cae/applications/{application_id}/components/{component_id}
    
    {
      "api_version" : "v1",
      "kind" : "Component",
      "metadata" : {
        "name" : "demo",
        "annotations" : {
          "version" : "1.0.0"
        }
      },
      "spec" : {
        "runtime" : "Docker",
        "build" : {
          "archive" : {
            "artifact_namespace" : "xxx"
          },
          "parameters" : {
            "base_image" : "xxx"
          }
        },
        "source" : {
          "type" : "image",
          "url" : "xxx/cae-demo:v1"
        },
        "resource_limit" : {
          "cpu_limit" : "500m",
          "memory_limit" : "1Gi"
        },
        "replica" : 1
      }
    }
  • Change the component code source to a software package: Set the component name to demo, version to 1.0.0, and runtime to Java8, and select software package forecast-1.0.0.jar.
    PUT https://{endpoint}/v1/{project_id}/cae/applications/{application_id}/components/{component_id}
    
    {
      "api_version" : "v1",
      "kind" : "Component",
      "metadata" : {
        "name" : "demo",
        "annotations" : {
          "version" : "1.0.0"
        }
      },
      "spec" : {
        "runtime" : "Java8",
        "build" : {
          "archive" : {
            "artifact_namespace" : "xxx"
          },
          "parameters" : {
            "base_image" : "openjdk:8u181-jdk-alpine",
            "dockerfile_content" : "xxx"
          }
        },
        "source" : {
          "type" : "softwarePackage",
          "sub_type" : "BinObs",
          "url" : "https://xxx.obs.region.xxx.huawei.com/xxx/forecast-1.0.0.jar"
        },
        "resource_limit" : {
          "cpu_limit" : "500m",
          "memory_limit" : "1Gi"
        },
        "replica" : 1
      }
    }

Example Response

None

Status Code

Status Code

Description

200

The request is successful.

Error Code

For details, see Error Codes.