更新时间:2024-02-01 GMT+08:00
分享

作业管理主页模糊查询

功能介绍

该接口可查询已创建的作业,可指定作业名称和作业创建人去精确查询,返回作业列表信息。

调用方法

请参见如何调用API

URI

POST /v1/{project_id}/cms/job/list

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

租户从IAM申请到的projectid,一般为32位字符串。

最小长度:32

最大长度:32

请求参数

表2 请求Header参数

参数

是否必选

参数类型

描述

X-Auth-Token

String

从IAM服务获取的用户Token。

最小长度:1

最大长度:40960

Content-Type

String

指定类型为application/json。

最小长度:1

最大长度:32

表3 请求Body参数

参数

是否必选

参数类型

描述

name

String

name为作业名称。

最小长度:1

最大长度:64

page_num

Integer

当前页,查询的当前页,page_num为正整数,不能是0和负数,当输入参数为负数,0和大于1000,自动修正参数为1,默认值是1(用户不传,值是1)。

最小值:1

最大值:1000

page_size

Integer

每页显示的条数,每页查询的总条数,page_size为正整数,不能是0和负数,当输入参数为负数,0和大于101,自动修正参数为10,默认值是10(用户不传时,值是10)。

最小值:1

最大值:100

order_by_column

String

需要排序的字段(默认为更新时间),支持字段有name,create_time,update_time。

最小长度:1

最大长度:32

sort_order

String

排序规则(默认降序) 传入升序或降序,升序:ASC,降序:DESC。

最小长度:1

最大长度:32

enterprise_project_id

String

企业项目id

最小长度:0

最大长度:64

响应参数

状态码: 200

表4 响应Body参数

参数

参数类型

描述

total_elements

Long

总数。

最小值:0

最大值:9999999

elements

Array of Job objects

查询作业信息集合。

数组长度:0 - 9999999

表5 Job

参数

参数类型

描述

id

String

作业id。

最小长度:1

最大长度:64

name

String

作业名称。

最小长度:1

最大长度:64

create_time

Long

实体的创建时间戳。

最小值:0

最大值:9999999999999

create_by

String

创建人。

最小长度:1

最大长度:64

update_time

Long

实体的最后更新时间戳。 注意:执行创建/修改/删除操作时,update_time将更新。

最小值:0

最大值:9999999999999

update_by

String

修改人。

最小长度:1

最大长度:64

description

String

作业描述,最大长度为1000。

最小长度:1

最大长度:1000

enterprise_project_id

String

企业项目id。

最小长度:1

最大长度:64

project_id

String

租户从IAM申请到的projectid,一般为32位字符串。

最小长度:32

最大长度:32

steps

Array of Step objects

作业步骤。

数组长度:1 - 10

parameters

Array of Parameter objects

全局参数。

数组长度:0 - 20

rate_control

RateControl object

执行策略。

approve_info

ApproveInfo object

审批详情。

is_latest_version

Boolean

是否为最新版本的作业

version_number

Integer

版本号

最小值:1

最大值:100

表6 Step

参数

参数类型

描述

id

String

步骤id。

最小长度:1

最大长度:64

name

String

步骤名称。

最小长度:1

最大长度:32

type

String

步骤类型。

最小长度:1

最大长度:16

input

Map<String,String>

步骤参数。

ignore_error

Boolean

是否自动忽略错误。

description

String

步骤说明。

最小长度:1

最大长度:1000

表7 Parameter

参数

参数类型

描述

param_name

String

参数名称。

param_type

String

参数类型。

最小长度:1

最大长度:16

param_group

String

参数分组。

最小长度:1

最大长度:32

default_value

String

参数初始值。

最小长度:1

最大长度:40960

id

String

参数id。

最小长度:1

最大长度:64

encryption

Boolean

是否加密。

hint

String

参数提示。

最小长度:1

最大长度:1000

quote_param

Boolean

是否从参数库选择。

required

Boolean

是否为必填参数。

description

String

参数描述。

最小长度:1

最大长度:1000

表8 RateControl

参数

参数类型

描述

have_rate_control

Boolean

是否分批发布,默认值是false。

time_delay

Integer

每批间隔。

最小值:1

最大值:60

max

Integer

每批支持的最大实例数。

最小值:0

最大值:100

表9 ApproveInfo

参数

参数类型

描述

topic_selected

String

审批人主题选择。

最小长度:1

最大长度:2048

need_approve

Boolean

是否审核,默认是不审核,true,false。

smn_urn_list

String

审批主题urn集合。

最小长度:1

最大长度:2048

状态码: 400

表10 响应Body参数

参数

参数类型

描述

error_code

String

响应码。

最小长度:1

最大长度:32

error_msg

String

调用失败响应信息描述。

最小长度:1

最大长度:1024

http_code

Integer

Http返回码

最小值:1

最大值:999

状态码: 401

表11 响应Body参数

参数

参数类型

描述

error_code

String

响应码。

最小长度:1

最大长度:32

error_msg

String

调用失败响应信息描述。

最小长度:1

最大长度:1024

http_code

Integer

Http返回码

最小值:1

最大值:999

请求示例

查询name为"xxx"、排序规则"order_by_column"为"create_time"的作业列表。

POST https://{Endpoint}/v1/{project_id}/cms/job/list

