查询模板列表
功能介绍
查询流水线模板列表
调用方法
请参见如何调用API。
URI
POST /v5/{tenant_id}/api/pipeline-templates/list
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
tenant_id |
是 |
String |
租户ID |
请求参数
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
language |
否 |
String |
模板语言 |
is_system |
否 |
Boolean |
是否系统模板 |
name |
否 |
String |
模板名称 |
offset |
否 |
Long |
偏移量,表示从此偏移量开始查询,offset大于等于0,默认为0 |
limit |
否 |
Long |
每次查询的条目数量,默认为10。 |
sort_key |
否 |
String |
用于排序的字段,非必选。取值为:name, create_time |
sort_dir |
否 |
String |
排序类型,非必选。asc按排序字段升序,desc按排序字段降序 |
响应参数
状态码: 200
参数 |
参数类型 |
描述 |
---|---|---|
offset |
Integer |
起始偏移 |
limit |
Integer |
每页大小 |
total |
Integer |
总数 |
templates |
Array of PipelineTemplateSimpleVO objects |
流水线模板列表 |
参数 |
参数类型 |
描述 |
---|---|---|
id |
String |
模板ID |
name |
String |
模板名称 |
icon |
String |
模板图标 |
manifest_version |
String |
版本 |
language |
String |
模板语言 |
description |
String |
模板描述 |
is_system |
Boolean |
是否系统模板 |
region |
String |
模板局点 |
domain_id |
String |
模板所属租户ID |
creator_id |
String |
模板创建人ID |
creator_name |
String |
模板创建人名称 |
updater_id |
String |
模板更新人ID |
create_time |
Integer |
创建时间 |
update_time |
Integer |
更新时间 |
is_collect |
Boolean |
是否收藏 |
is_show_source |
String |
是否展示流水线源 |
stages |
Array of stages objects |
模板编排stages |
状态码: 400
参数 |
参数类型 |
描述 |
---|---|---|
error_msg |
String |
错误信息 |
error_code |
String |
错误码 |
请求示例
查询流水线模板列表。 指定查询的起始偏移量为0,数量为3。
POST https://{endpoint}/v5/a5f63758220947b7821e70ae2734c01d/api/pipeline-templates/list { "is_system" : "", "offset" : 0, "limit" : 3, "name" : "" }
响应示例
状态码: 200
OK
{ "offset" : 0, "limit" : 3, "total" : 19, "templates" : [ { "id" : "e908740fe06e44a28f30c0f3c81b2ad5", "name" : "Serverless-maven编译部署", "icon" : "maven60", "manifest_version" : "3.0", "language" : "Java", "description" : "Serverless-maven编译构建、打包部署模板", "is_system" : true, "region" : "system", "domain_id" : "system", "creator_id" : "system", "creator_name" : "system", "updater_id" : "e908740fe06e44a28f30c0f3c81b2ad5", "create_time" : 1671172288000, "update_time" : 1677640980000, "is_collect" : true, "is_show_source" : null, "stages" : [ { "name" : "构建和检查", "sequence" : 0 }, { "name" : "部署和测试", "sequence" : 1 } ] }, { "id" : "ac3b3b9a6cb64ef6b732c8f8459ab578", "name" : "Node构建容器镜像", "icon" : "npm60", "manifest_version" : "3.0", "language" : "Node.js", "description" : "使用Node构建容器镜像,推送到SWR存储", "is_system" : true, "region" : "system", "domain_id" : "system", "creator_id" : "system", "creator_name" : "system", "updater_id" : "ac3b3b9a6cb64ef6b732c8f8459ab578", "create_time" : 1671172288000, "update_time" : 1677640980000, "is_collect" : true, "is_show_source" : null, "stages" : [ { "name" : "构建", "sequence" : 0 } ] }, { "id" : "8ea4d170ba0d45d9b1b647a9780ebcf8", "name" : "新手上路", "icon" : null, "manifest_version" : "3.0", "language" : "java", "description" : "流水线新手体验模板", "is_system" : true, "region" : "system", "domain_id" : "system", "creator_id" : "system", "creator_name" : "system", "updater_id" : "ac3b3b9a6cb64ef6b732c8f8459ab578", "create_time" : 1680769082000, "update_time" : 1680770243000, "is_collect" : false, "is_show_source" : null, "stages" : [ { "name" : "代码检查", "sequence" : 0 }, { "name" : "构建阶段", "sequence" : 1 }, { "name" : "部署发布", "sequence" : 2 } ] } ] }
SDK代码示例
SDK代码示例如下。
查询流水线模板列表。 指定查询的起始偏移量为0,数量为3。
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 |
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.codeartspipeline.v2.region.CodeArtsPipelineRegion; import com.huaweicloud.sdk.codeartspipeline.v2.*; import com.huaweicloud.sdk.codeartspipeline.v2.model.*; public class ListPipelineTemplatesSolution { 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); CodeArtsPipelineClient client = CodeArtsPipelineClient.newBuilder() .withCredential(auth) .withRegion(CodeArtsPipelineRegion.valueOf("<YOUR REGION>")) .build(); ListPipelineTemplatesRequest request = new ListPipelineTemplatesRequest(); ListPipelineTemplatesQuery body = new ListPipelineTemplatesQuery(); body.withLimit(3L); body.withOffset(0L); body.withName(""); body.withIsSystem(); request.withBody(body); try { ListPipelineTemplatesResponse response = client.listPipelineTemplates(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()); } } } |
查询流水线模板列表。 指定查询的起始偏移量为0,数量为3。
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 |
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkcodeartspipeline.v2.region.codeartspipeline_region import CodeArtsPipelineRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkcodeartspipeline.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 = CodeArtsPipelineClient.new_builder() \ .with_credentials(credentials) \ .with_region(CodeArtsPipelineRegion.value_of("<YOUR REGION>")) \ .build() try: request = ListPipelineTemplatesRequest() request.body = ListPipelineTemplatesQuery( limit=3, offset=0, name="", is_system= ) response = client.list_pipeline_templates(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) |
查询流水线模板列表。 指定查询的起始偏移量为0,数量为3。
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 |
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" codeartspipeline "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/codeartspipeline/v2" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/codeartspipeline/v2/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/codeartspipeline/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 := codeartspipeline.NewCodeArtsPipelineClient( codeartspipeline.CodeArtsPipelineClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.ListPipelineTemplatesRequest{} limitListPipelineTemplatesQuery:= int64(3) offsetListPipelineTemplatesQuery:= int64(0) nameListPipelineTemplatesQuery:= "" isSystemListPipelineTemplatesQuery:= request.Body = &model.ListPipelineTemplatesQuery{ Limit: &limitListPipelineTemplatesQuery, Offset: &offsetListPipelineTemplatesQuery, Name: &nameListPipelineTemplatesQuery, IsSystem: &isSystemListPipelineTemplatesQuery, } response, err := client.ListPipelineTemplates(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
状态码 |
描述 |
---|---|
200 |
OK |
400 |
Bad request |
401 |
Unauthorized |
403 |
Forbidden |
404 |
Not Found |
错误码
请参见错误码。