更新时间:2024-05-14 GMT+08:00
分享

获取方案信息

功能介绍

该接口可根据执行方案id查询执行方案详情。

调用方法

请参见如何调用API

URI

GET /v1/{project_id}/cms/template/{template_id}

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

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

最小长度:32

最大长度:32

template_id

String

方案id。

最小长度:1

最大长度:64

表2 Query参数

参数

是否必选

参数类型

描述

share_type

String

模板共享类型,默认为private。可选public private

最小长度:1

最大长度:10

请求参数

表3 请求Header参数

参数

是否必选

参数类型

描述

X-Auth-Token

String

从IAM服务获取的用户Token。

最小长度:1

最大长度:40960

Content-Type

String

指定类型为application/json。

最小长度:1

最大长度:32

响应参数

状态码: 200

表4 响应Body参数

参数

参数类型

描述

approve_info

ApproveInfo object

审批信息

create_by

String

模板创建人,从接口调用传入的token中获取。

最小长度:1

最大长度:64

create_time

Long

模板创建时间,为utc时间毫秒数。

最小值:0

最大值:9999999999999

enterprise_project_id

String

企业项目id

最小长度:1

最大长度:64

id

String

模板id,唯一标识,根据project_id和template_name生成。

最小长度:1

最大长度:64

is_collect

Boolean

模板是否收藏,不允许更新模板时修改,更改收藏状态调用单独的更新模板收藏状态接口

is_publish

Boolean

是否发布成服务

job_id

String

作业id

最小长度:1

最大长度:64

job_version

Integer

作业版本

最小值:1

最大值:999

name

String

模板名称

最小长度:1

最大长度:64

need_synchronize

Boolean

是否需要同步

nodes

Array of Node objects

任务执行时需要的参数列表。

数组长度:1 - 20

parameters

Array of Parameter objects

任务执行时需要的参数列表。

数组长度:0 - 20

project_id

String

项目id

最小长度:32

最大长度:32

quote

Array of strings

引用参数

最小长度:1

最大长度:256

数组长度:0 - 999

rate_control

RateControl object

执行策略

share_type

String

默认模板为public,自定义模板为private

最小长度:1

最大长度:16

steps

Array of Step objects

作业步骤

数组长度:1 - 20

update_by

String

模板更新人,从接口调用传入的token中获取。

最小长度:1

最大长度:64

update_time

Long

模板更新时间,为utc时间毫秒数。

最小值:0

最大值:9999999999999

version

String

模板版本

最小长度:1

最大长度:32

表5 ApproveInfo

参数

参数类型

描述

topic_selected

String

审批人主题选择。

最小长度:1

最大长度:2048

need_approve

Boolean

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

smn_urn_list

String

审批主题urn集合。

最小长度:1

最大长度:2048

表6 Node

参数

参数类型

描述

parent_node

String

父亲节点的名称。

最小长度:1

最大长度:64

category

String

节点类型。

最小长度:1

最大长度:32

description

String

节点描述。

最小长度:1

最大长度:1024

id

String

节点id

最小长度:1

最大长度:64

ignore_error

Boolean

是否忽略错误

metadata

Metadata object

元数据。

name

String

节点名称,比如是Node。

最小长度:1

最大长度:64

task_name

String

任务名称,节点上任务的名称。

最小长度:1

最大长度:64

表7 Metadata

参数

参数类型

描述

type

String

节点类型。

最小长度:1

最大长度:32

configuration

Map<String,Object>

配置信息。

表8 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

表9 RateControl

参数

参数类型

描述

have_rate_control

Boolean

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

time_delay

Integer

每批间隔。

最小值:1

最大值:60

max

Integer

每批支持的最大实例数。

最小值:0

最大值:100

表10 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

状态码: 400

表11 响应Body参数

参数

参数类型

描述

error_code

String

响应码。

最小长度:1

最大长度:64

error_msg

String

调用失败响应信息描述。

最小长度:1

最大长度:1024

http_code

Integer

http返回码

最小值:0

最大值:999

状态码: 401

表12 响应Body参数

参数

参数类型

描述

error_code

String

响应码。

最小长度:1

最大长度:64

error_msg

String

调用失败响应信息描述。

最小长度:1

最大长度:1024

http_code

Integer

http返回码

最小值:0

最大值:999

请求示例

用template_id和share_type查询执行方案。 share_type:默认为private。

https://{Endpoint}/v1/{project_id}/cms/template/{template_id}?share_type=private

响应示例

状态码: 200

请求响应成功,返回执行方案详情。

{
  "approve_info" : {
    "need_approve" : false
  },
  "create_by" : "xxxxxxxxx",
  "create_time" : 1600026634837,
  "enterprise_project_id" : "0",
  "id" : "xxxxxx",
  "is_collect" : false,
  "is_publish" : false,
  "job_id" : "xxxxxx",
  "job_version" : 1,
  "name" : "1",
  "need_synchronize" : false,
  "nodes" : [ {
    "category" : "pause",
    "description" : "xxxxxx",
    "id" : "xxxxxx",
    "ignore_error" : false,
    "metadata" : {
      "type" : "pause"
    },
    "name" : "xxx",
    "task_name" : "CMS::PAUSE"
  } ],
  "parameters" : [ {
    "default_value" : "",
    "description" : "",
    "encryption" : false,
    "hint" : "",
    "id" : "xxxxxx",
    "param_group" : "",
    "param_name" : "xxx",
    "param_type" : "STRING",
    "quote_param" : false,
    "required" : true
  }, {
    "default_value" : "",
    "description" : "xxxxxx",
    "encryption" : false,
    "hint" : "xxxxxxx",
    "id" : "xxxxxxx",
    "param_group" : "",
    "param_name" : "xxx",
    "param_type" : "STRING",
    "quote_param" : false,
    "required" : true
  } ],
  "project_id" : "xxxxxx",
  "quote" : [ ],
  "rate_control" : {
    "have_rate_control" : false,
    "max" : 0,
    "time_delay" : 0
  },
  "share_type" : "private",
  "steps" : [ {
    "description" : "xxxxxx",
    "id" : "xxxxxx",
    "ignore_error" : false,
    "input" : { },
    "name" : "xxx",
    "type" : "pause"
  } ],
  "update_by" : "xxx",
  "update_time" : 1600026634837,
  "version" : "v1"
}

状态码: 400

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

{
  "error_code" : "AOM.31001202",
  "error_msg" : "Invalid plan parameter.",
  "http_code" : 400
}

状态码: 401

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

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

SDK代码示例

SDK代码示例如下。

 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
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 SearchTemplateByIdSolution {

    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();
        SearchTemplateByIdRequest request = new SearchTemplateByIdRequest();
        request.withShareType("<share_type>");
        try {
            SearchTemplateByIdResponse response = client.searchTemplateById(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());
        }
    }
}
 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
# 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 = __import__('os').getenv("CLOUD_SDK_AK")
    sk = __import__('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 = SearchTemplateByIdRequest()
        request.share_type = "<share_type>"
        response = client.search_template_by_id(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)
 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
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.SearchTemplateByIdRequest{}
	request.ShareType = "<share_type>"
	response, err := client.SearchTemplateById(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

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

状态码

状态码

描述

200

请求响应成功,返回执行方案详情。

400

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

401

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

错误码

请参见错误码

分享:

    相关文档

    相关产品