Creating an Application (Recommended)
Function
This API is used to create an application.
Calling Method
For details, see Calling APIs.
URI
POST /v1/applications
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
Content-Type |
Yes |
String |
Definition: Type (or format) of the message body. Constraints: N/A. Value range: N/A. Default value: N/A. |
X-Auth-Token |
Yes |
String |
Definition: User token. Obtain a token (the value of the X-Subject-Token response header) by calling the IAM API used forObtaining a User Token. Constraints: N/A. Value range: String. Max. 20,000 characters. Default value: N/A. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Definition: Project ID. For details, see Obtaining a Project ID. Constraints: N/A. Value range: 32 characters, including letters and digits. Default value: N/A. |
name |
Yes |
String |
Definition: Application name. Constraints: N/A. Value range: 3 to 128 characters, including letters, digits, underscores (_), and hyphens (-). Default value: N/A. |
description |
No |
String |
Definition: Application description. Constraints: N/A. Value range: Max. 1,024 characters. Default value: N/A. |
group_id |
No |
String |
Definition: Group ID of an application. If no_grouped is transferred, the application is not grouped. Constraints: N/A. Value range: 32 characters, including letters and digits. no_grouped is also supported. Default value: N/A. |
is_draft |
Yes |
Boolean |
Definition: Draft or not. Constraints: N/A. Value range:
Default value: N/A. |
create_type |
Yes |
String |
Definition: Creation type. Constraints: N/A. Value range:
Default value: N/A. |
slave_cluster_id |
No |
String |
Definition: Slave cluster ID. It is empty by default. When it is empty, the default agent pool is used. Constraints: N/A. Value range: 1 to 32 characters, including letters and digits. Default value: N/A. |
trigger |
No |
TaskTriggerVO object |
Definition: Deployment task triggering scenarios. Constraints: trigger_source is mandatory when trigger is set. |
arrange_infos |
No |
Array of TaskV2RequestBody objects |
Definition: Deployment application list. Constraints: N/A. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
trigger_source |
No |
String |
Definition: Scenario where a deployment task can be executed. Constraints: N/A. Value range:
Default value: N/A. |
artifact_source_system |
No |
String |
Definition: Pipeline source when a task can be executed only by the pipeline. Constraints: N/A. Value range:
Default value: N/A. |
artifact_type |
No |
String |
Definition: Artifact repository type when a task can be executed only by the pipeline. Constraints: N/A. Value range:
Default value: N/A. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
template_id |
No |
String |
Definition: Deployment template ID. Constraints: N/A. Value range: 32 characters, including letters and digits. Default value: N/A. |
operation_list |
No |
Array of DeployV2OperationsDO objects |
Definition: Deployment orchestration list. Constraints: N/A. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
id |
No |
String |
Definition: Action ID. Constraints: N/A. Value range: Digits only. Default value: N/A. |
name |
No |
String |
Definition: Action name. Constraints: N/A. Value range: 1 to 128 characters. Default value: N/A. |
description |
No |
String |
Definition: Action description. Constraints: N/A. Value range: Max. 1,024 characters. Default value: N/A. |
code |
No |
String |
Definition: Action download address. Constraints: N/A. Value range: Max. 102,400 characters. Default value: N/A. |
params |
No |
String |
Definition: Detailed definition of actions. Constraints: N/A. Value range: Max. 204,800 characters. Default value: N/A. |
entrance |
No |
String |
Definition: Action entry function. Constraints: N/A. Value range: Max. 1,024 characters. Default value: N/A. |
version |
No |
String |
Definition: Action version. Constraints: N/A. Value range: Max. 1,024 characters. Default value: N/A. |
module_id |
No |
String |
Definition: Action module ID. Constraints: N/A. Value range: Max. 1,024 characters. Default value: N/A. |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
status |
String |
Definition: Request status (successful or failed). Value range:
|
result |
AppBaseResponse object |
Definition: Response body for application basic information. |
Parameter |
Type |
Description |
---|---|---|
id |
String |
Parameter description: Application ID. Value range: The value consists of 32 characters. Letters and digits are allowed. |
name |
String |
Parameter description: Application name. Value range: The value consists of 3-128 characters. Only letters, digits, hyphens (-) and underscores (_) are allowed. |
region |
String |
Parameter description: Region to which the application belongs. Value range: N/A |
arrange_infos |
Array of TaskBaseBody objects |
Parameter description: Deployment task list. |
Example Requests
This API is used to create an application.
https://{endpoint}/v1/applications { "name" : "testApp", "project_id" : "55837d272adf4eee90319800e2da6961", "description" : "Create an application using a template.", "trigger" : { "trigger_source" : 0, "artifact_source_system" : "", "artifact_type" : "" }, "slave_cluster_id" : "", "create_type" : "template", "is_draft" : true, "arrange_infos" : [ { "template_id" : "43b36b4678f743568e1ffebfd7f4ce76", "operation_list" : [ { "name" : "Application deployment in Kubernetes (CCE cluster) using Manifest", "description" : "Deploy an application in a Huawei Cloud CCE cluster with manifest file defining Kubernetes objects. [View operation guide](https://support.huaweicloud.com/en-us/usermanual-deployman/deployman_hlp_1096.html)", "code" : "https://example.com", "params" : "[{\"name\":\"datasource\",\"label\":\"Manifest file source\",\"displaySettings\":{\"DevCloud.ControlType\":\"Radio\",\"DevCloud.ControlType.Style\":\"ButtonGroup\",\"DevCloud.ControlType.Radio\":[{\"displayName\":\"CodeArts Artifact\",\"value\":\"1\"},{\"displayName\":\"CodeArts Repo\",\"value\":\"2\"},{\"displayName\":\"obs\",\"value\":\"4\"}],\"DevCloud.ControlType.Default\":{\"displayName\":\"CodeArts Artifact\",\"value\":\"1\",\"icon\":\"img/release.png\"}},\"defaultDisplay\":[{\"displayName\":\"CodeArts Artifact\",\"value\":\"1\"}],\"validation\":{\"pattern\":null,\"patternDescription\":null,\"maxLength\":null,\"dataType\":null,\"isRequired\":true,\"isNotParameter\":true}},{\"name\":\"deployTenant\",\"label\":\"Deployment tenant\",\"displaySettings\":{\"DevCloud.ControlType\":\"Select\",\"DevCloud.ControlType.Style\":null,\"DevCloud.ControlType.Select\":[{\"displayName\":\"Current Tenant\",\"value\":\"local\"},{\"displayName\":\"Other Tenant\",\"value\":\"other\"}],\"DevCloud.ControlType.Default\":{\"displayName\":\"Current Tenant\",\"value\":\"local\"}},\"defaultDisplay\":[{\"displayName\":\"Current Tenant\",\"value\":\"local\"}],\"validation\":{\"pattern\":null,\"patternDescription\":null,\"maxLength\":null,\"dataType\":null,\"isRequired\":true,\"isNotParameter\":true}},{\"name\":\"use_iam_checkbox\",\"displaySettings\":{\"DevCloud.ControlType\":\"Checkbox\",\"DevCloud.ControlType.Style\":null,\"DevCloud.ControlType.Checkbox\":[{\"displayName\":\"IAM Authorization\",\"value\":\"0\"}]},\"defaultDisplay\":[{\"displayName\":\"IAM Authorization\",\"value\":\"0\"}],\"visibleRule\":\"deployTenant=local\",\"validation\":{\"pattern\":null,\"patternDescription\":null,\"maxLength\":null,\"dataType\":null,\"isRequired\":false,\"isNotParameter\":true}},{\"name\":\"javaProbeCheckBox\",\"displaySettings\":{\"DevCloud.ControlType\":\"Checkbox\",\"DevCloud.ControlType.Style\":null,\"DevCloud.ControlType.Checkbox\":[{\"displayName\":\"Configure JAVA Probes\",\"value\":\"0\"}]},\"defaultDisplay\":[{\"displayName\":\"Configure JAVA Probes\",\"value\":\"0\"}],\"visibleRule\":\"not 1=1\",\"validation\":{\"pattern\":null,\"patternDescription\":null,\"maxLength\":null,\"dataType\":null,\"isRequired\":false,\"isNotParameter\":false}},{\"name\":\"controller_enabled_ignore_errors\",\"displaySettings\":{\"DevCloud.ControlType\":\"Checkbox\",\"DevCloud.ControlType.Style\":null,\"DevCloud.ControlType.Checkbox\":[{\"displayName\":\" Continue Upon Failure\",\"value\":\"0\"}]},\"defaultDisplay\":[{\"displayName\":\" Continue Upon Failure\",\"value\":\"0\"}],\"validation\":{\"pattern\":null,\"patternDescription\":null,\"maxLength\":null,\"dataType\":null,\"isRequired\":true,\"isNotParameter\":false}},{\"name\":\"controller_enabled_overtime\",\"label\":\"Timeout\",\"displaySettings\":{\"DevCloud.ControlType\":\"SingleLineText\",\"DevCloud.ControlType.Style\":null},\"defaultValue\":\"10\",\"validation\":{\"pattern\":\"^([1-9]|[1-2][0-9]|30)$\",\"patternDescription\":\" The time unit is minute. Enter an integer from 1 to 30.\",\"maxLength\":null,\"dataType\":null,\"isRequired\":true,\"isNotParameter\":false}},{\"name\":\"controller_enabled\",\"displaySettings\":{\"DevCloud.ControlType\":\"Hidden\",\"DevCloud.ControlType.Style\":null},\"defaultDisplay\":[{\"displayName\":\"Enable\",\"value\":\"1\"}]},{\"name\":\"visibleRule\",\"displaySettings\":{\"DevCloud.ControlType\":\"Hidden\",\"DevCloud.ControlType.Style\":null},\"defaultValue\":\"{\\\"use_iam_checkbox\\\":{\\\"value\\\":true,\\\"condition\\\":\\\"deployTenant=local\\\"},\\\"controller_enabled_overtime\\\":{\\\"value\\\":true},\\\"javaProbeCheckBox\\\":{\\\"value\\\":true,\\\"condition\\\":\\\"not 1=1\\\"},\\\"datasource\\\":{\\\"value\\\":true},\\\"deployTenant\\\":{\\\"value\\\":true},\\\"controller_enabled_ignore_errors\\\":{\\\"value\\\":true}}\"}]", "entrance" : "main.yml", "version" : "2.3.69", "module_id" : "devcloud2018.k8s-cce-manifest-deployment.k8sdeploy-manifest" } ] } ] }
Example Responses
Status code: 200
OK: The request is successful.
{ "result" : { "id" : "e700f15965694253940502911220d76b", "name" : "testApp", "region" : "region-a", "is_disable" : false, "arrange_infos" : [ { "id" : "3ea35372b6db4d58b187e9a7ee9dc349" } ] }, "status" : "success" }
SDK Sample Code
The SDK sample code is as follows.
Java
This API is used to create an application.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.codeartsdeploy.v2.region.CodeArtsDeployRegion; import com.huaweicloud.sdk.codeartsdeploy.v2.*; import com.huaweicloud.sdk.codeartsdeploy.v2.model.*; import java.util.List; import java.util.ArrayList; public class CreateAppSolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); ICredential auth = new BasicCredentials() .withAk(ak) .withSk(sk); CodeArtsDeployClient client = CodeArtsDeployClient.newBuilder() .withCredential(auth) .withRegion(CodeArtsDeployRegion.valueOf("<YOUR REGION>")) .build(); CreateAppRequest request = new CreateAppRequest(); CreateAppRequestBody body = new CreateAppRequestBody(); List<DeployV2OperationsDO> listArrangeInfosOperationList = new ArrayList<>(); listArrangeInfosOperationList.add( new DeployV2OperationsDO() .withName("Application deployment in Kubernetes (CCE cluster) using Manifest") .withDescription("Deploy an application in a Huawei Cloud CCE cluster with manifest file defining Kubernetes objects. [View operation guide](https://support.huaweicloud.com/en-us/usermanual-deployman/deployman_hlp_1096.html)") .withCode("https://example.com") .withParams("[{"name":"datasource","label":"Manifest file source","displaySettings":{"DevCloud.ControlType":"Radio","DevCloud.ControlType.Style":"ButtonGroup","DevCloud.ControlType.Radio":[{"displayName":"CodeArts Artifact","value":"1"},{"displayName":"CodeArts Repo","value":"2"},{"displayName":"obs","value":"4"}],"DevCloud.ControlType.Default":{"displayName":"CodeArts Artifact","value":"1","icon":"img/release.png"}},"defaultDisplay":[{"displayName":"CodeArts Artifact","value":"1"}],"validation":{"pattern":null,"patternDescription":null,"maxLength":null,"dataType":null,"isRequired":true,"isNotParameter":true}},{"name":"deployTenant","label":"Deployment tenant","displaySettings":{"DevCloud.ControlType":"Select","DevCloud.ControlType.Style":null,"DevCloud.ControlType.Select":[{"displayName":"Current Tenant","value":"local"},{"displayName":"Other Tenant","value":"other"}],"DevCloud.ControlType.Default":{"displayName":"Current Tenant","value":"local"}},"defaultDisplay":[{"displayName":"Current Tenant","value":"local"}],"validation":{"pattern":null,"patternDescription":null,"maxLength":null,"dataType":null,"isRequired":true,"isNotParameter":true}},{"name":"use_iam_checkbox","displaySettings":{"DevCloud.ControlType":"Checkbox","DevCloud.ControlType.Style":null,"DevCloud.ControlType.Checkbox":[{"displayName":"IAM Authorization","value":"0"}]},"defaultDisplay":[{"displayName":"IAM Authorization","value":"0"}],"visibleRule":"deployTenant=local","validation":{"pattern":null,"patternDescription":null,"maxLength":null,"dataType":null,"isRequired":false,"isNotParameter":true}},{"name":"javaProbeCheckBox","displaySettings":{"DevCloud.ControlType":"Checkbox","DevCloud.ControlType.Style":null,"DevCloud.ControlType.Checkbox":[{"displayName":"Configure JAVA Probes","value":"0"}]},"defaultDisplay":[{"displayName":"Configure JAVA Probes","value":"0"}],"visibleRule":"not 1=1","validation":{"pattern":null,"patternDescription":null,"maxLength":null,"dataType":null,"isRequired":false,"isNotParameter":false}},{"name":"controller_enabled_ignore_errors","displaySettings":{"DevCloud.ControlType":"Checkbox","DevCloud.ControlType.Style":null,"DevCloud.ControlType.Checkbox":[{"displayName":" Continue Upon Failure","value":"0"}]},"defaultDisplay":[{"displayName":" Continue Upon Failure","value":"0"}],"validation":{"pattern":null,"patternDescription":null,"maxLength":null,"dataType":null,"isRequired":true,"isNotParameter":false}},{"name":"controller_enabled_overtime","label":"Timeout","displaySettings":{"DevCloud.ControlType":"SingleLineText","DevCloud.ControlType.Style":null},"defaultValue":"10","validation":{"pattern":"^([1-9]|[1-2][0-9]|30)$","patternDescription":" The time unit is minute. Enter an integer from 1 to 30.","maxLength":null,"dataType":null,"isRequired":true,"isNotParameter":false}},{"name":"controller_enabled","displaySettings":{"DevCloud.ControlType":"Hidden","DevCloud.ControlType.Style":null},"defaultDisplay":[{"displayName":"Enable","value":"1"}]},{"name":"visibleRule","displaySettings":{"DevCloud.ControlType":"Hidden","DevCloud.ControlType.Style":null},"defaultValue":"{\"use_iam_checkbox\":{\"value\":true,\"condition\":\"deployTenant=local\"},\"controller_enabled_overtime\":{\"value\":true},\"javaProbeCheckBox\":{\"value\":true,\"condition\":\"not 1=1\"},\"datasource\":{\"value\":true},\"deployTenant\":{\"value\":true},\"controller_enabled_ignore_errors\":{\"value\":true}}"}]") .withEntrance("main.yml") .withVersion("2.3.69") .withModuleId("devcloud2018.k8s-cce-manifest-deployment.k8sdeploy-manifest") ); List<TaskV2RequestBody> listbodyArrangeInfos = new ArrayList<>(); listbodyArrangeInfos.add( new TaskV2RequestBody() .withTemplateId("43b36b4678f743568e1ffebfd7f4ce76") .withOperationList(listArrangeInfosOperationList) ); TaskTriggerVO triggerbody = new TaskTriggerVO(); triggerbody.withTriggerSource("0") .withArtifactSourceSystem("") .withArtifactType(""); body.withArrangeInfos(listbodyArrangeInfos); body.withTrigger(triggerbody); body.withSlaveClusterId(""); body.withCreateType(CreateAppRequestBody.CreateTypeEnum.fromValue("template")); body.withIsDraft(true); body.withDescription("Create an application using a template."); body.withName("testApp"); body.withProjectId("55837d272adf4eee90319800e2da6961"); request.withBody(body); try { CreateAppResponse response = client.createApp(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } } |
Python
This API is used to create an application.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkcodeartsdeploy.v2.region.codeartsdeploy_region import CodeArtsDeployRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkcodeartsdeploy.v2 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.environ["CLOUD_SDK_AK"] sk = os.environ["CLOUD_SDK_SK"] credentials = BasicCredentials(ak, sk) client = CodeArtsDeployClient.new_builder() \ .with_credentials(credentials) \ .with_region(CodeArtsDeployRegion.value_of("<YOUR REGION>")) \ .build() try: request = CreateAppRequest() listOperationListArrangeInfos = [ DeployV2OperationsDO( name="Application deployment in Kubernetes (CCE cluster) using Manifest", description="Deploy an application in a Huawei Cloud CCE cluster with manifest file defining Kubernetes objects. [View operation guide](https://support.huaweicloud.com/en-us/usermanual-deployman/deployman_hlp_1096.html)", code="https://example.com", params="[{"name":"datasource","label":"Manifest file source","displaySettings":{"DevCloud.ControlType":"Radio","DevCloud.ControlType.Style":"ButtonGroup","DevCloud.ControlType.Radio":[{"displayName":"CodeArts Artifact","value":"1"},{"displayName":"CodeArts Repo","value":"2"},{"displayName":"obs","value":"4"}],"DevCloud.ControlType.Default":{"displayName":"CodeArts Artifact","value":"1","icon":"img/release.png"}},"defaultDisplay":[{"displayName":"CodeArts Artifact","value":"1"}],"validation":{"pattern":null,"patternDescription":null,"maxLength":null,"dataType":null,"isRequired":true,"isNotParameter":true}},{"name":"deployTenant","label":"Deployment tenant","displaySettings":{"DevCloud.ControlType":"Select","DevCloud.ControlType.Style":null,"DevCloud.ControlType.Select":[{"displayName":"Current Tenant","value":"local"},{"displayName":"Other Tenant","value":"other"}],"DevCloud.ControlType.Default":{"displayName":"Current Tenant","value":"local"}},"defaultDisplay":[{"displayName":"Current Tenant","value":"local"}],"validation":{"pattern":null,"patternDescription":null,"maxLength":null,"dataType":null,"isRequired":true,"isNotParameter":true}},{"name":"use_iam_checkbox","displaySettings":{"DevCloud.ControlType":"Checkbox","DevCloud.ControlType.Style":null,"DevCloud.ControlType.Checkbox":[{"displayName":"IAM Authorization","value":"0"}]},"defaultDisplay":[{"displayName":"IAM Authorization","value":"0"}],"visibleRule":"deployTenant=local","validation":{"pattern":null,"patternDescription":null,"maxLength":null,"dataType":null,"isRequired":false,"isNotParameter":true}},{"name":"javaProbeCheckBox","displaySettings":{"DevCloud.ControlType":"Checkbox","DevCloud.ControlType.Style":null,"DevCloud.ControlType.Checkbox":[{"displayName":"Configure JAVA Probes","value":"0"}]},"defaultDisplay":[{"displayName":"Configure JAVA Probes","value":"0"}],"visibleRule":"not 1=1","validation":{"pattern":null,"patternDescription":null,"maxLength":null,"dataType":null,"isRequired":false,"isNotParameter":false}},{"name":"controller_enabled_ignore_errors","displaySettings":{"DevCloud.ControlType":"Checkbox","DevCloud.ControlType.Style":null,"DevCloud.ControlType.Checkbox":[{"displayName":" Continue Upon Failure","value":"0"}]},"defaultDisplay":[{"displayName":" Continue Upon Failure","value":"0"}],"validation":{"pattern":null,"patternDescription":null,"maxLength":null,"dataType":null,"isRequired":true,"isNotParameter":false}},{"name":"controller_enabled_overtime","label":"Timeout","displaySettings":{"DevCloud.ControlType":"SingleLineText","DevCloud.ControlType.Style":null},"defaultValue":"10","validation":{"pattern":"^([1-9]|[1-2][0-9]|30)$","patternDescription":" The time unit is minute. Enter an integer from 1 to 30.","maxLength":null,"dataType":null,"isRequired":true,"isNotParameter":false}},{"name":"controller_enabled","displaySettings":{"DevCloud.ControlType":"Hidden","DevCloud.ControlType.Style":null},"defaultDisplay":[{"displayName":"Enable","value":"1"}]},{"name":"visibleRule","displaySettings":{"DevCloud.ControlType":"Hidden","DevCloud.ControlType.Style":null},"defaultValue":"{\"use_iam_checkbox\":{\"value\":true,\"condition\":\"deployTenant=local\"},\"controller_enabled_overtime\":{\"value\":true},\"javaProbeCheckBox\":{\"value\":true,\"condition\":\"not 1=1\"},\"datasource\":{\"value\":true},\"deployTenant\":{\"value\":true},\"controller_enabled_ignore_errors\":{\"value\":true}}"}]", entrance="main.yml", version="2.3.69", module_id="devcloud2018.k8s-cce-manifest-deployment.k8sdeploy-manifest" ) ] listArrangeInfosbody = [ TaskV2RequestBody( template_id="43b36b4678f743568e1ffebfd7f4ce76", operation_list=listOperationListArrangeInfos ) ] triggerbody = TaskTriggerVO( trigger_source="0", artifact_source_system="", artifact_type="" ) request.body = CreateAppRequestBody( arrange_infos=listArrangeInfosbody, trigger=triggerbody, slave_cluster_id="", create_type="template", is_draft=True, description="Create an application using a template.", name="testApp", project_id="55837d272adf4eee90319800e2da6961" ) response = client.create_app(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) |
Go
This API is used to create an application.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" codeartsdeploy "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/codeartsdeploy/v2" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/codeartsdeploy/v2/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/codeartsdeploy/v2/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). Build() client := codeartsdeploy.NewCodeArtsDeployClient( codeartsdeploy.CodeArtsDeployClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.CreateAppRequest{} nameOperationList:= "Application deployment in Kubernetes (CCE cluster) using Manifest" descriptionOperationList:= "Deploy an application in a Huawei Cloud CCE cluster with manifest file defining Kubernetes objects. [View operation guide](https://support.huaweicloud.com/en-us/usermanual-deployman/deployman_hlp_1096.html)" codeOperationList:= "https://example.com" paramsOperationList:= "[{"name":"datasource","label":"Manifest file source","displaySettings":{"DevCloud.ControlType":"Radio","DevCloud.ControlType.Style":"ButtonGroup","DevCloud.ControlType.Radio":[{"displayName":"CodeArts Artifact","value":"1"},{"displayName":"CodeArts Repo","value":"2"},{"displayName":"obs","value":"4"}],"DevCloud.ControlType.Default":{"displayName":"CodeArts Artifact","value":"1","icon":"img/release.png"}},"defaultDisplay":[{"displayName":"CodeArts Artifact","value":"1"}],"validation":{"pattern":null,"patternDescription":null,"maxLength":null,"dataType":null,"isRequired":true,"isNotParameter":true}},{"name":"deployTenant","label":"Deployment tenant","displaySettings":{"DevCloud.ControlType":"Select","DevCloud.ControlType.Style":null,"DevCloud.ControlType.Select":[{"displayName":"Current Tenant","value":"local"},{"displayName":"Other Tenant","value":"other"}],"DevCloud.ControlType.Default":{"displayName":"Current Tenant","value":"local"}},"defaultDisplay":[{"displayName":"Current Tenant","value":"local"}],"validation":{"pattern":null,"patternDescription":null,"maxLength":null,"dataType":null,"isRequired":true,"isNotParameter":true}},{"name":"use_iam_checkbox","displaySettings":{"DevCloud.ControlType":"Checkbox","DevCloud.ControlType.Style":null,"DevCloud.ControlType.Checkbox":[{"displayName":"IAM Authorization","value":"0"}]},"defaultDisplay":[{"displayName":"IAM Authorization","value":"0"}],"visibleRule":"deployTenant=local","validation":{"pattern":null,"patternDescription":null,"maxLength":null,"dataType":null,"isRequired":false,"isNotParameter":true}},{"name":"javaProbeCheckBox","displaySettings":{"DevCloud.ControlType":"Checkbox","DevCloud.ControlType.Style":null,"DevCloud.ControlType.Checkbox":[{"displayName":"Configure JAVA Probes","value":"0"}]},"defaultDisplay":[{"displayName":"Configure JAVA Probes","value":"0"}],"visibleRule":"not 1=1","validation":{"pattern":null,"patternDescription":null,"maxLength":null,"dataType":null,"isRequired":false,"isNotParameter":false}},{"name":"controller_enabled_ignore_errors","displaySettings":{"DevCloud.ControlType":"Checkbox","DevCloud.ControlType.Style":null,"DevCloud.ControlType.Checkbox":[{"displayName":" Continue Upon Failure","value":"0"}]},"defaultDisplay":[{"displayName":" Continue Upon Failure","value":"0"}],"validation":{"pattern":null,"patternDescription":null,"maxLength":null,"dataType":null,"isRequired":true,"isNotParameter":false}},{"name":"controller_enabled_overtime","label":"Timeout","displaySettings":{"DevCloud.ControlType":"SingleLineText","DevCloud.ControlType.Style":null},"defaultValue":"10","validation":{"pattern":"^([1-9]|[1-2][0-9]|30)$","patternDescription":" The time unit is minute. Enter an integer from 1 to 30.","maxLength":null,"dataType":null,"isRequired":true,"isNotParameter":false}},{"name":"controller_enabled","displaySettings":{"DevCloud.ControlType":"Hidden","DevCloud.ControlType.Style":null},"defaultDisplay":[{"displayName":"Enable","value":"1"}]},{"name":"visibleRule","displaySettings":{"DevCloud.ControlType":"Hidden","DevCloud.ControlType.Style":null},"defaultValue":"{\"use_iam_checkbox\":{\"value\":true,\"condition\":\"deployTenant=local\"},\"controller_enabled_overtime\":{\"value\":true},\"javaProbeCheckBox\":{\"value\":true,\"condition\":\"not 1=1\"},\"datasource\":{\"value\":true},\"deployTenant\":{\"value\":true},\"controller_enabled_ignore_errors\":{\"value\":true}}"}]" entranceOperationList:= "main.yml" versionOperationList:= "2.3.69" moduleIdOperationList:= "devcloud2018.k8s-cce-manifest-deployment.k8sdeploy-manifest" var listOperationListArrangeInfos = []model.DeployV2OperationsDo{ { Name: &nameOperationList, Description: &descriptionOperationList, Code: &codeOperationList, Params: ¶msOperationList, Entrance: &entranceOperationList, Version: &versionOperationList, ModuleId: &moduleIdOperationList, }, } templateIdArrangeInfos:= "43b36b4678f743568e1ffebfd7f4ce76" var listArrangeInfosbody = []model.TaskV2RequestBody{ { TemplateId: &templateIdArrangeInfos, OperationList: &listOperationListArrangeInfos, }, } triggerSourceTrigger:= "0" artifactSourceSystemTrigger:= "" artifactTypeTrigger:= "" triggerbody := &model.TaskTriggerVo{ TriggerSource: &triggerSourceTrigger, ArtifactSourceSystem: &artifactSourceSystemTrigger, ArtifactType: &artifactTypeTrigger, } slaveClusterIdCreateAppRequestBody:= "" descriptionCreateAppRequestBody:= "Create an application using a template." request.Body = &model.CreateAppRequestBody{ ArrangeInfos: &listArrangeInfosbody, Trigger: triggerbody, SlaveClusterId: &slaveClusterIdCreateAppRequestBody, CreateType: model.GetCreateAppRequestBodyCreateTypeEnum().TEMPLATE, IsDraft: true, Description: &descriptionCreateAppRequestBody, Name: "testApp", ProjectId: "55837d272adf4eee90319800e2da6961", } response, err := client.CreateApp(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
More
For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.
Status Codes
Status Code |
Description |
---|---|
200 |
OK: The request is successful. |
Error Codes
See Error Codes.
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