Updated on 2024-06-14 GMT+08:00

Querying Template Details

Function

This API is used to query template details.

Calling Method

For details, see Calling APIs.

URI

GET /v3/templates/{template_id}

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

template_id

Yes

String

Template ID.

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

template_type

Yes

String

Template type.

source

No

String

API callers.

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

No

String

User token.

It can be obtained by calling the IAM API used to obtain a user token. The value of X-Subject-Token in the response header is the user token.

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

template_id

String

Template ID.

template_name

String

Template name.

template_type

String

Template type.

user_id

String

User ID.

user_name

String

User name.

domain_id

String

Tenant ID.

domain_name

String

Tenant name.

is_build_in

Boolean

Whether the template is a built-in template or not.

region

String

region

project_id

String

Project ID.

project_name

String

Project name.

create_time

String

Creation time.

last_modify_time

String

Modification time.

is_watch

Boolean

Whether it is followed.

description

String

Template description.

parameter

Array of TemplateParam objects

Template parameter.

flow

Map<String,Map<String,String>>

Flow orchestration details, which describe the serial and parallel relationships of jobs in each stage of a pipeline. A Map type value, key indicates the stage name. By default, the first stage is initial, the last stage is final, and other stages are identified by state_digit. The value is the ID of the task (identified by Task_digit) in the stage and the ID of the subsequent stage. This field is one of the basic orchestration data of a pipeline. It is advised to obtain the value from the template-based creation API on the pipeline web UI.

states

Map<String,TemplateState>

State orchestration details. It is a Map type value. This field is one of the basic orchestration data of a pipeline. It is advised to obtain the value from the template-based creation API on the pipeline web UI.

Table 5 TemplateParam

Parameter

Type

Description

required

String

Whether the parameter is mandatory.

visible

String

Whether the parameter is visible.

name

String

Pipeline parameter name.

value

String

Pipeline parameter value.

description

String

Pipeline parameter description.

paramtype

String

Pipeline parameter type.

display_type

String

Pipeline parameter display type.

display_name

String

Pipeline parameter display name.

is_static

Boolean

Whether it is a static parameter.

is_default

Boolean

Whether it is a default parameter.

limits

Array of ParamTypeLimits objects

Data of the Array type.

constraints

Array of Constraint objects

Data of the Array type.

Table 6 ParamTypeLimits

Parameter

Type

Description

disable

String

Whether it is discarded.

name

String

Language name.

displayname

String

Language display name.

id

String

Policy ID.

language

String

Scanning language.

Table 7 Constraint

Parameter

Type

Description

type

String

Verification rule type.

value

String

Verification rule.

errormsg

String

Verification failure description.

Table 8 TemplateState

Parameter

Type

Description

type

String

Job type.

name

String

Job name.

module_or_template_id

String

Template job ID.

module_or_template_name

String

Template job name.

display_name

String

Job name displayed on the pipeline page.

dsl_method

String

Types of jobs that can be mounted to a pipeline.

parameters

Map<String,Object>

Job parameter, which is a value of map type.

is_manual_execution

Boolean

Whether to manually execute the job.

job_parameter_validate

Boolean

Whether to verify job parameters.

is_show_codehub_url

Boolean

Whether to display the code repository URL.

is_execute

Boolean

Whether to execute

job_id

String

ID of the executed job.

job_name

String

Name of the executed job.

project_id

String

ID of the project to which the job belongs.

execution_mode

String

This parameter controls the execution mode of jobs in a stage. If type is task, the value of execution_mode is null. If type is stage, the value of execution_mode can be parallel or serial.

Status code: 400

Table 9 Response body parameters

Parameter

Type

Description

error_msg

String

Error message.

error_code

String

Error code.

Example Requests

GET https://{endpoint}/v3/templates/6efb0b24e2e9489eb0e53ee12904a19e?template_type=deployMan

Example Responses

None

SDK Sample Code

The SDK sample code is as follows.

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

    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();
        ShowTemplateDetailRequest request = new ShowTemplateDetailRequest();
        request.withTemplateType("<template_type>");
        request.withSource("<source>");
        try {
            ShowTemplateDetailResponse response = client.showTemplateDetail(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
31
32
# 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 = ShowTemplateDetailRequest()
        request.template_type = "<template_type>"
        request.source = "<source>"
        response = client.show_template_detail(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
37
38
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.ShowTemplateDetailRequest{}
	request.TemplateType = "<template_type>"
	sourceRequest:= "<source>"
	request.Source = &sourceRequest
	response, err := client.ShowTemplateDetail(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.