
# 解析发布单模板包 - ParseReleaseTaskTemplatePackage
#### 功能介绍
此API用来解析发布单模板包。
#### 授权信息
账号具备所有API的调用权限，如果使用账号下的IAM用户调用当前API，该IAM用户需具备调用API所需的权限。
- 如果使用角色与策略授权，具体权限要求请参见[权限和授权项](https://support.huaweicloud.com/api-servicestage/servicestage_06_0183.html)。
- 如果使用身份策略授权，需具备如下身份策略权限。
  
  | 授权项                       | 访问级别 | 资源类型（\*为必须） | 条件键 | 别名 | 依赖的授权项 |
  |:---|:---|:---|:---|:---|:---|
  | servicestage:pipeline:get | read | pipeline \* | -   | -  | -      |
     
  
 
#### URI
POST /v3/{project_id}/pipeline/pipelines/parse-template-package
表1路径参数 
| 参数         | 是否必选 | 参数类型   | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
|:---|:---|:---|:---|
| project_id | 是    | String | **参数解释：** 租户项目ID。获取方法，请参考[获取项目ID](https://support.huaweicloud.com/api-servicestage/servicestage_06_0164.html)。 **约束限制：** 不涉及 **取值范围：** 不涉及 **默认取值：** 不涉及 |
   
#### 请求消息
表2请求Header参数 
| 参数           | 是否必选 | 参数类型   | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
|:---|:---|:---|:---|
| Content-Type | 是    | String | **参数解释：** 消息体的类型（格式）。 **约束限制：** 不涉及 **取值范围：** application/json;charset=utf8 **默认取值：** 不涉及                                                                                                                      |
| X-Auth-Token | 是    | String | **参数解释：** 调用接口的认证方式分为Token和AK/SK两种，如果您使用的Token方式，此参数为必填，请填写Token的值。Token获取方式，请参考[认证鉴权](https://support.huaweicloud.com/api-servicestage/servicestage_06_0010.html)。 **约束限制：** 不涉及 **取值范围：** 不涉及 **默认取值：** 不涉及 |
   
表3请求Body参数 
| 参数      | 是否必选 | 参数类型             | 描述                                                                                       |
|:---|:---|:---|:---|
| sources | 是    | Array of objects | 组件模板包来源，请参考[表4]。 |
   
 表4sources 
| 参数              | 是否必选 | 参数类型                  | 描述                                                                                        |
|:---|:---|:---|:---|
| input_values    | 否    | Map\<String, String\> | 模板包输入信息。                                                                                  |
| template_source | 是    | Object                | 组件模板包来源，请参考[表5]。 |
   
 表5template_source 
| 参数            | 是否必选 | 参数类型             | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
|:---|:---|:---|:---|
| storage       | 是    | String           | 组件模板包存储方式。 - devcloud：CodeArts软件发布库。  - obs：OBS对象存储。  - http：自定义文件地址。   |
| url           | 是    | String           | 组件模板包地址。 组件模板包存储方式为自定义文件地址时有效。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| http_username | 否    | String           | 用户名。 组件模板包存储方式为自定义文件地址且安全认证方式为用户名密码认证时有效。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| http_password | 否    | String           | 密码。 组件模板包存储方式为自定义文件地址且安全认证方式为用户名密码认证时有效。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| http_headers  | 否    | Array of objects | 请求头，请参考[表6]。 组件模板包存储方式为自定义文件地址且安全认证方式为自定义Header认证时有效。                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
   
 表6http_headers 
| 参数    | 是否必选 | 参数类型   | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
|:---|:---|:---|:---|
| key   | 是    | String | **参数解释：** 请求key。 **取值范围：** 不涉及 **默认取值：** 不涉及        |
| value | 是    | String | **参数解释：** 请求value。 **取值范围：** 不涉及 **默认取值：** 不涉及 |
   
#### 响应消息
表7响应参数 
| 参数                | 参数类型             | 描述                                                                                                        |
|:---|:---|:---|
| template_contents | Array of objects | 模板包解析内容，请参考[表8]。 |
   
 表8template_contents 
| 参数           | 参数类型                  | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
|:---|:---|:---|
| template     | Map\<String, String\> | 模板包文件信息。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| variables    | Map\<String, Object\> | 模板包变量声明信息。 - key，变量名。  - value，请参考[表9]。   |
| input_values | Map\<String, String\> | 模板包输入信息。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| package_name | String                | 包名。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
   
 表9variables 
| 参数          | 参数类型   | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
|:---|:---|:---|
| type        | String | 变量类型。 - LIST，集合。  - SET，无重复集合。  - MAP，键值对。  - OBJECT，普通对象。   |
| default     | String | 变量默认值。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| description | String | 变量描述。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
   
#### 请求示例
解析存储在OBS桶obs://apitest/路径下的demo-app-package.zip发布单模板包。
```
{
    "sources": [
        {
            "template_source": {
                "storage": "obs",
                "url": "obs://apitest/demo-app-package.zip",
                "http_username": "",
                "http_password": ""
            },
            "input_values": {}
        }
    ]
}
```
#### 响应示例
```
{
    "template_contents": [
        {
            "template": {
                "comp1/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",
                "comp2/variables.yaml": "variable:\n  namespace:\n    type: string\n    default: demo\n    description: 命名空间\n  dep_name:\n    type: string\n    default: demo-dep\n    description: 工作负载的名字\n  svc_port:\n    type: integer\n    default: 8080\n    description: 服务的端口号\n  value:\n    type: string\n    default: World\n    description: Hello接口响应数据\n  cce_resource:\n    type: cce\n    description: CCE资源\n  image:\n    type: string\n    description: 工作负载镜像",
                "values.yaml": "namespace: demo\ndep_name: demo-dep\nsvc_port: 8080\nvalue: World\nimage: swr.cn-north-4.myhuaweicloud.com/ss/demo-app:latest",
                "comp3/comp_demo/ss-component.yaml": "kind: ServiceStageComponent\nspec:\n  name: zyh-component-3\n  environment_name: default/env-ayl\n  refer_resources:\n    - type: cce\n      id: c90a1197-c26c-11ef-8078-0255ac10009a",
                "comp2/comp_demo/deployment.yaml": "apiVersion: apps/v1\nkind: Deployment\nmetadata:\n  name: zyh-test-dep-2\n  namespace: default\nspec:\n  selector:\n    matchLabels: {}\n  template:\n    metadata:\n      labels: {}\n    spec:\n      containers:\n        - name: container-1\n          image: swr.cn-north-4.myhuaweicloud.com/ss/test3:v1\n          imagePullPolicy: IfNotPresent\n          resources:\n            requests:\n              cpu: 100m\n              memory: 256Mi\n            limits:\n              cpu: 100m\n              memory: 256Mi\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",
                "comp1/comp_demo/ss-component.yaml": "kind: ServiceStageComponent\nspec:\n  name: zyh-component-1\n  environment_name: default/env-ayl\n  refer_resources:\n    - type: cce\n      id: c90a1197-c26c-11ef-8078-0255ac10009a",
                "comp1/variables.yaml": "variable:\n  namespace:\n    type: string\n    default: demo\n    description: 命名空间\n  dep_name:\n    type: string\n    default: demo-dep\n    description: 工作负载的名字\n  svc_port:\n    type: integer\n    default: 8080\n    description: 服务的端口号\n  value:\n    type: string\n    default: World\n    description: Hello接口响应数据\n  cce_resource:\n    type: cce\n    description: CCE资源\n  image:\n    type: string\n    description: 工作负载镜像",
                "comp1/comp_demo/deployment.yaml": "apiVersion: apps/v1\nkind: Deployment\nmetadata:\n  name: zyh-test-dep-1\n  namespace: default\nspec:\n  selector:\n    matchLabels: {}\n  template:\n    metadata:\n      labels: {}\n    spec:\n      containers:\n        - name: container-1\n          image: swr.cn-north-4.myhuaweicloud.com/ss/test3:v1\n          imagePullPolicy: IfNotPresent\n          resources:\n            requests:\n              cpu: 100m\n              memory: 256Mi\n            limits:\n              cpu: 100m\n              memory: 256Mi\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",
                "comp2/values.yaml": "namespace: demo\ndep_name: demo-dep\nsvc_port: 8080\nvalue: World\nimage: swr.cn-north-4.myhuaweicloud.com/ss/demo-app:latest",
                "comp3/spec.yaml": "model_version: v1.0.0\n\ndependency:\n  - component_name: zyh-component-2\n    application_name: default/test-application-zyh\n  - component_name: zyh-component-1\n    application_name: default/test-application-zyh\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",
                "comp1/values.yaml": "namespace: demo\ndep_name: demo-dep\nsvc_port: 8080\nvalue: World\nimage: swr.cn-north-4.myhuaweicloud.com/ss/demo-app:latest",
                "comp3/variables.yaml": "variable:\n  namespace:\n    type: string\n    default: demo\n    description: 命名空间\n  dep_name:\n    type: string\n    default: demo-dep\n    description: 工作负载的名字\n  svc_port:\n    type: integer\n    default: 8080\n    description: 服务的端口号\n  value:\n    type: string\n    default: World\n    description: Hello接口响应数据\n  cce_resource:\n    type: cce\n    description: CCE资源\n  image:\n    type: string\n    description: 工作负载镜像",
                "comp2/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",
                "variables.yaml": "variable:\n  namespace:\n    type: string\n    default: demo\n    description: 命名空间\n  dep_name:\n    type: string\n    default: demo-dep\n    description: 工作负载的名字\n  svc_port:\n    type: integer\n    default: 8080\n    description: 服务的端口号\n  value:\n    type: string\n    default: World\n    description: Hello接口响应数据\n  cce_resource:\n    type: cce\n    description: CCE资源\n  image:\n    type: string\n    description: 工作负载镜像",
                "spec.yaml": "model_version: v1.0.0\n\nmodel_type: Application",
                "comp3/comp_demo/deployment.yaml": "apiVersion: apps/v1\nkind: Deployment\nmetadata:\n  name: zyh-test-dep-3\n  namespace: default\nspec:\n  selector:\n    matchLabels: {}\n  template:\n    metadata:\n      labels: {}\n    spec:\n      containers:\n        - name: container-1\n          image: swr.cn-north-4.myhuaweicloud.com/ss/test3:v1\n          imagePullPolicy: IfNotPresent\n          resources:\n            requests:\n              cpu: 100m\n              memory: 256Mi\n            limits:\n              cpu: 100m\n              memory: 256Mi\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",
                "comp3/values.yaml": "namespace: demo\ndep_name: demo-dep\nsvc_port: 8080\nvalue: World\nimage: swr.cn-north-4.myhuaweicloud.com/ss/demo-app:latest",
                "application.yaml": "kind: ServiceStageApplication\nspec:\n    name: test-application-zyh\n    enterprise_project_id: 0",
                "comp2/comp_demo/ss-component.yaml": "kind: ServiceStageComponent\nspec:\n  name: zyh-component-2\n  environment_name: default/env-ayl\n  refer_resources:\n    - type: cce\n      id: c90a1197-c26c-11ef-8078-0255ac10009a"
            },
            "variable": {
                "comp2/dep_name": {
                    "parsed_type": {
                        "type": "string",
                        "properties": null,
                        "item_type": null
                    },
                    "type": "string",
                    "sensitive": false,
                    "default": "demo-dep",
                    "description": "工作负载的名字"
                },
                "comp1/image": {
                    "parsed_type": {
                        "type": "string",
                        "properties": null,
                        "item_type": null
                    },
                    "type": "string",
                    "sensitive": false,
                    "default": null,
                    "description": "工作负载镜像"
                },
                "image": {
                    "parsed_type": {
                        "type": "string",
                        "properties": null,
                        "item_type": null
                    },
                    "type": "string",
                    "sensitive": false,
                    "default": null,
                    "description": "工作负载镜像"
                },
                "comp2/value": {
                    "parsed_type": {
                        "type": "string",
                        "properties": null,
                        "item_type": null
                    },
                    "type": "string",
                    "sensitive": false,
                    "default": "World",
                    "description": "Hello接口响应数据"
                },
                "comp3/cce_resource": {
                    "parsed_type": {
                        "type": "cce",
                        "properties": null,
                        "item_type": null
                    },
                    "type": "cce",
                    "sensitive": false,
                    "default": null,
                    "description": "CCE资源"
                },
                "comp1/namespace": {
                    "parsed_type": {
                        "type": "string",
                        "properties": null,
                        "item_type": null
                    },
                    "type": "string",
                    "sensitive": false,
                    "default": "demo",
                    "description": "命名空间"
                },
                "comp1/value": {
                    "parsed_type": {
                        "type": "string",
                        "properties": null,
                        "item_type": null
                    },
                    "type": "string",
                    "sensitive": false,
                    "default": "World",
                    "description": "Hello接口响应数据"
                },
                "comp3/namespace": {
                    "parsed_type": {
                        "type": "string",
                        "properties": null,
                        "item_type": null
                    },
                    "type": "string",
                    "sensitive": false,
                    "default": "demo",
                    "description": "命名空间"
                },
                "svc_port": {
                    "parsed_type": {
                        "type": "integer",
                        "properties": null,
                        "item_type": null
                    },
                    "type": "integer",
                    "sensitive": false,
                    "default": 8080,
                    "description": "服务的端口号"
                },
                "cce_resource": {
                    "parsed_type": {
                        "type": "cce",
                        "properties": null,
                        "item_type": null
                    },
                    "type": "cce",
                    "sensitive": false,
                    "default": null,
                    "description": "CCE资源"
                },
                "comp1/svc_port": {
                    "parsed_type": {
                        "type": "integer",
                        "properties": null,
                        "item_type": null
                    },
                    "type": "integer",
                    "sensitive": false,
                    "default": 8080,
                    "description": "服务的端口号"
                },
                "comp3/value": {
                    "parsed_type": {
                        "type": "string",
                        "properties": null,
                        "item_type": null
                    },
                    "type": "string",
                    "sensitive": false,
                    "default": "World",
                    "description": "Hello接口响应数据"
                },
                "comp1/cce_resource": {
                    "parsed_type": {
                        "type": "cce",
                        "properties": null,
                        "item_type": null
                    },
                    "type": "cce",
                    "sensitive": false,
                    "default": null,
                    "description": "CCE资源"
                },
                "comp3/image": {
                    "parsed_type": {
                        "type": "string",
                        "properties": null,
                        "item_type": null
                    },
                    "type": "string",
                    "sensitive": false,
                    "default": null,
                    "description": "工作负载镜像"
                },
                "dep_name": {
                    "parsed_type": {
                        "type": "string",
                        "properties": null,
                        "item_type": null
                    },
                    "type": "string",
                    "sensitive": false,
                    "default": "demo-dep",
                    "description": "工作负载的名字"
                },
                "comp2/cce_resource": {
                    "parsed_type": {
                        "type": "cce",
                        "properties": null,
                        "item_type": null
                    },
                    "type": "cce",
                    "sensitive": false,
                    "default": null,
                    "description": "CCE资源"
                },
                "comp1/dep_name": {
                    "parsed_type": {
                        "type": "string",
                        "properties": null,
                        "item_type": null
                    },
                    "type": "string",
                    "sensitive": false,
                    "default": "demo-dep",
                    "description": "工作负载的名字"
                },
                "comp3/dep_name": {
                    "parsed_type": {
                        "type": "string",
                        "properties": null,
                        "item_type": null
                    },
                    "type": "string",
                    "sensitive": false,
                    "default": "demo-dep",
                    "description": "工作负载的名字"
                },
                "comp3/svc_port": {
                    "parsed_type": {
                        "type": "integer",
                        "properties": null,
                        "item_type": null
                    },
                    "type": "integer",
                    "sensitive": false,
                    "default": 8080,
                    "description": "服务的端口号"
                },
                "comp2/svc_port": {
                    "parsed_type": {
                        "type": "integer",
                        "properties": null,
                        "item_type": null
                    },
                    "type": "integer",
                    "sensitive": false,
                    "default": 8080,
                    "description": "服务的端口号"
                },
                "namespace": {
                    "parsed_type": {
                        "type": "string",
                        "properties": null,
                        "item_type": null
                    },
                    "type": "string",
                    "sensitive": false,
                    "default": "demo",
                    "description": "命名空间"
                },
                "comp2/image": {
                    "parsed_type": {
                        "type": "string",
                        "properties": null,
                        "item_type": null
                    },
                    "type": "string",
                    "sensitive": false,
                    "default": null,
                    "description": "工作负载镜像"
                },
                "value": {
                    "parsed_type": {
                        "type": "string",
                        "properties": null,
                        "item_type": null
                    },
                    "type": "string",
                    "sensitive": false,
                    "default": "World",
                    "description": "Hello接口响应数据"
                },
                "comp2/namespace": {
                    "parsed_type": {
                        "type": "string",
                        "properties": null,
                        "item_type": null
                    },
                    "type": "string",
                    "sensitive": false,
                    "default": "demo",
                    "description": "命名空间"
                }
            },
            "input_values": {
                "comp2/dep_name": "demo-dep",
                "comp1/image": "swr.cn-north-4.myhuaweicloud.com/ss/demo-app:latest",
                "image": "swr.cn-north-4.myhuaweicloud.com/ss/demo-app:latest",
                "comp2/value": "World",
                "comp3/cce_resource": null,
                "comp1/namespace": "demo",
                "comp1/value": "World",
                "comp3/namespace": "demo",
                "svc_port": 8080,
                "cce_resource": null,
                "comp1/svc_port": 8080,
                "comp3/value": "World",
                "comp1/cce_resource": null,
                "comp3/image": "swr.cn-north-4.myhuaweicloud.com/ss/demo-app:latest",
                "dep_name": "demo-dep",
                "comp2/cce_resource": null,
                "comp1/dep_name": "demo-dep",
                "comp3/dep_name": "demo-dep",
                "comp3/svc_port": 8080,
                "comp2/svc_port": 8080,
                "namespace": "demo",
                "comp2/image": "swr.cn-north-4.myhuaweicloud.com/ss/demo-app:latest",
                "value": "World",
                "comp2/namespace": "demo"
            },
            "package_name": "demo-app-package.zip"
        }
    ]
}
```
#### 状态码
| 状态码 | 描述       |
|:---|:---|
| 200 | 操作成功。    |
| 400 | 错误的请求。   |
| 404 | 请求对象不存在。 |
| 500 | 内部错误。    |
   
#### 错误码
请参考[ServiceStage错误码](https://support.huaweicloud.com/api-servicestage/servicestage_06_0162.html)。
