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
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| tml_name | No | String | Definition Domain name template name. Constraints N/A Range 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 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
| Parameter | Type | Description |
|---|---|---|
| total | Integer | Definition Total number of domain name templates. Range N/A |
| templates | Array of TemplateItem objects | Definition Template configuration. |
| Parameter | Type | Description |
|---|---|---|
| account_id | String | Definition Account ID. Range N/A |
| tml_name | String | Definition Domain name template name. Range |
| 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 |
| 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. |
| 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 |
| 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 |
| 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. |
| Parameter | Type | Description |
|---|---|---|
| name | String | Definition Name of an HTTP response header. Range |
| value | String | Definition Value of the HTTP response header. Range |
| 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 |
| Parameter | Type | Description |
|---|---|---|
| status | String | Definition Smart compression status. Range |
| type | String | Definition Smart compression type. Range Separate smart compression types by commas (,). |
| file_type | String | Definition Types of files to compress. Range .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 |
| compress_max_length | Integer | Definition Maximum size of files to be compressed. Range |
| Parameter | Type | Description |
|---|---|---|
| type | String | Definition IP ACL type. Range |
| 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. Range N/A |
| Parameter | Type | Description |
|---|---|---|
| type | String | Definition Type of the referer blacklist or whitelist. Range |
| 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 |
| Parameter | Type | Description |
|---|---|---|
| type | String | Definition User-Agent ACL type. Range |
| 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. Range |
| 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. |
| ua_list | Array of strings | Definition User-Agent ACL. type is set to off. |
| Parameter | Type | Description |
|---|---|---|
| strategy_type | String | Definition Measurement type. Range |
| item_type | String | Definition Usage cap type. Range |
| 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 |
Status code: 400
| Parameter | Type | Description |
|---|---|---|
| error | ErrMsg object | Error code and 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.
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot