Updated on 2026-08-12 GMT+08:00

Listing Domain Name Templates

Function

This API is used to list domain name templates.

Calling Method

For details, see Calling APIs.

URI

GET /v1.0/cdn/configuration/templates

Table 1 Query Parameters

Parameter

Mandatory

Type

Description

tml_name

No

String

Definition

Domain name template name.

Constraints

N/A

Range

  • Enter 1 to 100 characters.

  • Use only letters, digits, underscores (_), and hyphens (-).

Default Value

N/A

tml_id

No

String

Definition

Domain name template ID, which can be obtained using this API.

Constraints

N/A

Range

N/A

Default Value

N/A

tml_type

No

Integer

Definition

Domain name template type.

Constraints

N/A

Range

  • 1: system-preset.

  • 2: tenant-defined.

Default Value

N/A

limit

No

String

Definition

Number of records displayed on each page.

Constraints

N/A

Range

1 to 10,000.

Default Value

30

offset

No

String

Definition

Page number to be queried.

Constraints

N/A

Range

0 to 65,535.

Default Value

0

Request Parameters

None

Response Parameters

Status code: 200

Table 2 Response body parameters

Parameter

Type

Description

total

Integer

Definition

Total number of domain name templates.

Range

N/A

templates

Array of TemplateItem objects

Definition

Template configuration.

Table 3 TemplateItem

Parameter

Type

Description

account_id

String

Definition

Account ID.

Range

N/A

tml_name

String

Definition

Domain name template name.

Range

  • Enter 1 to 100 characters.

  • Use only letters, digits, underscores (_), and hyphens (-).

remark

String

Definition

Domain name template description.

Range

N/A

tml_id

String

Definition

Domain name template ID.

Range

N/A

type

Integer

Definition

Domain name template type.

Range

  • 1: system-preset.

  • 2: tenant-defined.

create_time

Integer

Definition

Creation time.

Range

N/A

modify_time

Integer

Definition

Modification time.

Range

N/A

configs

TemplateConfigs object

Definition

Domain name template configuration.

Table 4 TemplateConfigs

Parameter

Type

Description

http_response_header

Array of HttpResponseHeader objects

Definition

HTTP response headers. When CDN PoPs respond to clients, they perform operations on HTTP response headers based on your settings.

cache_rules

Array of CacheRules objects

Definition

Cache TTL of origin resources on CDN PoPs.

origin_follow302_status

String

Definition

Whether to enable redirect from origin. If the origin server uses 301/302 redirection, CDN PoPs redirect to the address specified in a 301/302 response, cache the resource, and return it to the user.

Range

  • on: enabled.

  • off: disabled.

compress

Compress object

Definition

Smart compression. CDN can compress static content on websites by reducing file size. This speeds up file transfer and saves a lot of bandwidth.

origin_range_status

String

Definition

Range requests for origin pull. A range request allows the origin server to send data of a specific range to a CDN PoP based on the range information in the HTTP request header.

Range field in the headers. Otherwise, origin pull may fail.

Range

  • on: enabled.

  • off: disabled.

ip_filter

IpFilter object

Definition

IP access control list (ACL), which blocks or allows access from specific IP addresses.

referer

RefererConfig object

Definition

Referrer whitelist or whitelist, which identifies and filters user identities to control access.

user_agent_filter

UserAgentFilter object

Definition

User-Agent ACL, which filters out requests from specific proxies.

flow_limit_strategy

Array of FlowLimitStrategy objects

Definition

Usage cap. When the actual data exceeds the cap you set, CDN blocks the domain name to prevent excess billing caused by traffic theft or attacks.

NOTE:
Blocking may be delayed by about 10 minutes after the monitored data reaches the cap.
Table 5 HttpResponseHeader

Parameter

Type

Description

name

String

Definition

Name of an HTTP response header.

Range

  • Enter 1 to 100 characters.

  • Use only letters, digits, and hyphens (-). Start with a letter.

value

String

Definition

Value of the HTTP response header.

Range

  • Enter 1 to 1,000 characters.

  • Use only letters, digits, and the following special characters .-_*#!&+|^~'"/:;,=@?<>

  • This parameter is optional when the header is to be deleted.

action

String

Definition

Operation type of the HTTP response header.

action is set to set, if the header does not exist in the original HTTP response, it is added. If it exists, it is modified.

Range

  • set

  • delete

Table 6 CacheRules

Parameter

Type

Description

match_type

String

Definition

Match type.

Range

  • all: all files.

  • file_extension: file name extension.

  • catalog: directory.

  • full_path: full path.

  • home_page: homepage.

match_value

String

Definition

Cache rule match content.

