更新时间:2025-08-22 GMT+08:00

查询域名模板列表

功能介绍

查询域名模板列表。

调用方法

请参见如何调用API

URI

GET /v1.0/cdn/configuration/templates

表1 Query参数

参数

是否必选

参数类型

描述

tml_name

String

参数解释:

域名模板名称

约束限制:

不涉及

取值范围:

  • 1-100个字符

  • 仅支持字母、数字、中文、下划线(_)、中横线(-)

默认取值:

不涉及

tml_id

String

参数解释:

域名模板ID,可以通过本接口获取

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

tml_type

Integer

参数解释:

域名模板类型

约束限制:

不涉及

取值范围:

  • 1: 系统预置模板

  • 2: 租户自定义模板

默认取值:

不涉及

limit

String

参数解释:

分页大小

约束限制:

不涉及

取值范围:

1-10000

默认取值:

30

offset

String

参数解释:

查询的页码

约束限制:

不涉及

取值范围:

0-65535

默认取值:

0

请求参数

响应参数

状态码:200

表2 响应Body参数

参数

参数类型

描述

total

Integer

参数解释:

查询域名模板总数

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

temlates

Array of TemplateItem objects

参数解释:

查询模板配置

约束限制:

不涉及

表3 TemplateItem

参数

参数类型

描述

account_id

String

参数解释:

账户ID

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

tml_name

String

参数解释:

域名模板名称

约束限制:

不涉及

取值范围:

  • 1-100个字符

  • 仅支持字母、数字、中文、下划线(_)、中横线(-)

默认取值:

不涉及

remark

String

参数解释:

域名模板描述

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

tml_id

String

参数解释:

域名模板ID

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

type

Integer

参数解释:

域名模板类型

约束限制:

不涉及

取值范围:

  • 1: 系统预置模板

  • 2: 租户自定义模板

默认取值:

不涉及

create_time

Integer

参数解释:

创建时间

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

modify_time

Integer

参数解释:

修改时间

约束限制:

不涉及

取值范围:

不涉及

默认取值:

不涉及

configs

TemplateConfigs object

参数解释:

域名模板配置

约束限制:

不涉及

表4 TemplateConfigs

参数

参数类型

描述

http_response_header

Array of HttpResponseHeader objects

http响应头设置

cache_rules

Array of CacheRules objects

origin_follow302_status

String

参数解释:

开启回源跟随,当源站地址因业务需求做了301/302 重定向,CDN节点会先跳转到301/302对应地址获取资源,缓存后再返回给用户

约束限制:

不涉及

取值范围:

  • on: 开启

  • off: 关闭

默认取值:

不涉及

compress

Compress object

参数解释:

智能压缩,压缩网站的静态资源,缩小传输文件的大小,提升传输效率,减少带宽消耗

约束限制:

不涉及

origin_range_status

String

参数解释:

Range回源,开启后,源站在收到CDN节点回源请求时,根据HTTP请求头中的Range信息返回指定范围的数据给CDN节点

约束限制:

开启Range回源的前提是您的源站支持Range请求,即HTTP请求头中包含Range字段,否则可能导致回源失败

取值范围:

  • on: 开启

  • off: 关闭

默认取值:

不涉及

ip_filter

IpFilter object

参数解释:

IP黑白名单,对用户的请求IP地址进行过滤,从而限制访问来源

约束限制:

不涉及

referer

RefererConfig object

参数解释:

referer黑白名单,对访问者身份进行识别和过滤,从而限制访问来源

约束限制:

不涉及

user_agent_filter

UserAgentFilter object

参数解释:

UA黑白名单,对用户请求使用的代理过滤,从而限制访问来源

约束限制:

不涉及

flow_limit_strategy

Array of FlowLimitStrategy objects

参数解释:

设置用量封顶阈值,当实际用量大于阈值时停用域名,有效预防流量盗刷或恶意攻击带来的高额账单。

说明:
由于监控数据存在时延,域名将在用量达到阈值后的10分钟左右被停用

约束限制:

不涉及

表5 HttpResponseHeader

参数

参数类型

描述

name

String

参数解释:

设置HTTP响应头参数

约束限制:

不涉及

取值范围:

  • 1-100个字符

  • 由数字,大小写字母,中划线组成,只能以字母开头

默认取值:

不涉及

value

String

参数解释:

设置HTTP响应头参数的值

约束限制:

不涉及

取值范围:

  • 1-1000个字符

  • 支持字母、数字和特定字符,如:.-_*#!&+|^~'"/:;,=@?<> 等

  • 当为删除动作时,可不填

默认取值:

不涉及

action

String

参数解释:

设置HTTP响应头操作类型

约束限制:

  • 同一个响应头字段只允许删除或者设置

  • action为set时,若原HTTP响应头参数不存在该字段,则执行新增动作。若存在,则执行修改动作

取值范围:

  • set: 设置

  • delete: 删除

默认取值:

不涉及

表6 CacheRules

