Creating an Application Component
Function
A component implements a service feature of an application. It is in the form of code or software packages and can be deployed independently.
This API is used to create an application component.
URI
POST /v2/{project_id}/cas/applications/{application_id}/components
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| project_id | String | Yes | Tenant's project ID. |
| application_id | String | Yes | Application ID. |
Request Parameters
Request parameters
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| name | String | Yes | Application component name. |
| runtime | String | Yes | Runtime. The value can be obtained from type_name returned by the API in Obtaining All Supported Runtimes of Application Components. |
| category | String | Yes | Application component type. Example: Webapp, Microservice, or Common. |
| sub_category | String | No | Application component sub-type. Webapp sub-types include Web, Magento, and Wordpress. Microservice sub-types include Java Chassis, Go Chassis, and Mesher. Common sub-type can be empty. |
| description | String | No | Description. |
| source | Object | No | Source of the code or software package. See Table 3. |
| build | Object | No | Component build. See Table 6. |
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| kind | String | No | Type. Option: source code or artifact software package. |
| spec | Object | No | For details about the source code, see Table 4. For details about the artifact software package, see Table 5. |
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| repo_type | String | Yes | Code repository. Value: GitHub, GitLab, Gitee, or Bitbucket. |
| repo_url | String | Yes | Code repository URL. Example: https://github.com/example/demo.git. |
| repo_ref | String | No | Code branch or tag. Default value: master. |
| repo_auth | String | Yes | Authorization name, which can be obtained from the authorization list. |
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| storage | String | Yes | Storage mode. Value: swr or obs. |
| type | String | Yes | Type. Value: package. |
| url | String | Yes | Source code address of the software package. Example: https://{IP}:20202/xxx/xxx.jar. |
| auth | String | No | Authentication mode. Value: iam or none. Default value: iam. |
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| parameters | Map<String, Object> | No | See Table 7. This parameter is provided only when no ID is available during build creation. |
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| build_cmd | String | No | Compilation command. By default:
|
| dockerfile_path | String | No | Address of the Docker file. By default, the Docker file is in the root directory (./). |
| artifact_namespace | String | No | Build archive organization. Default value: cas_{project_id}. |
Response Parameters
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. |
| category | String | Application component type. Example: Webapp, Microservice, or Common. |
| sub_category | String | Application component sub-type. Webapp sub-types include Web, Magento, and Wordpress. Microservice sub-types include Java Chassis, Go Chassis, and Mesher. Common sub-type 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 9. |
| build | Object | Build. See Table 12. |
| pipeline_ids | ID list | Pipeline ID list. A maximum of 10 pipeline IDs are supported. |
| creator | String | Creator. |
| create_time | Integer | Creation time. |
| update_time | Integer | Update time. |
| Parameter | Type | Description |
|---|---|---|
| kind | String | Type. |
| spec | Object | For details about the source code, see Table 10. For details about the artifact software package, see Table 11. |
| Parameter | Type | Description |
|---|---|---|
| repo_type | String | Code repository. Value: GitHub, GitLab, Gitee, or Bitbucket. |
| 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. |
| Parameter | Type | Description |
|---|---|---|
| storage | String | Storage mode. |
| type | String | Type. |
| url | String | Source code address of the software package. |
| auth | String | Authentication mode. |
| Parameter | Type | Description |
|---|---|---|
| ID | String | Type. |
| parameters | Map<String, Object> | See Table 13. |
Example
Example request
{
"name": "service-a",
"runtime": "Tomcat8",
"category": "Common",
"description": "component_desc",
"source": {
"kind": "artifact",
"spec": {
"storage": "swr",
"type": "package",
"url": "https://{IP}:20202/xxx/xxx.jar",
"auth": "iam"
}
}
} Example response
{
"id": "string",
"name": "service-a",
"runtime": "Tomcat8",
"category": "Common",
"description": "component_desc",
"project_id": "string",
"application_id": "string",
"source": {
"kind": "artifact",
"spec": {
"storage": "swr",
"type": "package",
"url": "https://{IP}:20202/xxx/xxx.jar",
"auth": "iam"
}
},
"build": {
"id": "string",
"parameters": {
"artifact_namespace": "string",
"env_vars": {}
}
},
"pipeline_ids": [
"string"
],
"create_time": 0,
"update_time": 0
} Status Code
| HTTP Status Code | Description |
|---|---|
| 200 | OK |
| 400 | Bad Request |
| 404 | Not Found |
| 500 | Internal Server Error |
Error code must be in the format of SVCSTG.00100.[Error_ID]. Example: SVCSTG.00100400. See Error Codes of Application Management APIs.
Last Article: Components
Next Article: Obtaining All Components of an Application
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.