{
  "name" : "xxx",
  "enterprise_project_id" : "",
  "page_num" : 1,
  "page_size" : 10,
  "order_by_column" : "create_time",
  "sort_order" : "DESC"
}

响应示例

状态码: 200

响应成功,返回作业列表。

{
  "elements" : [ {
    "approve_info" : {
      "need_approve" : false
    },
    "create_by" : "xxxxxx",
    "create_time" : 1600015045074,
    "description" : "",
    "enterprise_project_id" : "0",
    "id" : "xxxxxx",
    "is_latest_version" : true,
    "name" : "xxxxxx",
    "parameters" : [ {
      "default_value" : "xxxxx",
      "description" : "",
      "encryption" : false,
      "hint" : "",
      "id" : "xxxxxxx",
      "param_group" : "",
      "param_name" : "xxxxx",
      "param_type" : "STRING",
      "quote_param" : false,
      "required" : true
    }, {
      "default_value" : "xxxx",
      "description" : "",
      "encryption" : false,
      "hint" : "",
      "id" : "xxxxxxxx",
      "param_group" : "",
      "param_name" : "xxxxx",
      "param_type" : "STRING",
      "quote_param" : false,
      "required" : true
    }, {
      "default_value" : "{xxxxxxx}",
      "description" : "",
      "encryption" : false,
      "hint" : "",
      "id" : "xxxxxxxxxx",
      "param_group" : "ecs_instance",
      "param_name" : "xxxxx",
      "param_type" : "HOST",
      "quote_param" : false,
      "required" : true
    } ],
    "project_id" : "xxxxxxxxx",
    "rate_control" : {
      "have_rate_control" : false,
      "max" : 0,
      "time_delay" : 0
    },
    "steps" : [ {
      "description" : "",
      "id" : "xxxxxxxxxxx",
      "ignore_error" : false,
      "input" : {
        "script_param" : "{xxxxxxx}",
        "get_instances" : "{xxxxxxx}"
      },
      "name" : "xxx",
      "type" : "script"
    }, {
      "description" : "",
      "id" : "xxxxxxxxxxxx",
      "ignore_error" : false,
      "input" : {
        "package" : "{xxxx}",
        "get_instances" : "{xxxx}"
      },
      "name" : "file1",
      "type" : "package"
    } ],
    "update_by" : "xxxx",
    "update_time" : 1600015045074,
    "version_number" : 1
  } ],
  "total_elements" : 1
}

状态码: 400

BadRequest。非法请求。建议直接修改该请求,不要重试该请求。

{
  "error_code" : "AOM.31003202",
  "error_msg" : "job parameter invalid.",
  "http_code" : 400
}

状态码: 401

Unauthorized。在客户端提供认证信息后,返回该状态码,表明服务端指出客户端所提供的认证信息不正确或非法。

{
  "error_code" : "AOM.31009019",
  "error_message" : "auth failed.",
  "http_code" : "401"
}

SDK代码示例

SDK代码示例如下。

查询name为"xxx"、排序规则"order_by_column"为"create_time"的作业列表。

 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
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.*;


public class ListAllJobByNameSolution {

    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();
        ListAllJobByNameRequest request = new ListAllJobByNameRequest();
        SearchJobsRequestBody body = new SearchJobsRequestBody();
        body.withEnterpriseProjectId("");
        body.withSortOrder("DESC");
        body.withOrderByColumn("create_time");
        body.withPageSize(10);
        body.withPageNum(1);
        body.withName("xxx");
        request.withBody(body);
        try {
            ListAllJobByNameResponse response = client.listAllJobByName(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());
        }
    }
}

查询name为"xxx"、排序规则"order_by_column"为"create_time"的作业列表。

 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
# coding: utf-8

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.getenv("CLOUD_SDK_AK")
    sk = os.getenv("CLOUD_SDK_SK")

    credentials = BasicCredentials(ak, sk) \

    client = AomClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(AomRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = ListAllJobByNameRequest()
        request.body = SearchJobsRequestBody(
            enterprise_project_id="",
            sort_order="DESC",
            order_by_column="create_time",
            page_size=10,
            page_num=1,
            name="xxx"
        )
        response = client.list_all_job_by_name(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)

查询name为"xxx"、排序规则"order_by_column"为"create_time"的作业列表。

 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
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.ListAllJobByNameRequest{}
	enterpriseProjectIdSearchJobsRequestBody:= ""
	pageSizeSearchJobsRequestBody:= int32(10)
	pageNumSearchJobsRequestBody:= int32(1)
	nameSearchJobsRequestBody:= "xxx"
	request.Body = &model.SearchJobsRequestBody{
		EnterpriseProjectId: &enterpriseProjectIdSearchJobsRequestBody,
		SortOrder: "DESC",
		OrderByColumn: "create_time",
		PageSize: &pageSizeSearchJobsRequestBody,
		PageNum: &pageNumSearchJobsRequestBody,
		Name: &nameSearchJobsRequestBody,
	}
	response, err := client.ListAllJobByName(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。

状态码

状态码

描述

200

响应成功,返回作业列表。

400

BadRequest。非法请求。建议直接修改该请求,不要重试该请求。

401

Unauthorized。在客户端提供认证信息后,返回该状态码,表明服务端指出客户端所提供的认证信息不正确或非法。

错误码

请参见错误码

分享:

    相关文档

    相关产品