match_type is set to all, this parameter is left blank.

  • When match_type is set to file_extension, the value of this parameter is a list of up to 100 file types with up to 1,000 characters. A file type starts with a period (.). File types are separated by commas (,) or semicolons (;). Example: .jpg,.zip,.exe.

  • When match_type is set to catalog, the value of this parameter is a list of up to 20 directories with up to 255 characters. A directory starts with a slash (/). Directories are separated by commas (,) or semicolons (;). Example: /test/folder01,/test/folder02.

  • When match_type is set to full_path, the value of this parameter is a full path. A full path starts with a slash (/) and supports wildcard characters (*). A cache rule can contain only one full path, for example, /test/index.html or /test/*.jpg. /* is not allowed.

  • When match_type is set to home_page, this parameter is left blank.

Range

N/A

ttl

Integer

Definition

TTL of a resource cached on CDN PoPs.

Range

N/A

ttl_unit

String

Definition

Unit of the cache TTL.

Range

  • s: second.

  • m: minute.

  • h: hour.

  • d: day.

priority

Integer

Definition

Cache rule priority. A larger value indicates a higher priority.

Range

1 to 100.

follow_origin

String

Definition

Source of the cache TTL, that is, whether CDN PoPs use the cache TTL set on the origin server or that set in cache rules on CDN.

Range

  • on: CDN PoPs use the TTL set on the origin server.

  • off: CDN PoPs use the TTL set in cache rules.

  • min_ttl: CDN PoPs use the shorter TTL between the TTL set on the origin server and that in cache rules.

force_cache

String

Definition

Forcible cache. Specify whether CDN PoP cache ignores the no-cache, private, and no-store fields in the Cache-Control response header sent from the origin server.

Range

  • on: enabled.

  • off: disabled.

url_parameter_type

String

Definition

URL parameter filtering.

Range

  • del_params: Ignore specific URL parameters.

  • reserve_params: Retain specific URL parameters.

  • ignore_url_params: Ignore all URL parameters.

  • full_url: Retain all URL parameters.

url_parameter_value

String

Definition

URL parameters.

url_parameter_type is set to del_params or reserve_params.

Range

N/A

Table 7 Compress

Parameter

Type

Description

status

String

Definition

Smart compression status.

Range

  • on: enabled.

  • off: disabled.

type

String

Definition

Smart compression type.

Range

Separate smart compression types by commas (,).

  • gzip: gzip compression.

  • br: Brotli compression.

file_type

String

Definition

Types of files to compress.

Range

  • Enter up to 2,000 characters.

  • Enter up to 50 characters for each type.

  • Separate types by commas (,).

.js,.html,.css,.xml,.json,.shtml,.htm,text/xml,text/plain,text/javascript,text/html,text/css,image/tiff,image/svg+xml,application/xml,application/x-javascript,application/rss+xml,application/json,application/javascript. When this function is used again and this value is left empty, the result of the previous setting is used.

compress_min_length

Integer

Definition

Minimum size of files to be compressed.

Range

  • 0 MB to 30 MB. The unit is byte.

compress_max_length

Integer

Definition

Maximum size of files to be compressed.

Range

  • 0 MB to 30 MB. The unit is byte.

Table 8 IpFilter

Parameter

Type

Description

type

String

Definition

IP ACL type.

Range

  • off: The IP ACL is disabled.

  • black: IP address blacklist.

  • white: IP address whitelist.

value

String

Definition

IP ACL.

NOTE:
IPv6 is supported. IP addresses and CIDR blocks in the IP address/Subnet mask format are supported.

type is set to off.

  • Separate rules by commas (,).

  • Enter up to 500 rules.

  • Duplicate IP addresses and CIDR blocks will be removed.

  • Wildcards are not supported, for example, 192.168.0.*.

Range

N/A

Table 9 RefererConfig

Parameter

Type

Description

type

String

Definition

Type of the referer blacklist or whitelist.

Range

  • off: The referer blacklist/whitelist is disabled.

  • black: referer blacklist.

  • white: referer whitelist.

value

String

Definition

Domain names or IP addresses.

NOTE:
Domain name and IP address can be entered together. Wildcard domain names and domain names with port numbers are supported.

Range

N/A

include_empty

Boolean

Definition

Whether blank referers are included.

NOTE:
A referer blacklist including blank referers indicates that requests without any referers are not allowed to access.

A referer whitelist including blank referers indicates that requests without any referers are allowed to access.

Range

  • true: Blank referers are included.

  • false: Blank referers are not included.

Table 10 UserAgentFilter

Parameter

Type

Description

type

String

Definition

User-Agent ACL type.

Range

  • off: The User-Agent ACL is disabled.

  • black: User-Agent blacklist.

  • white: User-Agent whitelist.

value

String

Definition

User-Agent ACL content.

NOTE:
This old parameter will be deprecated recently. Use ua_list to set a User-Agent ACL.

type is set to off.

  • Configure up to 50 rules.

  • Separate rules by commas (,).

Range

  • Enter up to 200 characters for each rule.

  • Use only letters, digits, spaces, and the following special characters: *.-_();,/'#!@$^&+=~?"[]{}:%

include_empty

Boolean

Definition

Whether blank user agents are included.

NOTE:
A blacklist including blank user agents indicates that requests without any user agents are not allowed to access.

A whitelist including blank user agents indicates that requests without any user agents are allowed to access.

Range

true: Blank user agents are included.

false: Blank user agents are not included.

false for blacklists.

  • true for whitelists.

ua_list

Array of strings

Definition

User-Agent ACL.

type is set to off.

  • Configure up to 50 rules.

  • Enter up to 200 characters for each rule.

  • When ua_list and value are both set, ua_list is used.

Table 11 FlowLimitStrategy

Parameter

Type

Description

strategy_type

String

Definition

Measurement type.

Range

  • instant: instantaneous usage.

  • hour: hourly cumulative usage.

  • day: daily cumulative usage.

item_type

String

Definition

Usage cap type.

Range

  • bandwidth: bandwidth cap, in bit/s

  • traffic: traffic cap, in bytes

limit_value

Long

Definition

Usage cap. When the usage of a domain name reaches this cap, CDN will be disabled for it.

Range

The value must be a positive integer.

alarm_percent_threshold

Integer

Definition

Usage alarm threshold. When the domain name usage reaches this threshold, an alarm is sent.

Range

10-90

ban_time

Long

Definition

Capping period.

ban_time to 0 indicates that the domain name is not automatically unblocked. You need to manually unblock it.

Range

  • 0: Block the domain name until you manually unblock it.

  • 60: 60 minutes (1 hour)

  • 720: 720 minutes (12 hours)

  • 1440: 1,440 minutes (24 hours)

  • 4320: 4,320 minutes (3 days)

Status code: 400

Table 12 Response body parameters

Parameter

Type

Description

error

ErrMsg object

Error code and error message.

Table 13 ErrMsg

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Example Requests

GET https://cdn.myhuaweicloud.com/v1.0/cdn/configuration/templates?limit=1000&offset=0

Example Responses

Status code: 200

Success response

{
  "total" : 1,
  "templates" : [ {
    "type" : 2,
    "configs" : {
      "http_response_header" : [ {
        "action" : "set",
        "name" : "Content-Disposition",
        "value" : "example"
      } ]
    },
    "tml_name" : "example",
    "tml_id" : "example********************tmlid",
    "remark" : "this is remark",
    "account_id" : "example****************accountid",
    "create_time" : 1700000000000,
    "modify_time" : 1700000000000
  } ]
}

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
package com.huaweicloud.sdk.test;

import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.GlobalCredentials;
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.cdn.v2.region.CdnRegion;
import com.huaweicloud.sdk.cdn.v2.*;
import com.huaweicloud.sdk.cdn.v2.model.*;


public class ShowDomainTemplateSolution {

    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 GlobalCredentials()
                .withAk(ak)
                .withSk(sk);

        CdnClient client = CdnClient.newBuilder()
                .withCredential(auth)
                .withRegion(CdnRegion.valueOf("<YOUR REGION>"))
                .build();
        ShowDomainTemplateRequest request = new ShowDomainTemplateRequest();
        try {
            ShowDomainTemplateResponse response = client.showDomainTemplate(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

import os
from huaweicloudsdkcore.auth.credentials import GlobalCredentials
from huaweicloudsdkcdn.v2.region.cdn_region import CdnRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkcdn.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 = GlobalCredentials(ak, sk)

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

    try:
        request = ShowDomainTemplateRequest()
        response = client.show_domain_template(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
39
40
41
42
43
44
45
46
47
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/global"
    cdn "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cdn/v2"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cdn/v2/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cdn/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, err := global.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        SafeBuild()

    if err != nil {
        fmt.Println(err)
        return
    }

    hcClient, err := cdn.CdnClientBuilder().
         WithRegion(region.ValueOf("<YOUR REGION>")).
         WithCredential(auth).
         SafeBuild()


    if err != nil {
        fmt.Println(err)
        return
    }

    client := cdn.NewCdnClient(hcClient)

    request := &model.ShowDomainTemplateRequest{}
	response, err := client.ShowDomainTemplate(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

Success response

400

Abnormal response

Error Codes

See Error Codes.