Updated on 2026-04-10 GMT+08:00

Parsing a Component Template Package

Function

This API is used to parse a component template package.

Authorization Information

Each account has all of the permissions required to call all APIs, but IAM users must have the required permissions specifically assigned.

  • If you are using role/policy-based authorization, see the required permissions in Permissions and Supported Actions.
  • If you are using identity policy-based authorization, the permission listed below is required.

    Action

    Access Level

    Resource Type (*: required)

    Condition Key

    Alias

    Dependencies

    servicestage:app:getComponent

    read

    app *

    servicestage:app:get

    -

URI

POST /v3/{project_id}/cas/components/parse-template-package

Table 1 Path parameter

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition

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

Constraints

N/A

Range

N/A

Default Value

N/A

Request

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

Content-Type

Yes

String

Definition

Message body type (or format).

Constraints

N/A

Range

application/json;charset=utf8

Default Value

N/A

X-Auth-Token

Yes

String

Definition

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 the token, see Authentication.

Constraints

N/A

Range

N/A

Default Value

N/A

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

template_source

No

Object

Definition

Source of the component template package. See Table 4.

component_id

No

String

Definition

Component ID.

Range

N/A

Default Value

N/A

Table 4 template_source

Parameter

Mandatory

Type

Description

storage

Yes

String

Definition

Storage mode of the component template package.

Range

  • devcloud: CodeArts release repository
  • obs
  • http: custom file address

Default Value

N/A

url

Yes

String

Definition

Address of the component template package.

This parameter is valid only when the component template package storage mode is http.

Range

N/A

Default Value

N/A

http_username

No

String

Definition

Username.

This parameter is valid only when the component template package storage mode is http and the security authentication mode is username and password authentication.

Range

N/A

Default Value

N/A

http_password

No

String

Definition

Password.

This parameter is valid only when the component template package storage mode is http and the security authentication mode is username and password authentication.

Range

N/A

Default Value

N/A

http_headers

No

Array of objects

Definition

Request header. See Table 5.

This parameter is valid only when the component template package storage mode is http and the security authentication mode is custom header authentication.

Table 5 http_headers

Parameter

Mandatory

Type

Description

key

Yes

String

Definition

Request key.

Range

N/A

Default Value

N/A

value

Yes

String

Definition

Request value.

Range

N/A

Default Value

N/A

Response

Table 6 Response parameters

Parameter

Type

Description

template

Map<String, String>

Definition

Template package file information.

Range

N/A

variables

Map<String, Object>

Definition

Template package variable declaration information.

Range

input_values

Map<String, String>

Definition

Template package input information.

Range

N/A

Table 7 variables

Parameter

Type

Description

type

String

Definition

Variable type.

Range

  • LIST: set
  • SET: set (no duplicate values)
  • MAP: key-value pair
  • OBJECT: common object

default

String

Definition

Default variable value.

Range

N/A

description

String

Definition

Variable description.

Range

N/A

Example Request

Parse the demo-app-package.zip component template package stored in the obs://apitest/ directory of the OBS bucket.

{
    "template_source": {
        "storage": "obs",
        "url": "obs://apitest/demo-app-package.zip",
        "http_username": null,
        "http_password": null
    }
}

Example Response

