查询域名模板列表 - ShowDomainTemplate
功能介绍
查询域名模板列表。
调用方法
请参见如何调用API。
授权信息
账号具备所有API的调用权限,如果使用账号下的IAM用户调用当前API,该IAM用户需具备调用API所需的权限。
- 如果使用角色与策略授权,具体权限要求请参见权限和授权项。
- 如果使用身份策略授权,需具备如下身份策略权限。
URI
GET /v1.0/cdn/configuration/templates
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| tml_name | 否 | String | 参数解释: 域名模板名称 约束限制: 不涉及 取值范围: 默认取值: 不涉及 |
| tml_id | 否 | String | 参数解释: 域名模板ID,可以通过本接口获取 约束限制: 不涉及 取值范围: 不涉及 默认取值: 不涉及 |
| tml_type | 否 | Integer | 参数解释: 域名模板类型 约束限制: 不涉及 取值范围: 默认取值: 不涉及 |
| limit | 否 | String | 参数解释: 分页大小 约束限制: 不涉及 取值范围: 1-10000 默认取值: 30 |
| offset | 否 | String | 参数解释: 查询的页码 约束限制: 不涉及 取值范围: 0-65535 默认取值: 0 |
请求参数
无
响应参数
状态码:200
| 参数 | 参数类型 | 描述 |
|---|---|---|
| total | Integer | 参数解释: 查询域名模板总数 取值范围: 不涉及 |
| templates | Array of TemplateItem objects | 参数解释: 查询模板配置 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| account_id | String | 参数解释: 账户ID 取值范围: 不涉及 |
| tml_name | String | 参数解释: 域名模板名称 取值范围: |
| remark | String | 参数解释: 域名模板描述 取值范围: 不涉及 |
| tml_id | String | 参数解释: 域名模板ID 取值范围: 不涉及 |
| type | Integer | 参数解释: 域名模板类型 取值范围: |
| create_time | Integer | 参数解释: 创建时间,Unix时间戳,单位为秒 取值范围: 不涉及 |
| modify_time | Integer | 参数解释: 修改时间,Unix时间戳,单位为秒 取值范围: 不涉及 |
| configs | TemplateConfigs object | 参数解释: 域名模板配置 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| http_response_header | Array of HttpResponseHeader objects | 参数解释: HTTP响应头,CDN节点响应客户端时,根据HTTP响应头配置操作响应的HTTP头部信息 |
| cache_rules | Array of CacheRules objects | 参数解释: 设置源站资源在CDN节点的缓存时长 |
| origin_follow302_status | String | 参数解释: 开启回源跟随,当源站地址因业务需求做了301/302 重定向,CDN节点会先跳转到301/302对应地址获取资源,缓存后再返回给用户 取值范围: |
| compress | Compress object | 参数解释: 智能压缩,压缩网站的静态资源,缩小传输文件的大小,提升传输效率,减少带宽消耗 |
| origin_range_status | String | 参数解释: Range回源,开启后,源站在收到CDN节点回源请求时,根据HTTP请求头中的Range信息返回指定范围的数据给CDN节点 取值范围: |
| ip_filter | IpFilter object | 参数解释: IP黑白名单,对用户的请求IP地址进行过滤,从而限制访问来源 |
| referer | RefererConfig object | 参数解释: referer黑白名单,对访问者身份进行识别和过滤,从而限制访问来源 |
| user_agent_filter | UserAgentFilter object | 参数解释: UA黑白名单,对用户请求使用的代理过滤,从而限制访问来源 |
| flow_limit_strategy | Array of FlowLimitStrategy objects | 参数解释: 设置用量封顶阈值,当实际用量大于阈值时停用域名,有效预防流量盗刷或恶意攻击带来的高额账单。 说明: 由于监控数据存在时延,域名将在用量达到阈值后的10分钟左右被停用 |
| origin_request_header | Array of OriginRequestHeader objects | 参数解释: 回源请求头,CDN节点回源时,在请求源站时添加指定的HTTP请求头信息 |
| https | 参数解释: HTTPS证书配置,配置证书后,允许客户端采用HTTPS协议访问CDN节点 | |
| http2 | String | 参数解释: HTTP/2开关,支持客户端采用HTTP/2协议访问CDN节点 取值范围: |
| ocsp_stapling | String | 参数解释: OCSP Stapling开关,开启后CDN节点将获取并缓存服务器证书的OCSP响应结果并直接发送给客户端 取值范围: |
| quic | Quic object | 参数解释: QUIC协议,客户端使用QUIC协议访问CDN节点,提高了传输的安全性,减少传输和连接时的延时,避免网络拥塞 |
| force_redirect | ForceRedirect object | 参数解释: 强制客户端使用HTTPS协议访问CDN节点 |
| https_tls_version | HttpsTlsVersion object | 参数解释: 配置TLS版本及加密套件,TLS版本需要匹配合适的加密套件使用,详情可参考CDN《用户指南》文档的“TLS版本与加密套件”章节。 |
| access_area_filter | Array of AccessAreaFilter objects | 参数解释: 区域访问控制,通过配置访问控制规则限制客户端所在地区,实现只允许或只禁止特定地区的用户访问资源 |
| url_auth | UrlAuth object | 参数解释: 配置URL鉴权功能,通过计算出的鉴权URL访问用户站点资源,防止资源被用户恶意下载盗用 |
| rules | Array of RuleResponse objects | 参数解释: 规则引擎,通过配置规则来对请求和响应进行自定义控制 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| match_type | String | 参数解释: 匹配类型 取值范围: |
| match_value | String | 参数解释: 缓存规则匹配内容 取值范围: 不涉及 |
| ttl | Integer | 参数解释: 资源在CDN节点的缓存过期时间,单位由ttl_unit参数指定 取值范围: 不涉及 |
| ttl_unit | String | 参数解释: 缓存过期时间单位 取值范围: |
| priority | Integer | 参数解释: 缓存规则的优先级,数值越大,优先级越高 取值范围: 1-1000 |
| follow_origin | String | 参数解释: 缓存过期时间来源,设置CDN节点的缓存遵循源站还是CDN侧的配置 取值范围: |
| force_cache | String | 参数解释: 强制缓存:CDN节点缓存过期时间是否忽略源站响应头Cache-Control中的no-cache、private、no-store字段 取值范围: |
| url_parameter_type | String | 参数解释: URL参数 取值范围: |
| url_parameter_value | String | 参数解释: URL参数值 取值范围: 不涉及 |
| stale_while_revalidate | String | 参数解释: 缓存回源后,从源站获取的新缓存数据在后台生效;在过期缓存生效期间,若客户端请求的资源大于新缓存更新时间,则CDN节点会响应过期内容,同时回源更新缓存 取值范围: |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| status | String | 参数解释: 智能压缩开关 取值范围: |
| type | String | 参数解释: 智能压缩类型 取值范围: 多种智能压缩类型用“,”分隔,可选值如下: |
| file_type | String | 参数解释: 需要压缩的文件类型 取值范围: |
| compress_min_length | Integer | 参数解释: 压缩区间最小范围 取值范围: |
| compress_max_length | Integer | 参数解释: 压缩区间最大范围 取值范围: |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| type | String | 参数解释: IP黑白名单类型 取值范围: |
| value | String | 参数解释: 配置IP黑白名单 说明: 支持IPv6,支持配置IP地址和IP&掩码格式的网段 取值范围: 不涉及 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| type | String | 参数解释: Referer黑白名单类型 取值范围: |
| value | String | 参数解释: 域名或IP地址 说明: 域名、IP地址可以混合输入,支持泛域名和带端口的域名 取值范围: 不涉及 |
| include_empty | Boolean | 参数解释: 是否包含空Referer 说明: 如果是黑名单并开启该选项,则表示无referer不允许访问 如果是白名单并开启该选项,则表示无referer允许访问 取值范围: |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| type | String | 参数解释: UA黑白名单类型 取值范围: |
| value | String | 参数解释: UA黑白名单内容 说明: 此参数作为旧参数,将于近期下线,建议使用ua_list字段设置UA黑白名单内容 取值范围: |
| include_empty | Boolean | 参数解释: 是否包含空UA 说明: 如果黑名单并开启该选项,则表示无UA不允许访问 如果是白名单并开启该选项,则表示无UA允许访问 取值范围: true: 包含空 false:不包含空 |
| ua_list | Array of strings | 参数解释: 配置UA黑白名单,每个数组元素为一条UA规则 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| strategy_type | String | 参数解释: 用量统计类型 取值范围: |
| item_type | String | 参数解释: 用量封顶类型 取值范围: |
| limit_value | Long | 参数解释: 用量封顶阈值,域名用量达到该阈值后,将会停用域名,单位由item_type参数决定(bandwidth对应bit/s,traffic对应byte) 取值范围: 必须为正整数 |
| alarm_percent_threshold | Integer | 参数解释: 用量告警阈值,单位为百分比(%),域名用量达到该百分比阈值后,将会发送告警 取值范围: 10-90 |
| ban_time | Long | 参数解释: 域名封禁周期 取值范围: |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| domain_name | String | 参数解释: 需要配置HTTPS证书的域名 取值范围: 不涉及 |
| https_switch | Integer | 参数解释: 证书配置开关 取值范围: |
| access_origin_way | Integer | 参数解释: 回源协议 取值范围: |
| force_redirect_https | Integer | 参数解释: 是否开启HTTPS强制跳转,强制客户端使用HTTPS协议访问CDN节点 说明: 此参数即将下线,建议使用force_redirect_config修改配置 取值范围: |
| force_redirect_config | ForceRedirect object | 参数解释: 强制客户端使用HTTPS协议访问CDN节点 |
| http2 | Integer | 参数解释: HTTP/2开关,支持客户端采用HTTP/2协议访问CDN节点 取值范围: |
| cert_name | String | 参数解释: 证书名称 取值范围: 3-64个字符,由英文字母、数字及“-”、“_”、空格组成 |
| certificate | String | 参数解释: SSL证书内容 取值范围: 证书链长度不超过20KB |
| private_key | String | 参数解释: SSL证书私钥内容 取值范围: 不涉及 |
| certificate_type | Integer | 参数解释: 证书类型 取值范围: |
| scm_certificate_id | String | 参数解释: SCM证书ID,可使用云证书与管理服务(CCM)的查询证书列表接口获取 取值范围: 不涉及 |
| certificates | Array of MultiCertificateBatchVo objects | 参数解释: 配置国际证书和国密证书双证书场景下的证书列表 取值范围: 不涉及 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| cert_name | String | 参数解释: 证书名称 取值范围: |
| certificate_category | Integer | 参数解释: 证书类型 取值范围: |
| certificate_type | Integer | 参数解释: 证书类型 取值范围: |
| certificate | String | 参数解释: SSL证书内容 取值范围: 证书链长度不超过20KB |
| private_key | String | 参数解释: SSL证书私钥内容 取值范围: 不涉及 |
| enc_certificate | String | 参数解释: 国密证书加密证书内容(国密证书使用双证书场景下必传) 取值范围: 不涉及 |
| enc_private_key | String | 参数解释: 国密证书加密私钥内容(国密证书使用双证书场景下必传) 取值范围: 不涉及 |
| scm_certificate_id | String | 参数解释: SCM证书ID,配置SCM证书时必传 取值范围: 不涉及 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| switch | Integer | 参数解释: 是否开启强制跳转,强制客户端使用HTTPS或HTTP协议访问CDN节点 取值范围: |
| redirect_type | String | 参数解释: 强制跳转类型 取值范围: |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| tls_version | String | 参数解释: 传输层安全性协议,即TLS版本配置 取值范围: 目前支持TLSv1.0/1.1/1.2/1.3四个版本的协议 |
| cipher_suite_group | String | 参数解释: 加密算法套件组 取值范围: |
| cipher_suite | String | 参数解释: 加密套件 取值范围: |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| type | String | 参数解释: 规则类型 取值范围: |
| content_type | String | 参数解释: 生效类型 取值范围: |
| content_value | String | 参数解释: 生效规则 取值范围: 不涉及 |
| area | String | 参数解释: 配置规则适用的区域 取值范围: 不涉及 |
| exception_ip | String | 参数解释: 例外IP,配置指定IP不执行当前规则 取值范围: 不涉及 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| status | String | 参数解释: 是否开启URL鉴权 取值范围: |
| type | String | 参数解释: 鉴权方式 取值范围: |
| expire_time | Integer | 参数解释: 鉴权URL的有效时间 取值范围: 0-31536000,单位:秒 |
| sign_method | String | 参数解释: 加密算法 取值范围: |
| match_type | String | 参数解释: 鉴权范围,指定哪些文件参与鉴权 取值范围: |
| match_rule | String | 参数解释: 鉴权文件匹配规则 取值范围: |
| inherit_config | InheritConfig object | 参数解释: 鉴权继承,为M3U8/MPD索引文件下的TS/MP4文件添加鉴权参数,解决因鉴权不通过导致的TS/MP4文件无法播放的问题 |
| key | String | 参数解释: 鉴权密钥 取值范围: |
| backup_key | String | 参数解释: 备选鉴权密钥,当需要替换密钥时,如果需要新旧密钥同时生效,可设置备KEY。主、备KEY之一鉴权通过即可正常访问 取值范围: |
| sign_arg | String | 参数解释: 用户url中携带的鉴权信息参数名 取值范围: |
| time_format | String | 参数解释: 时间格式 取值范围: |
| time_arg | String | 参数解释: 时间参数名称 取值范围: |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| status | String | 参数解释: 是否开启鉴权继承 取值范围: |
| inherit_type | String | 参数解释: 为m3u8/mpd索引文件下的ts/mp4文件添加鉴权参数,解决因鉴权不通过导致的ts/mp4文件无法播放的问题 取值范围: |
| inherit_time_type | String | 参数解释: 鉴权继承开始时间 取值范围: |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| rule_id | String | 参数解释: 规则id 取值范围: 不涉及 |
| name | String | 参数解释: 规则名称 取值范围: 不涉及 |
| status | String | 规则状态,on:开启,off:关闭。 |
| priority | Integer | 参数解释: 此条规则的优先级,数值越大,优先级越高。 取值范围: 1-1000 |
| conditions | Conditions object | 参数解释: 触发当前规则的条件 |
| actions | Array of Actions objects | 满足规则条件后执行的动作列表 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| logic | String | 参数解释: 逻辑运算符 取值范围: |
| criteria | Array of Criteria objects | 参数解释: 匹配条件列表,可包含多个匹配参数,当用户请求匹配了当前设置的条件规则时,将执行当前规则配置的操作。 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| match_target_type | String | 参数解释: 匹配目标类型 取值范围: |
| match_target_name | String | 参数解释: 匹配目标名称 取值范围: |
| match_type | String | 参数解释: 匹配算法 取值范围: contains:包含匹配,匹配到match_pattern任意一个条件即匹配成功 |
| match_pattern | Array of strings | 参数解释: 匹配内容,为字符串数组,具体取值取决于匹配目标类型: |
| negate | Boolean | 参数解释: 是否取反,与match_type配合使用。例:negate配置为true,match_type配置为contains,则实际业务逻辑将转换为not_contains 取值范围: |
| case_sensitive | Boolean | 参数解释: 是否区分大小写 取值范围: |
| logic | String | 参数解释: 嵌套条件逻辑运算符 取值范围: |
| criteria | Array of Criteria objects | 参数解释: 匹配条件列表,可包含多个匹配参数,当用户请求匹配了当前设置的条件规则时,将执行当前规则配置的操作。 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| flexible_origin | Array of flexibleOriginsEngine objects | 参数解释: 高级回源,实现根据不同的资源类型或路径回源到不同源站 |
| origin_request_header | Array of OriginRequestHeader objects | 参数解释: CDN节点回源时,改写用户回源请求URL的HTTP头部信息 |
| http_response_header | Array of HttpResponseHeader objects | 参数解释: 配置节点响应给客户端的头部信息,配置响应消息后,用户请求加速域名下的资源时,CDN返回给用户的消息中将包含该域名配置的响应头信息 |
| access_control | AccessControl object | 参数解释: 访问控制 |
| request_limit_rule | RequestLimitRulesEngine object | 参数解释: 请求限速,将用户请求速度限制在指定范围内,一定程度上减少突发高带宽风险,节省成本 |
| origin_request_url_rewrite | 参数解释: 改写回源URL | |
| cache_rule | CacheRulesEngine object | 参数解释: 通过不同参数控制源站资源在CDN节点的缓存时长 |
| request_url_rewrite | RequestUrlRewriteEngine object | 参数解释: 访问URL重写,当用户请求URL与CDN节点缓存资源的URL不一致时,可以通过访问URL重写功能重定向到目标URL |
| browser_cache_rule | BrowserCacheRulesEngine object | 参数解释: 浏览器缓存过期时间,当终端用户请求资源时,如果浏览器有缓存,直接返回给用户 |
| error_code_cache | Array of ErrorCodeCacheEngine objects | 参数解释: 将源站返回的错误状态码缓存到CDN节点,用户再次请求时由CDN直接响应给用户错误状态码 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| sources_type | String | 参数解释: 源站类型 取值范围: |
| ip_or_domain | String | 参数解释: 源站IP或者域名 取值范围: 不涉及 |
| obs_bucket_type | String | 参数解释: OBS桶类型 取值范围: |
| bucket_access_key | String | 参数解释: 第三方对象存储访问密钥 取值范围: 不涉及 |
| bucket_secret_key | String | 参数解释: 第三方对象存储密钥 取值范围: 不涉及 |
| bucket_region | String | 参数解释: 第三方对象存储区域 取值范围: 不涉及 |
| bucket_name | String | 参数解释: 第三方对象存储名称 取值范围: 不涉及 |
| host_name | String | 参数解释: 回源HOST 取值范围: 不涉及 |
| origin_protocol | String | 参数解释: 指定CDN回源时的请求协议 取值范围: |
| http_port | Integer | 参数解释: HTTP端口 取值范围: 1-65535 |
| https_port | Integer | 参数解释: HTTPS端口 取值范围: 1-65535 |
| priority | Integer | 参数解释: 优先级,值越大优先级越高 取值范围: 1-100 |
| weight | Integer | 参数解释: 权重,值越大回源到该源站的次数越多。多个优先级相同的源站,由权重决定回源到各个源站的比例 取值范围: 1-100 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| name | String | 参数解释: 设置回源请求头参数 取值范围: |
| value | String | 参数解释: 设置回源请求头参数的值 取值范围: |
| action | String | 参数解释: 回源请求头设置类型 取值范围: |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| name | String | 参数解释: 设置HTTP响应头参数 取值范围: |
| value | String | 参数解释: 设置HTTP响应头参数的值 取值范围: |
| action | String | 参数解释: 设置HTTP响应头操作类型 取值范围: |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| limit_rate_after | Long | 参数解释: 限速条件 说明: 例如:type=size,limit_rate_after=50表示从传输50个字节后开始限速且限速值为limit_rate_value 取值范围: 0-1073741824,单位:byte |
| limit_rate_value | Integer | 参数解释: 限速值,即达到限速条件后的最大访问速度 取值范围: 0-104857600,单位:Bps |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| rewrite_type | String | 参数解释: 改写方式 取值范围: |
| source_url | String | 参数解释: 需要替换的URI 取值范围: |
| target_url | String | 参数解释: 替换后的URI 取值范围: 说明: 通配符 * 可通过$n捕获(n=1,2,3...,例如:/newtest/$1/$2.jpg) |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| ttl | Integer | 参数解释: 资源在CDN节点的缓存过期时间 取值范围: 不涉及 |
| ttl_unit | String | 参数解释: 缓存过期时间单位 取值范围: |
| follow_origin | String | 参数解释: 缓存过期时间来源,设置CDN节点的缓存遵循源站还是CDN侧的配置 取值范围: |
| force_cache | String | 参数解释: 强制缓存:CDN节点缓存过期时间是否忽略源站响应头Cache-Control中的no-cache、private、no-store字段 取值范围: |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| rewrite_type | String | 参数解释: 改写方式 取值范围: |
| source_url | String | 参数解释: 需要替换的URI 取值范围: |
| redirect_status_code | Integer | 参数解释: 重定向状态码 取值范围: |
| redirect_url | String | 参数解释: 重定向URL 取值范围: 不涉及 |
| redirect_host | String | 参数解释: 支持将客户端请求重定向到其他域名 取值范围: |
| execution_mode | String | 参数解释: 执行规则 取值范围: |
| inherit_param | String | 参数解释: 重定向URL是否携带请求参数 取值范围: |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| cache_type | String | 参数解释: 缓存生效类型 取值范围: |
| ttl | Integer | 参数解释: 缓存过期时间 取值范围: 不涉及 |
| ttl_unit | String | 参数解释: 缓存过期时间单位 取值范围: |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| code | Integer | 参数解释: 需要缓存的错误码 取值范围: |
| ttl | Integer | 参数解释: 错误码缓存时间 取值范围: 0-31536000,单位:秒 说明: 3XX状态码缓存时间范围为0-20s |
状态码:400
| 参数 | 参数类型 | 描述 |
|---|---|---|
| error | ErrMsg object | 用于返回具体的错误码和错误消息 |
请求示例
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 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) } } |
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
| 状态码 | 描述 |
|---|---|
| 200 | 成功响应 |
| 400 | 异常响应 |
错误码
请参见错误码。