Updated on 2024-07-04 GMT+08:00

Querying Template List

Function

This API is used to query the pipeline template list.

Calling Method

For details, see Calling APIs.

URI

POST /v5/{tenant_id}/api/pipeline-templates/list

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

tenant_id

Yes

String

Tenant ID.

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

language

No

String

Template language.

is_system

No

Boolean

Whether the template is a system template.

name

No

String

Template name.

offset

No

Long

Offset, which is the position where the query starts. Min.: 0 (default value).

limit

No

Long

Number of records queried each time. The default value is 10.

sort_key

No

String

(Optional) Field for sorting. The value can be name or create_time.

sort_dir

No

String

(Optional) Sorting type. asc: Ascending; desc: Descending.

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

offset

Integer

Initial offset.

limit

Integer

Number of records on each page.

total

Integer

Total number.

templates

Array of PipelineTemplateSimpleVO objects

Pipeline template list.

Table 4 PipelineTemplateSimpleVO

Parameter

Type

Description

id

String

Template ID.

name

String

Template name.

icon

String

Template icon.

manifest_version

String

Version.

language

String

Template language.

description

String

Template description.

is_system

Boolean

Whether the template is a system template.

region

String

Template region.

domain_id

String

ID of the tenant to which the template belongs.

creator_id

String

Template creator ID.

creator_name

String

Template creator name.

updater_id

String

Template updater ID.

create_time

Integer

Creation time.

update_time

Integer

Update time.

is_collect

Boolean

Whether to follow or not.

is_show_source

String

Whether to display the pipeline source.

stages

Array of stages objects

Template orchestration stages.

Table 5 stages

Parameter

Type

Description

name

String

Stage name.

sequence

Integer

Stage sequence.

Status code: 400

Table 6 Response body parameters

Parameter

Type

Description

error_msg

String

Error message.

error_code

String

Error code.

Example Requests

This API is used to query the pipeline template list. Set the start offset to 0 and the number to 3.

POST https://{endpoint}/v5/a5f63758220947b7821e70ae2734c01d/api/pipeline-templates/list

{
  "is_system" : "",
  "offset" : 0,
  "limit" : 3,
  "name" : ""
}

Example Responses

Status code: 200

OK

{
  "offset" : 0,
  "limit" : 3,
  "total" : 19,
  "templates" : [ {
    "id" : "e908740fe06e44a28f30c0f3c81b2ad5",
    "name" : "Serverless-maven Compilation and Deployment",
    "icon" : "maven60",
    "manifest_version" : "3.0",
    "language" : "Java",
    "description" : "Serverless-maven compilation and building, packaging, and deployment templates",
    "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" : "Build and Check",
      "sequence" : 0
    }, {
      "name" : "Deployment and Test",
      "sequence" : 1
    } ]
  }, {
    "id" : "ac3b3b9a6cb64ef6b732c8f8459ab578",
    "name" : "Building a Container Image on a Node",
    "icon" : "npm60",
    "manifest_version" : "3.0",
    "language" : "Node.js",
    "description" : "Use nodes to build container images and push them to SWR for storage.",
    "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" : "Build",
      "sequence" : 0
    } ]
  }, {
    "id" : "8ea4d170ba0d45d9b1b647a9780ebcf8",
    "name" : "Getting Started",
    "icon" : null,
    "manifest_version" : "3.0",
    "language" : "java",
    "description" : "Pipeline Template for Beginners",
    "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" : "Code check",
      "sequence" : 0
    }, {
      "name" : "Build Phase",
      "sequence" : 1
    }, {
      "name" : "Deployment and Release",
      "sequence" : 2
    } ]
  } ]
}

SDK Sample Code

The SDK sample code is as follows.

This API is used to query the pipeline template list. Set the start offset to 0 and the number to 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());
        }
    }
}

This API is used to query the pipeline template list. Set the start offset to 0 and the number to 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)

This API is used to query the pipeline template list. Set the start offset to 0 and the number to 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)
    }
}

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

400

Bad request

401

Unauthorized

403

Forbidden

404

Not Found

Error Codes

See Error Codes.