Querying Tasks
Function
This API is used to query the created tasks. You can query tasks by task name, task status, task type, executor, and update time.
Calling Method
For details, see Calling APIs.
URI
POST /v1/{project_id}/cms/workflow-list
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Project ID obtained from IAM. Generally, a project ID contains 32 characters. Minimum: 32 Maximum: 32 |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
User token obtained from IAM. Minimum: 1 Maximum: 40960 |
Content-Type |
Yes |
String |
Content type, which is application/json. Minimum: 1 Maximum: 32 |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
search |
No |
String |
Search content. You can enter a workflow name or description to search. Minimum: 1 Maximum: 64 |
type |
No |
String |
Workflow type. Options: cron, event, and manual. Minimum: 1 Maximum: 16 |
tags |
No |
Map<String,String> |
Workflow tags. Maximum: 10. |
page |
No |
Integer |
Number of the current page to be queried. Default: 0. Minimum: 1 Maximum: 9999999 |
size |
No |
Integer |
Number of records that can be queried on the current page. Default: 10. Minimum: 1 Maximum: 100 |
enterprise_project_id |
No |
String |
Enterprise project ID. Minimum: 1 Maximum: 64 |
create_by |
No |
String |
Workflow creator. Minimum: 1 Maximum: 64 |
sort_field |
Yes |
String |
Sorting field. Options: create_time, last_execution_start_time, or update_time. Minimum: 1 Maximum: 64 |
sort_type |
Yes |
String |
Sorting order. Options: ASC and DESC. Minimum: 1 Maximum: 16 |
search_time_start |
No |
Long |
Start time specified for search. Minimum: 0 Maximum: 9999999999999 |
search_time_end |
No |
Long |
End time specified for search. Minimum: 0 Maximum: 9999999999999 |
status |
No |
String |
Task status. Options: success, fail, executing, cancel, waitExecute, waitApproval, approvalFailed, pausing, and canceling. Minimum: 1 Maximum: 16 |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
elements |
Array of Workflow objects |
Workflow details set. Array Length: 0 - 9999999 |
total_elements |
Long |
Total number. Minimum: 0 Maximum: 99999999 |
Parameter |
Type |
Description |
---|---|---|
id |
String |
Workflow ID, which is unique and generated based on project_id and workflow_name. Minimum: 1 Maximum: 64 |
name |
String |
Workflow name. Minimum: 1 Maximum: 64 |
type |
String |
Workflow type. Options: cron and manual. Minimum: 1 Maximum: 16 |
description |
String |
Workflow description. Minimum: 1 Maximum: 128 |
tags |
Map<String,String> |
List of tag keys and values. Maximum key-value pairs: 20. |
create_time |
Long |
Time (UTC, in milliseconds) when a workflow was created. Minimum: 0 Maximum: 9999999999999 |
create_by |
String |
User who created the workflow. This parameter is obtained from the token transferred during API calling. Minimum: 1 Maximum: 64 |
update_time |
Long |
Time (UTC, in milliseconds) when a workflow was updated. Minimum: 0 Maximum: 9999999999999 |
update_by |
String |
User who updated the workflow. This parameter is obtained from the token transferred during API calling. Minimum: 1 Maximum: 64 |
template_name |
String |
Template name. Minimum: 1 Maximum: 64 |
template_id |
String |
Template ID. Minimum: 1 Maximum: 64 |
input |
Map<String,Object> |
List of parameters required for executing a task. |
last_execution_id |
String |
Latest execution ID, which is also the workflow ID. Minimum: 1 Maximum: 64 |
status |
String |
Task status. Options: success, fail, and executing. Minimum: 1 Maximum: 16 |
citation_urns |
Array of strings |
Reference of a workflow. Minimum: 1 Maximum: 256 Array Length: 0 - 200 |
last_execution_end_time |
Long |
End time (UTC, in milliseconds) of the last execution. Minimum: 0 Maximum: 9999999999999 |
last_execution_start_time |
Long |
Start time (UTC, in milliseconds) of the last execution. Minimum: 0 Maximum: 9999999999999 |
quote |
Array of strings |
Parameters that are referenced. Minimum: 1 Maximum: 256 Array Length: 1 - 999 |
job_name |
String |
Job name. Minimum: 1 Maximum: 64 |
job_id |
String |
Job ID. Minimum: 1 Maximum: 64 |
service_scenario |
String |
Service scenario. Minimum: 1 Maximum: 64 |
service_name |
String |
Service name. Minimum: 1 Maximum: 64 |
task_type |
String |
Task type. Minimum: 1 Maximum: 16 |
project_id |
String |
Project ID returned by FunctionGraph. Minimum: 1 Maximum: 32 |
workflow_id |
String |
Workflow ID returned by FunctionGraph. Minimum: 1 Maximum: 64 |
task_status |
String |
Task status. Minimum: 1 Maximum: 32 |
nodes |
Array of Node objects |
Task node. Array Length: 1 - 20 |
edit_time |
Long |
Edit time. Minimum: 0 Maximum: 9999999999999 |
execution_action_rules |
Array of strings |
Fine-grained permissions for executing actions. Minimum: 1 Maximum: 128 Array Length: 0 - 200 |
execution_permission |
Array of strings |
Cloud service permissions. Minimum: 1 Maximum: 128 Array Length: 1 - 32 |
global_parameters |
Array of Parameter objects |
Global parameters. Array Length: 0 - 20 |
is_delete |
Boolean |
Whether the object has been logically deleted. |
steps |
Array of Step objects |
Step. Array Length: 1 - 10 |
output |
String |
Task output. Minimum: 1 Maximum: 40960 |
trigger_id |
String |
Trigger ID. Minimum: 1 Maximum: 64 |
trigger_status |
String |
Trigger status. Minimum: 1 Maximum: 64 |
approve_id |
String |
Approval ID. Minimum: 1 Maximum: 64 |
template_i18n |
WorkFlowModel object |
Task internationalization field, including English description. |
enterprise_project_id |
String |
Enterprise project to which the task belongs. Minimum: 1 Maximum: 64 |
last_execute_by |
String |
Last task executor. Minimum: 1 Maximum: 64 |
Parameter |
Type |
Description |
---|---|---|
parent_node |
String |
Name of the parent node. Minimum: 1 Maximum: 64 |
category |
String |
Node type. Minimum: 1 Maximum: 32 |
description |
String |
Node description. Minimum: 1 Maximum: 1024 |
id |
String |
Node ID. Minimum: 1 Maximum: 64 |
ignore_error |
Boolean |
Whether to ignore the error. |
metadata |
Metadata object |
Metadata. |
name |
String |
Node name, for example, Node. Minimum: 1 Maximum: 64 |
task_name |
String |
Task name. Minimum: 1 Maximum: 64 |
Parameter |
Type |
Description |
---|---|---|
type |
String |
Node type. Minimum: 1 Maximum: 32 |
configuration |
Map<String,Object> |
Configuration information. |
Parameter |
Type |
Description |
---|---|---|
param_name |
String |
Parameter name. |
param_type |
String |
Parameter type. Minimum: 1 Maximum: 16 |
param_group |
String |
Parameter group. Minimum: 1 Maximum: 32 |
default_value |
String |
Initial value of a parameter. Minimum: 1 Maximum: 40960 |
id |
String |
Parameter ID. Minimum: 1 Maximum: 64 |
encryption |
Boolean |
Whether to encrypt the data. |
hint |
String |
Parameter prompt. Minimum: 1 Maximum: 1000 |
quote_param |
Boolean |
Whether to select a parameter from the parameter library. |
required |
Boolean |
Whether a parameter is mandatory. |
description |
String |
Parameter description. Minimum: 1 Maximum: 1000 |
Parameter |
Type |
Description |
---|---|---|
id |
String |
Step ID. Minimum: 1 Maximum: 64 |
name |
String |
Step name. Minimum: 1 Maximum: 32 |
type |
String |
Step type. Minimum: 1 Maximum: 16 |
input |
Map<String,String> |
Step parameter. |
ignore_error |
Boolean |
Whether to automatically ignore errors. |
description |
String |
Step description. Minimum: 1 Maximum: 1000 |
Parameter |
Type |
Description |
---|---|---|
en-us |
Map<String,String> |
Description |
zh-cn |
Map<String,String> |
Description |
Status code: 400
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Response code. Minimum: 1 Maximum: 64 |
error_msg |
String |
Error message. Minimum: 1 Maximum: 1024 |
http_code |
Integer |
HTTP response code. Minimum: 0 Maximum: 999 |
Status code: 401
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Response code. Minimum: 1 Maximum: 64 |
error_msg |
String |
Error message. Minimum: 1 Maximum: 1024 |
http_code |
Integer |
HTTP response code. Minimum: 0 Maximum: 999 |
Status code: 500
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Response code. Minimum: 1 Maximum: 64 |
error_msg |
String |
Error message. Minimum: 1 Maximum: 1024 |
http_code |
Integer |
HTTP response code. Minimum: 0 Maximum: 999 |
Example Requests
Query the task list by setting Name to xxx, last_execute_by to xxx, status to xxx, task_type to xxx, and search_time_start to 1600060125000.
https://{Endpoint}/v1/{project_id}/cms/workflow-list { "search" : "", "tags" : { }, "page" : 0, "size" : 10, "enterprise_project_id" : "0", "create_by" : "xxx", "sort_field" : "update_time", "sort_type" : "DESC", "status" : "xxx", "type" : "manual", "search_time_start" : 160000000000, "search_time_end" : 160000000000 }
Example Responses
Status code: 200
OK: The task list is returned.
{ "elements" : [ { "citation_urns" : [ ], "create_by" : "xxxx", "create_time" : 16000000000, "description" : "", "edit_time" : 0, "enterprise_project_id" : "0", "execution_action_rules" : [ "xxxxxxx", "xxxxxxx" ], "execution_permission" : [ "xxxxxxx", "xxxxxx" ], "id" : "xxxxxx", "input" : { "package" : { "cmd_user" : "xxxxx", "software_list" : "[xxxxxxx]", "pre_install_script" : "", "operate_type" : "install", "un_install_script" : "", "version_number" : "1", "time_out" : "7200", "install_script" : "xxxx", "package_version_id" : "xxxxxx", "package_basic_id" : "xxxxxx", "package_name" : "xxxxx", "install_file_dir" : "xxxxx", "plat_form" : "Linux", "group" : "package" }, "project_id" : "xxxxxxx", "approve" : { "need_approve" : "false", "group" : "approve" }, "region_id" : "cn-north-7", "get_instances" : { "frontend_info" : "{xxxxxx}", "ecs_id_list" : "[xxxxxxx]", "type" : "cmdb_manual", "group" : "ecs_instance" }, "rate_control" : { "max" : "0", "timeDelay" : "0", "group" : "rate_control" } }, "is_delete" : false, "last_execute_by" : "xxxxxx", "last_execution_end_time" : 1600000000, "last_execution_id" : "xxxxxx", "last_execution_start_time" : 1600000000, "name" : "xxxxxx", "nodes" : [ { "category" : "service", "description" : "download obs plug and install plug", "id" : "xxxxxx", "ignore_error" : true, "metadata" : { "configuration" : { "func_urn" : "xxxxxxx", "dataOutputPath" : "", "func_app" : "CMS", "dataInputPath" : "", "validator" : true, "func_version" : "latest", "dataResultsPath" : "", "parameters" : [ { "default" : "", "showFormat" : false, "format" : "", "value" : "root", "isEditor" : false, "key" : "properties.cmd_user" }, { "default" : "", "showFormat" : false, "format" : "", "value" : "[xxxxxx]", "isEditor" : false, "key" : "properties.software_list" }, { "default" : "", "showFormat" : false, "format" : "", "value" : "", "isEditor" : false, "key" : "properties.pre_install_script" }, { "default" : "", "showFormat" : false, "format" : "", "value" : "install", "isEditor" : false, "key" : "properties.operate_type" }, { "default" : "", "showFormat" : false, "format" : "", "value" : "", "isEditor" : false, "key" : "properties.un_install_script" }, { "default" : "", "showFormat" : false, "format" : "", "value" : "1", "isEditor" : false, "key" : "properties.version_number" }, { "default" : "", "showFormat" : false, "format" : "", "value" : "7200", "isEditor" : false, "key" : "properties.time_out" }, { "default" : "", "showFormat" : false, "format" : "", "value" : "xxxx", "isEditor" : false, "key" : "properties.install_script" }, { "default" : "", "showFormat" : false, "format" : "", "value" : "xxxxxx", "isEditor" : false, "key" : "properties.package_version_id" }, { "default" : "", "showFormat" : false, "format" : "", "value" : "xxxxxx", "isEditor" : false, "key" : "properties.package_basic_id" }, { "default" : "", "showFormat" : false, "format" : "", "value" : "xxxxx", "isEditor" : false, "key" : "properties.package_name" }, { "default" : "", "showFormat" : false, "format" : "", "value" : "xxxx", "isEditor" : false, "key" : "properties.install_file_dir" }, { "default" : "", "showFormat" : false, "format" : "", "value" : "Linux", "isEditor" : false, "key" : "properties.plat_form" }, { "default" : "", "showFormat" : false, "format" : "", "value" : "package", "isEditor" : false, "key" : "properties.group" }, { "default" : "", "showFormat" : false, "format" : "", "value" : "xxxxxx", "isEditor" : false, "key" : "properties.project_id" }, { "default" : "", "showFormat" : false, "format" : "", "value" : "cn-north-4", "isEditor" : false, "key" : "properties.region_id" }, { "default" : "", "showFormat" : false, "format" : "", "value" : "{xxxxxx}", "isEditor" : false, "key" : "properties.frontend_info" }, { "default" : "", "showFormat" : false, "format" : "", "value" : "[xxxxxx]", "isEditor" : false, "key" : "properties.ecs_id_list" }, { "default" : "", "showFormat" : false, "format" : "", "value" : "cmdb_manual", "isEditor" : false, "key" : "properties.type" }, { "default" : "", "showFormat" : false, "format" : "", "value" : "ecs_instance", "isEditor" : false, "key" : "properties.group" }, { "default" : "", "showFormat" : false, "format" : "", "value" : "0", "isEditor" : false, "key" : "properties.max" }, { "default" : "", "showFormat" : false, "format" : "", "value" : "0", "isEditor" : false, "key" : "properties.timeDelay" }, { "default" : "", "showFormat" : false, "format" : "", "value" : "rate_control", "isEditor" : false, "key" : "properties.group" }, { "default" : "", "showFormat" : false, "format" : "", "value" : "$.executionId", "isEditor" : false, "key" : "properties.executionId" }, { "default" : "", "showFormat" : false, "format" : "", "value" : "xxxxxxx", "isEditor" : false, "key" : "properties.workflowId" }, { "default" : "", "showFormat" : false, "format" : "", "value" : "CMS::ECS::Package", "isEditor" : false, "key" : "properties.cmsTaskName2Distribute" }, { "default" : "", "showFormat" : false, "format" : "", "value" : "xxxxxx", "isEditor" : false, "key" : "properties.cmsAccessPodLb" }, { "default" : "", "showFormat" : false, "format" : "", "value" : "manual", "isEditor" : false, "key" : "properties.workflowType" }, { "default" : "", "showFormat" : false, "format" : "", "value" : "package-manipulation", "isEditor" : false, "key" : "properties.nodeId" } ] }, "type" : "operation" }, "name" : "package", "task_name" : "CMS::ECS::Package" } ], "project_id" : "xxxxxx", "quote" : [ ], "status" : "fail", "steps" : [ ], "tags" : { }, "task_type" : "package", "template_i18n" : { "en-us" : { "name" : "Package", "description" : "download install plug or uninstall plug" }, "zh-cn" : { "name" : "File management", "description" : " " } }, "template_id" : "CMS::ECS::Package", "template_name" : "CMS::ECS::Package", "type" : "manual", "update_time" : 1600000000 } ], "total_elements" : 1 }
Status code: 400
Bad Request: Invalid request. The client should not repeat the request without modifications.
{ "error_code" : "AOM.31001302", "error_msg" : "Invalid input parameter.", "http_code" : 400 }
Status code: 401
Unauthorized: The authentication information is incorrect or invalid.
{ "error_code" : "AOM.31009003", "error_msg" : "auth failed.", "http_code" : 401 }
Status code: 500
Internal Server Error: The server is able to receive the request but unable to understand the request.
{ "error_code" : "AOM.31001305", "error_msg" : "workflow internal server error.", "http_code" : 500 }
SDK Sample Code
The SDK sample code is as follows.
Java
Query the task list by setting Name to xxx, last_execute_by to xxx, status to xxx, task_type to xxx, and search_time_start to 1600060125000.
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 |
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.aom.v1.region.AomRegion; import com.huaweicloud.sdk.aom.v1.*; import com.huaweicloud.sdk.aom.v1.model.*; import java.util.Map; import java.util.HashMap; public class ListWorkflowSolution { 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); AomClient client = AomClient.newBuilder() .withCredential(auth) .withRegion(AomRegion.valueOf("<YOUR REGION>")) .build(); ListWorkflowRequest request = new ListWorkflowRequest(); WorkflowQueryParam body = new WorkflowQueryParam(); body.withStatus("xxx"); body.withSearchTimeEnd(160000000000L); body.withSearchTimeStart(160000000000L); body.withSortType("DESC"); body.withSortField("update_time"); body.withCreateBy("xxx"); body.withEnterpriseProjectId("0"); body.withSize(10); body.withPage(0); body.withType("manual"); body.withSearch(""); request.withBody(body); try { ListWorkflowResponse response = client.listWorkflow(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
Query the task list by setting Name to xxx, last_execute_by to xxx, status to xxx, task_type to xxx, and search_time_start to 1600060125000.
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 |
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkaom.v1.region.aom_region import AomRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkaom.v1 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 = AomClient.new_builder() \ .with_credentials(credentials) \ .with_region(AomRegion.value_of("<YOUR REGION>")) \ .build() try: request = ListWorkflowRequest() request.body = WorkflowQueryParam( status="xxx", search_time_end=160000000000, search_time_start=160000000000, sort_type="DESC", sort_field="update_time", create_by="xxx", enterprise_project_id="0", size=10, page=0, type="manual", search="" ) response = client.list_workflow(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
Query the task list by setting Name to xxx, last_execute_by to xxx, status to xxx, task_type to xxx, and search_time_start to 1600060125000.
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 |
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" aom "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/aom/v1" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/aom/v1/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/aom/v1/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 := aom.NewAomClient( aom.AomClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.ListWorkflowRequest{} statusWorkflowQueryParam:= "xxx" searchTimeEndWorkflowQueryParam:= int64(160000000000) searchTimeStartWorkflowQueryParam:= int64(160000000000) createByWorkflowQueryParam:= "xxx" enterpriseProjectIdWorkflowQueryParam:= "0" sizeWorkflowQueryParam:= int32(10) pageWorkflowQueryParam:= int32(0) typeWorkflowQueryParam:= "manual" searchWorkflowQueryParam:= "" request.Body = &model.WorkflowQueryParam{ Status: &statusWorkflowQueryParam, SearchTimeEnd: &searchTimeEndWorkflowQueryParam, SearchTimeStart: &searchTimeStartWorkflowQueryParam, SortType: "DESC", SortField: "update_time", CreateBy: &createByWorkflowQueryParam, EnterpriseProjectId: &enterpriseProjectIdWorkflowQueryParam, Size: &sizeWorkflowQueryParam, Page: &pageWorkflowQueryParam, Type: &typeWorkflowQueryParam, Search: &searchWorkflowQueryParam, } response, err := client.ListWorkflow(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 task list is returned. |
400 |
Bad Request: Invalid request. The client should not repeat the request without modifications. |
401 |
Unauthorized: The authentication information is incorrect or invalid. |
500 |
Internal Server Error: The server is able to receive the request but unable to understand the request. |
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