Updated on 2024-11-27 GMT+08:00

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

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID obtained from IAM. Generally, a project ID contains 32 characters.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token obtained from IAM.

Content-Type

Yes

String

Content type, which is application/json.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

search

No

String

Search content. You can enter a workflow name or description to search.

type

No

String

Workflow type. Options: cron, event, and manual.

tags

No

Map<String,String>

Workflow tags. Maximum: 10.

page

No

Integer

Number of the current page to be queried. Default: 0.

size

No

Integer

Number of records that can be queried on the current page. Default: 10.

enterprise_project_id

No

String

Enterprise project ID.

create_by

No

String

Workflow creator.

sort_field

Yes

String

Sorting field. Options: create_time, last_execution_start_time, or update_time.

sort_type

Yes

String

Sorting order. Options: ASC and DESC.

search_time_start

No

Long

Start time specified for search.

search_time_end

No

Long

End time specified for search.

status

No

String

Task status. Options: success, fail, executing, cancel, waitExecute, waitApproval, approvalFailed, pausing, and canceling.

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

elements

Array of Workflow objects

Workflow details set.

total_elements

Long

Total number.

Table 5 Workflow

Parameter

Type

Description

id

String

Workflow ID, which is unique and generated based on project_id and workflow_name.

name

String

Workflow name.

type

String

Workflow type. Options: cron and manual.

description

String

Workflow description.

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.

create_by

String

User who created the workflow. This parameter is obtained from the token transferred during API calling.

update_time

Long

Time (UTC, in milliseconds) when a workflow was updated.

update_by

String

User who updated the workflow. This parameter is obtained from the token transferred during API calling.

template_name

String

Template name.

template_id

String

Template ID.

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.

status

String

Task status. Options: success, fail, and executing.

citation_urns

Array of strings

Reference of a workflow.

last_execution_end_time

Long

End time (UTC, in milliseconds) of the last execution.

last_execution_start_time

Long

Start time (UTC, in milliseconds) of the last execution.

quote

Array of strings

Parameters that are referenced.

job_name

String

Job name.

job_id

String

Job ID.

service_scenario

String

Service scenario.

service_name

String

Service name.

task_type

String

Task type.

project_id

String

Project ID returned by FunctionGraph.

workflow_id

String

Workflow ID returned by FunctionGraph.

task_status

String

Task status.

nodes

Array of Node objects

Task node.

edit_time

Long

Edit time.

execution_action_rules

Array of strings

Fine-grained permissions for executing actions.

execution_permission

Array of strings

Cloud service permissions.

global_parameters

Array of Parameter objects

Global parameters.

is_delete

Boolean

Whether the object has been logically deleted.

steps

Array of Step objects

Step.

output

String

Task output.

trigger_id

String

Trigger ID.

trigger_status

String

Trigger status.

approve_id

String

Approval ID.

template_i18n

WorkFlowModel object

Task internationalization field, including English description.

enterprise_project_id

String

Enterprise project to which the task belongs.

last_execute_by

String

Last task executor.

Table 6 Node

Parameter

Type

Description

parent_node

String

Name of the parent node.

category

String

Node type.

description

String

Node description.

id

String

Node ID.

ignore_error

Boolean

Whether to ignore the error.

metadata

Metadata object

Metadata.

name

String

Node name, for example, Node.

task_name

String

Task name.

Table 7 Metadata

Parameter

Type

Description

type

String

Node type.

configuration

Map<String,Object>

Configuration information.

Table 8 Parameter

Parameter

Type

Description

param_name

String

Parameter name.

param_type

String

Parameter type.

param_group

String

Parameter group.

default_value

String

Initial value of a parameter.

id

String

Parameter ID.

encryption

Boolean

Whether to encrypt the data.

hint

String

Parameter prompt.

quote_param

Boolean

Whether to select a parameter from the parameter library.

required

Boolean

Whether a parameter is mandatory.

description

String

Parameter description.

Table 9 Step

Parameter

Type

Description

id

String

Step ID.

name

String

Step name.

type

String

Step type.

input

Map<String,String>

Step parameter.

ignore_error

Boolean

Whether to automatically ignore errors.

description

String

Step description.

Table 10 WorkFlowModel

Parameter

Type

Description

en-us

Map<String,String>

Description

zh-cn

Map<String,String>

Description

Status code: 400

Table 11 Response body parameters

Parameter

Type

Description

error_code

String

Response code.

error_msg

String

Error message.

http_code

Integer

HTTP response code.

Status code: 401

Table 12 Response body parameters

Parameter

Type

Description

error_code

String

Response code.

error_msg

String

Error message.

http_code

Integer

HTTP response code.

Status code: 500

Table 13 Response body parameters

Parameter

Type

Description

error_code

String

Response code.

error_msg

String

Error message.

http_code

Integer

HTTP response code.

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
61
62
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");
        String projectId = "{project_id}";

        ICredential auth = new BasicCredentials()
                .withProjectId(projectId)
                .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
44
# 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"]
    projectId = "{project_id}"

    credentials = BasicCredentials(ak, sk, projectId)

    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
58
59
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")
    projectId := "{project_id}"

    auth := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        WithProjectId(projectId).
        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.