参数

参数类型

描述

match_type

String

参数解释:

匹配类型

约束限制:

不涉及

取值范围:

  • all: 匹配所有文件

  • file_extension: 按文件后缀匹配

  • catalog: 按目录匹配

  • full_path: 全路径匹配

  • home_page: 按首页匹配

默认取值:

不涉及

match_value

String

参数解释:

缓存规则匹配内容

约束限制:

  • 当match_type为all时,置空

  • 当match_type为file_extension时,为文件后缀,输入首字符为“.”,以“,”或“;”分隔,如.jpg,.zip,.exe,并且输入的文件名后缀总数不超过100个,总字符不超过1000

  • 当match_type为catalog时,为目录路径,输入要求以“/”作为首字符, 以“,”或“;”分隔,如/test/folder01,/test/folder02,并且输入的目录路径总数不超过20个,总字符不超过255

  • 当match_type为full_path时,为全路径,输入要求以“/”作为首字符,支持匹配指定目录下的具体文件,或者带通配符“*”的文件,单条全路径缓存规则里仅支持配置一个全路径,如/test/index.html或/test/*.jpg,不可配置/*

  • 当match_type为home_page时,置空

取值范围:

不涉及

默认取值:

不涉及

ttl

Integer

参数解释:

资源在CDN节点的缓存过期时间

约束限制:

最大支持365天

取值范围:

不涉及

默认取值:

0

ttl_unit

String

参数解释:

缓存过期时间单位

约束限制:

不涉及

取值范围:

  • s: 秒

  • m: 分

  • h: 小时

  • d: 天

默认取值:

不涉及

priority

Integer

参数解释:

缓存规则的优先级,数值越大,优先级越高

约束限制:

优先级不能相同

取值范围:

1-100

默认取值:

不涉及

follow_origin

String

参数解释:

缓存过期时间来源,设置CDN节点的缓存遵循源站还是CDN侧的配置

约束限制:

不涉及

取值范围:

  • on: CDN节点的缓存过期时间遵循源站的设置

  • off: CDN节点的缓存过期时间遵循“缓存规则”中的“缓存过期时间”

  • min_ttl: CDN节点的缓存过期时间取缓存规则和源站二者的最小值

默认取值:

off: CDN节点的缓存过期时间遵循“缓存规则”中的“缓存过期时间”

force_cache

String

参数解释:

强制缓存:CDN节点缓存过期时间是否忽略源站响应头Cache-Control中的no-cache、private、no-store字段

约束限制:

强制缓存与缓存过期时间来源功能配合使用,具体使用限制及配置效果请参考CDN用户指南的配置节点缓存规则章节

取值范围:

  • on: 打开强制缓存

  • off: 关闭强制缓存

默认取值:

off: 关闭强制缓存

url_parameter_type

String

参数解释:

URL参数

约束限制:

不涉及

取值范围:

  • del_params: 忽略指定URL参数

  • reserve_params: 保留指定URL参数

  • ignore_url_params: 忽略全部URL参数

  • full_url: 使用完整URL参数

默认取值:

full_url: 使用完整URL参数

url_parameter_value

String

参数解释:

URL参数值

约束限制:

  • 最多配置30条参数值

  • 以“,”或“;”分隔

  • 当url_parameter_type为del_params或reserve_params时必填

取值范围:

不涉及

默认取值:

不涉及

表7 Compress

参数

参数类型

描述

status

String

参数解释:

智能压缩开关

约束限制:

不涉及

取值范围:

  • on: 开启

  • off: 关闭

默认取值:

不涉及

type

String

参数解释:

智能压缩类型

约束限制:

当配置了多种智能压缩类型时,优先使用brotli压缩

取值范围:

多种智能压缩类型用“,”分隔,可选值如下:

  • gzip: gzip压缩

  • br: brotli压缩

默认取值:

不涉及

file_type

String

参数解释:

需要压缩的文件类型

约束限制:

不涉及

取值范围:

  • 内容总长度不可超过2000个字符

  • 单个格式不可超过50个字符

  • 多种格式用“,”分隔

默认取值:

开启状态下,首次传空时默认值为.js,.html,.css,.xml,.json,.shtml,.htm,否则为上次设置值

compress_min_length

Integer

参数解释:

压缩区间最小范围

约束限制:

如果未设置参与压缩的文件大小,默认大小为“0MB~30MB”的文件参与压缩。

取值范围:

  • 文件大小范围(0MB~30MB),单位为Byte

默认取值:

不涉及

compress_max_length

Integer

参数解释:

压缩区间最大范围

约束限制:

如果未设置参与压缩的文件大小,默认大小为“0MB~30MB”的文件参与压缩。

取值范围:

  • 文件大小范围(0MB~30MB),单位为Byte

默认取值:

不涉及

表8 IpFilter

参数

参数类型

描述

type

String

参数解释:

IP黑白名单类型

约束限制:

不涉及

取值范围:

  • off: 关闭IP黑白名单

  • black: IP黑名单

  • white: IP白名单

默认取值:

不涉及

value

String

参数解释:

配置IP黑白名单

说明:
支持IPv6,支持配置IP地址和IP&掩码格式的网段

约束限制:

  • 当type=off时,非必传

  • 多条规则用“,”分隔

  • 最多支持配置500条规则

  • 多个完全重复的IP/IP段将合并为一条规则

  • 不支持带通配符的地址,如192.168.0.*

取值范围:

不涉及

默认取值:

不涉及

表9 RefererConfig

参数

参数类型

描述

type

String

参数解释:

Referer黑白名单类型

约束限制:

不涉及

取值范围:

  • off: 关闭Referer黑白名单

  • black: Referer黑名单

  • white: Referer白名单

默认取值:

不涉及

value

String

参数解释:

域名或IP地址

说明:
域名、IP地址可以混合输入,支持泛域名和带端口的域名

约束限制:

  • 以“,”进行分隔

  • 域名、IP地址总数不超过1000个

  • 端口取值范围1-65535

取值范围:

不涉及

默认取值:

不涉及

include_empty

Boolean

参数解释:

是否包含空Referer

说明:
如果是黑名单并开启该选项,则表示无referer不允许访问

如果是白名单并开启该选项,则表示无referer允许访问

约束限制:

不涉及

取值范围:

  • true: 包含空

  • false: 不包含空

默认取值:

false: 不包含空

表10 UserAgentFilter

参数

参数类型

描述

type

String

参数解释:

UA黑白名单类型

约束限制:

不涉及

取值范围:

  • off: 关闭UA黑白名单

  • black: UA黑名单

  • white: UA白名单

默认取值:

不涉及

value

String

参数解释:

UA黑白名单内容

说明:
此参数作为旧参数,将于近期下线,建议使用ua_list字段设置UA黑白名单内容

约束限制:

  • 当type=off时,非必传

  • 最多配置50条规则

  • 多条规则用“,”分隔

取值范围:

  • 单条规则不超过200个字符

  • 支持数字0-9、字符a-z、A-Z,空格,及特殊符"*"、"."、"-"、"_"、"("、")"、";"、","、"/"、"'"、"#"、"!"、"@"、"$"、"^"、"&"、"+"、"="、"~"、"?"、"""、"["、"]"、"{"、"}"、""、":"、"%"

默认取值:

不涉及

include_empty

Boolean

参数解释:

是否包含空UA

说明:
如果黑名单并开启该选项,则表示无UA不允许访问

如果是白名单并开启该选项,则表示无UA允许访问

约束限制:

不涉及

取值范围:

true: 包含空

false:不包含空

默认取值:

  • 当UA为黑名单时该字段默认值为false

  • 当UA为白名单时该字段默认值为true

ua_list

Array of strings

参数解释:

配置UA黑白名单

约束限制:

  • 当type=off时,非必传

  • 最多配置50条规则

  • 单条规则不超过200个字符

  • 同时配置value和ua_list时,ua_list生效

表11 FlowLimitStrategy

参数

参数类型

描述

strategy_type

String

参数解释:

用量统计类型

约束限制:

不涉及

取值范围:

  • instant: 瞬时用量

  • hour: 累计用量(小时)

  • day: 累计用量(天)

默认取值:

不涉及

item_type

String

参数解释:

用量封顶类型

约束限制:

不涉及

取值范围:

  • bandwidth: 带宽封顶,单位: bit/s

  • traffic: 流量封顶,单位: bit

默认取值:

不涉及

limit_value

String

参数解释:

用量封顶阈值,域名用量达到该阈值后,将会停用域名

约束限制:

不涉及

取值范围:

必须为正整数

默认取值:

不涉及

alarm_percent_threshold

String

参数解释:

用量告警阈值,域名用量达到该阈值后,将会发送告警

约束限制:

不涉及

取值范围:

1-90

默认取值:

不涉及

ban_time

String

参数解释:

域名封禁周期

约束限制:

ban_time设置为0时,表示不自动解封,需要客户手动解封域名

取值范围:

  • 0: 不自动解封

  • 60: 60分钟,即1个小时

  • 720: 720分钟,即12个小时

  • 1440: 1440分钟,即24个小时

  • 4320: 4320分钟,即3天

默认取值:

不涉及

状态码:default

表12 响应Body参数

参数

参数类型

描述

error

ErrMsg object

用于返回具体的错误码和错误消息

表13 ErrMsg

参数

参数类型

描述

error_code

String

错误码

error_msg

String

错误描述

请求示例

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

响应示例

状态码:200

成功响应

{
  "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代码示例

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
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
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 := global.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        Build()

    client := cdn.NewCdnClient(
        cdn.CdnClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.ShowDomainTemplateRequest{}
	response, err := client.ShowDomainTemplate(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

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

状态码

状态码

描述

200

成功响应

default

异常响应

错误码

请参见错误码