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
Parameter |
Type |
Mandatory |
Description |
---|---|---|---|
name |
String |
Yes |
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. |
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. MicroService sub-types include Java Chassis, Go Chassis, Mesher, Spring Cloud, and Dubbo. Common sub-type can be empty. |
description |
String |
No |
Description. The value can contain up to 128 characters. |
source |
Object |
No |
Source of the code or software package. See Table 3. |
build |
Object |
No |
Component build. See Table 7. |
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: obs. |
type |
String |
Yes |
Type. Value: package. |
url |
String |
Yes |
Software package address. |
auth |
String |
No |
Authentication mode. Value: iam or none. Default value: iam. |
properties |
Object |
No |
Other attributes of the software package. You need to add these attributes only when you set storage to obs. See Table 6. |
Parameter |
Type |
Mandatory |
Description |
---|---|---|---|
endpoint |
String |
No |
OBS endpoint address. Example: https://obs.region_id.external_domain_name.com. |
bucket |
String |
No |
Name of the OBS bucket where the software package is stored. |
key |
String |
No |
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. |
Parameter |
Type |
Mandatory |
Description |
---|---|---|---|
parameters |
Map<String, Object> |
No |
See Table 8. |
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}. |
cluster_id |
String |
No |
ID of the cluster to be built. |
node_label_selector |
Map<String, String> |
No |
key indicates the key of the tag, and value indicates the value of the tag. |
Response
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. MicroService sub-types include Java Chassis, Go Chassis, Mesher, Spring Cloud, and Dubbo. 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 10. |
build |
Object |
Build. See Table 14. |
pipeline_ids |
ID list |
Pipeline ID list. A maximum of 10 pipeline IDs are supported. |
create_time |
Integer |
Creation time. |
update_time |
Integer |
Update time. |
creator |
String |
Creator. |
Parameter |
Type |
Description |
---|---|---|
kind |
String |
Type. Option: source code or artifact software package. |
spec |
Object |
For details about the source code, see Table 11. For details about the artifact software package, see Table 12. |
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 |
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 13. |
Parameter |
Type |
Mandatory |
Description |
---|---|---|---|
endpoint |
String |
No |
OBS endpoint address. Example: https://obs.region_id.external_domain_name.com. |
bucket |
String |
No |
Name of the OBS bucket where the software package is stored. |
key |
String |
No |
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. |
Parameter |
Type |
Description |
---|---|---|
ID |
String |
Type. |
parameters |
Map<String, Object> |
See Table 15. |
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 indicates the key of the tag, and value indicates the value of the tag. |
Example
Example request
{ "name": "mycomponent", "runtime": "Java8", "category": "MicroService", "sub_category": "Java Chassis", "description": "", "build": { "parameters": { "artifact_namespace": "ns" } }, "source": { "kind": "artifact", "spec": { "storage": "obs", "type": "package", "url": "obs://myapp/demo.jar", "properties": { "bucket": "myapp", "key": "demo.jar", "endpoint": "https://obs.region_id.external_domain_name.com" } } } }
Example response
{ "id": "384eb8d4-c193-4d84-9558-6fda2366b536", "name": "mycomponent", "runtime": "Java8", "category": "MicroService", "sub_category": "Java Chassis", "description": "", "project_id": "384eb8d4-c193-4d84-9558-6fda23698536", "application_id": "a8f7eed5-0aa0-4251-9723-c9119a6bf56d", "source": { "kind": "artifact", "spec": { "storage": "obs", "type": "package", "url": "obs://myapp/demo.jar", "properties": { "bucket": "myapp", "key": "demo.jar", "endpoint": "https://obs.region_id.external_domain_name.com" } } }, "build": { "id": "w3dpv7p0t1vpxvey5hjb22iuwxway1vupwx0nae1", "parameters": { "artifact_namespace": "ns", "use_public_cluster": true } }, "pipeline_ids": null, "status": 0, "creator": "xxx", "create_time": 1610333934288, "update_time": 1610333934288 }
Status Code
Status Code |
Description |
---|---|
200 |
OK |
400 |
Bad Request |
404 |
Not Found |
500 |
Internal Server Error |
Error Code
Error code must be in the format of SVCSTG.00100.[Error_ID]. Example: SVCSTG.00100400. See Error Codes of Application Management APIs.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot