Deploying an Application
Function
This API is used to deploy an application by deployment task ID.
Calling Method
For details, see Calling APIs.
URI
POST /v2/tasks/{task_id}/start
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
task_id |
Yes |
String |
Definition: Deployment task ID. Constraints: N/A. Value range: 32 characters, including letters and digits. Default value: N/A. |
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 |
---|---|---|---|
params |
No |
Array of DynamicConfigInfo objects |
Definition: Parameters transferred during application deployment. Constraints: N/A. |
record_id |
No |
String |
Definition: Application deployment ID. Constraints: N/A. Value range: 32 characters, including letters and digits. Default value: N/A. |
trigger_source |
No |
String |
Definition: Whether to restrict the triggering source. Constraints: N/A. Value range:
Default value: N/A. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
key |
No |
String |
Definition: Parameter name transferred during application deployment. Constraints: N/A. Value range: 1 to 128 characters, including letters, digits, hyphens (-), underscores (_), and periods (.). Default value: N/A. |
value |
No |
String |
Definition: Parameter value transferred during application deployment. Constraints: N/A. Value range: Max. 8,192 characters. The following special characters are not supported: {{, {%, and {# Default value: N/A. |
type |
No |
String |
Definition: Deployment parameter type. Constraints: If you set this parameter to runtime, this parameter is mandatory. Value range:
Default value: N/A. |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
id |
String |
Definition: Deployment record ID. Value range: 32 characters, including letters and digits. |
task_id |
String |
Definition: Deployment task ID. Value range: 32 characters, including letters and digits. |
job_name |
String |
Definition: Execution task name. Value range: 50 characters, including letters, digits, and underscores (_). |
app_component_list |
Array of AppComponentDao objects |
Definition: Mapping between applications and AOM application components. |
Parameter |
Type |
Description |
---|---|---|
task_id |
String |
Parameter description: Deployment application ID. Value range: The value consists of 32 characters. Letters and digits are allowed. |
app_id |
String |
Parameter description: AOM application ID. Value range: The value consists of 32 characters. Letters and digits are allowed. |
app_name |
String |
Parameter description: AOM application name. Value range: The value consists of letters and digits. |
comp_id |
String |
Parameter description: AOM application component ID. Value range: The value consists of 32 characters. Letters and digits are allowed. |
comp_name |
String |
Parameter description: AOM application component name. Value range: The value consists of 0 to 128 characters. |
domain_id |
String |
Parameter description: Tenant ID. Value range: The value consists of 32 characters. Letters and digits are allowed. |
region |
String |
Parameter description: Region information. Value range: The value consists of 1 to 256 characters. |
state |
String |
Parameter description: Whether the AOM application component takes effect. Value range:
|
Example Requests
This API is used to deploy an application by deployment task ID.
https://{endpoint}/v2/tasks/d2dc947ec2424d8789bb3984bb3adf45/start { "params" : [ { "key" : "string", "value" : "test", "type" : "text" }, { "key" : "env", "value" : "e3144513a4094398857c992606ccba12", "type" : "host_group" }, { "key" : "enum", "value" : "value1", "type" : "enum" } ], "trigger_source" : 0 }
Example Responses
Status code: 200
OK: The request is successful.
{ "id" : "0ee9c8e6a7dc44109541e53c6dccf47c", "task_id" : "d2dc947ec2424d8789bb3984bb3adf45", "job_name" : "job_0ee9c8e6a7dc44109541e53c6dccf47c_1620810492008", "app_component_list" : [ ] }
SDK Sample Code
The SDK sample code is as follows.
Java
This API is used to deploy an application by deployment task ID.
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 |
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 StartDeployTaskSolution { 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(); StartDeployTaskRequest request = new StartDeployTaskRequest(); request.withTaskId("{task_id}"); EnvExecutionBody body = new EnvExecutionBody(); List<DynamicConfigInfo> listbodyParams = new ArrayList<>(); listbodyParams.add( new DynamicConfigInfo() .withType(DynamicConfigInfo.TypeEnum.fromValue("text")) .withValue("test") .withKey("string") ); listbodyParams.add( new DynamicConfigInfo() .withType(DynamicConfigInfo.TypeEnum.fromValue("host_group")) .withValue("e3144513a4094398857c992606ccba12") .withKey("env") ); listbodyParams.add( new DynamicConfigInfo() .withType(DynamicConfigInfo.TypeEnum.fromValue("enum")) .withValue("value1") .withKey("enum") ); body.withTriggerSource("0"); body.withParams(listbodyParams); request.withBody(body); try { StartDeployTaskResponse response = client.startDeployTask(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 deploy an application by deployment task ID.
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 |
# 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 = StartDeployTaskRequest() request.task_id = "{task_id}" listParamsbody = [ DynamicConfigInfo( type="text", value="test", key="string" ), DynamicConfigInfo( type="host_group", value="e3144513a4094398857c992606ccba12", key="env" ), DynamicConfigInfo( type="enum", value="value1", key="enum" ) ] request.body = EnvExecutionBody( trigger_source="0", params=listParamsbody ) response = client.start_deploy_task(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 deploy an application by deployment task ID.
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 |
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.StartDeployTaskRequest{} request.TaskId = "{task_id}" typeParams:= model.GetDynamicConfigInfoTypeEnum().TEXT valueParams:= "test" keyParams:= "string" typeParams1:= model.GetDynamicConfigInfoTypeEnum().HOST_GROUP valueParams1:= "e3144513a4094398857c992606ccba12" keyParams1:= "env" typeParams2:= model.GetDynamicConfigInfoTypeEnum().ENUM valueParams2:= "value1" keyParams2:= "enum" var listParamsbody = []model.DynamicConfigInfo{ { Type: &typeParams, Value: &valueParams, Key: &keyParams, }, { Type: &typeParams1, Value: &valueParams1, Key: &keyParams1, }, { Type: &typeParams2, Value: &valueParams2, Key: &keyParams2, }, } triggerSourceEnvExecutionBody:= "0" request.Body = &model.EnvExecutionBody{ TriggerSource: &triggerSourceEnvExecutionBody, Params: &listParamsbody, } response, err := client.StartDeployTask(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