{
    "template": {
        "comp_demo/service-account.yaml": "apiVersion: v1\nkind: ServiceAccount\nmetadata:\n  name: ss-demo-app-account\n  namespace: ${var.namespace}",
        "comp_demo/role.yaml": "apiVersion: rbac.authorization.k8s.io/v1\nkind: Role\nmetadata:\n  name: ss-demo-app-role\n  namespace: ${var.namespace}\nrules:\n  - apiGroups: [ \"\" ]\n    resources: [ \"pods\" ]\n    verbs: [ \"get\", \"list\", \"watch\" ]",
        "values.yaml": "namespace: demo\ndep_name: demo-dep\nsvc_port: 8080\nvalue: World\nimage: swr.ap-southeast-1.myhuaweicloud.com/ss/demo-app:latest\nconfig_name: demo-group/application-wqd.yaml",
        "comp_demo/rolebinding.yaml": "apiVersion: rbac.authorization.k8s.io/v1\nkind: RoleBinding\nmetadata:\n  name: ss-demo-app-rolebinding\n  namespace: ${var.namespace}\nroleRef:\n  apiGroup: rbac.authorization.k8s.io\n  kind: Role\n  name: ss-demo-app-role\nsubjects:\n  - kind: ServiceAccount\n    name: ss-demo-app-account\n    namespace: ${var.namespace}",
        "comp_demo/service.yaml": "apiVersion: v1\nkind: Service\nmetadata:\n  name: demo-app-service\n  namespace: ${var.namespace}\nspec:\n  selector:\n    app: ${var.dep_name}\n  ports:\n    - name: cce-service-0\n      targetPort: ${var.svc_port}\n      port: ${var.svc_port}\n      protocol: TCP\n  type: ClusterIP\n",
        "comp_demo/ss-component.yaml": "kind: ServiceStageComponent\nspec:\n  name: ${var.dep_name}\n  refer_resources:\n    - type: cce\n      id: ${var.cce_resource}\n    - type: elb\n      id: ${var.elb_resource}\n  external_accessed:\n    - address: www.demo.com\n      forward_port: 8080\n      id : ${var.elb_resource}\n      protocol: HTTP\n      type: SPECIFIED\n  configs:\n    - config_name: ${var.config_name}\n      mount_path: /home/demo/application-wqd.yaml\n      container_name: container-1",
        "comp_demo/ss-config.yaml": "kind: ServiceStageConfig\nspec:\n  name: ${var.config_name}\n  description: desc\n  sensitive: true\n  content: |\n    server:\n      port: ${var.svc_port}\n    demo:\n      value: ${var.value}",
        "comp_demo/secret.yaml": "apiVersion: v1\nkind: Secret\nmetadata:\n  name: ss-demo-app-secret\n  namespace: ${var.namespace}\ntype: Opaque\ndata:\n  SECRET_KEY: ******",
        "comp_demo/hpa.yaml": "kind: HorizontalPodAutoscaler\napiVersion: autoscaling/v2\nmetadata:\n  name: ss-demo-app-hpa\n  namespace: ${var.namespace}\nspec:\n  scaleTargetRef:\n    kind: Deployment\n    name: ${var.dep_name}\n    apiVersion: apps/v1\n  minReplicas: 1\n  maxReplicas: 10\n  metrics:\n    - type: Resource\n      resource:\n        name: cpu\n        target:\n          type: Utilization\n          averageUtilization: 70",
        "comp_demo/deployment.yaml": "apiVersion: apps/v1\nkind: Deployment\nmetadata:\n  name: ${var.dep_name}\n  namespace: ${var.namespace}\nspec:\n  selector:\n    matchLabels: {}\n  template:\n    metadata:\n      labels: {}\n    spec:\n      containers:\n        - name: container-1\n          image: ${var.image}\n          imagePullPolicy: IfNotPresent\n          envFrom:\n            - configMapRef:\n                name: ss-demo-app-configmap\n            - secretRef:\n                name: ss-demo-app-secret\n          resources:\n            requests:\n              cpu: 100m\n              memory: 256Mi\n            limits:\n              cpu: 100m\n              memory: 256Mi\n      serviceAccountName: ss-demo-app-account\n      imagePullSecrets:\n        - name: default-secret\n      terminationGracePeriodSeconds: 30\n      dnsPolicy: ClusterFirst\n  replicas: 2\n  revisionHistoryLimit: 10\n  strategy:\n    type: RollingUpdate\n    rollingUpdate:\n      maxUnavailable: 25%\n      maxSurge: 25%\n  progressDeadlineSeconds: 600\n",
        "variables.yaml": "variable:\n  config_name:\n    type: string\n    default: demo-group/application-wqd.yaml\n    description: configuration file name\n  namespace:\n    type: string\n    default: demo\n    description: namespace\n  dep_name:\n    type: string\n    default: demo-dep\n    description: workload name\n  svc_port:\n    type: integer\n    default: 8080\n    description: service port number\n  value:\n    type: string\n    default: World\n    description: Hello interface response data\n  cce_resource:\n    type: cce\n    description: CCE resource\n  elb_resource:\n    type: elb\n    description: ELB resource\n  image:\n    type: string\n    description: workload image",
        "comp_demo/configmap.yaml": "apiVersion: v1\nkind: ConfigMap\nmetadata:\n  name: ss-demo-app-configmap\n  namespace: ${var.namespace}\ndata:\n  CONFIG_KEY: \"value\"",
        "spec.yaml": "model_version: v1.0.0\n\ncomponent:\n  component_dir: comp_demo/\n\nk8s_resources:\n  order_type: CUSTOM\n  custom_orders:\n    - ServiceAccount\n    - Role\n    - RoleBinding\n    - ConfigMap\n    - Secret\n    - Deployment\n    - HorizontalPodAutoscaler\n    - Service\n    - Ingress"
    },
    "input_values": {
        "config_name": "demo-group/application.yaml",
        "image": "swr.ap-southeast-1.myhuaweicloud.com/ss/demo-app:latest",
        "svc_port": 8080,
        "cce_resource": null,
        "namespace": "demo",
        "dep_name": "demo-dep",
        "value": "World",
        "elb_resource": null
    }
}

Status Code

Status Code

Description

200

OK

400

Bad Request

404

Not Found

500

Internal Server Error

Error Code

See ServiceStage Error Codes.