Modifying a Domain Name Template
Function
This API is used to modify a domain name template.
Calling Method
For details, see Calling APIs.
URI
PUT /v1.0/cdn/configuration/templates/{tml_id}
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
tml_id |
Yes |
String |
Definition Domain name template ID, which can be obtained by calling the API for listing domain name templates. Constraints N/A Range N/A Default Value N/A |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
tml_name |
Yes |
String |
Definition Domain name template name. Constraints N/A Range
Default Value N/A |
remark |
No |
String |
Definition Domain name template description. Constraints N/A Range N/A Default Value N/A |
configs |
Yes |
TemplateConfigs object |
Definition Domain name template configuration. Constraints N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
http_response_header |
No |
Array of HttpResponseHeader objects |
HTTP response header settings |
cache_rules |
No |
Array of CacheRules objects |
|
origin_follow302_status |
No |
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. Constraints N/A Range
Default Value N/A |
compress |
No |
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. Constraints N/A |
origin_range_status |
No |
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. Constraints To enable range requests for origin pull, the origin server must support range requests, that is, requests with the Range field in the headers. Otherwise, origin pull may fail. Range
Default Value N/A |
ip_filter |
No |
IpFilter object |
Definition IP access control list (ACL), which blocks or allows access from specific IP addresses. Constraints N/A |
referer |
No |
RefererConfig object |
Definition Referrer whitelist or whitelist, which identifies and filters user identities to control access. Constraints N/A |
user_agent_filter |
No |
UserAgentFilter object |
Definition User-Agent ACL, which filters out requests from specific proxies. Constraints N/A |
flow_limit_strategy |
No |
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.
Constraints N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
name |
Yes |
String |
Definition Name of an HTTP response header. Constraints N/A Range
Default Value N/A |
value |
No |
String |
Definition Value of the HTTP response header. Constraints N/A Range
Default Value N/A |
action |
Yes |
String |
Definition Operation type of the HTTP response header. Constraints
Range
Default Value N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
match_type |
Yes |
String |
Definition Match type. Constraints N/A Range
Default Value N/A |
match_value |
No |
String |
Definition Cache rule match content. Constraints
Range N/A Default Value N/A |
ttl |
No |
Integer |
Definition TTL of a resource cached on CDN PoPs. Constraints Up to 365 days. Range N/A Default Value 0 |
ttl_unit |
Yes |
String |
Definition Unit of the cache TTL. Constraints N/A Range
Default Value N/A |
priority |
Yes |
Integer |
Definition Cache rule priority. A larger value indicates a higher priority. Constraints The priority of a rule must be unique. Range 1 to 100. Default Value N/A |
follow_origin |
No |
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. Constraints N/A Range
Default Value off |
force_cache |
No |
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. Constraints Forcible cache is used together with cache TTL source. For details about the restrictions and configuration effect, see section "PoP Cache Rules" in the User Guide of CDN. Range
Default Value off |
url_parameter_type |
No |
String |
Definition URL parameter filtering. Constraints N/A Range
Default Value full_url |
url_parameter_value |
No |
String |
Definition URL parameters. Constraints
Range N/A Default Value N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
status |
Yes |
String |
Definition Smart compression status. Constraints N/A Range
Default Value N/A |
type |
No |
String |
Definition Smart compression type. Constraints If multiple smart compression types are configured, Brotli compression is used first. Range Separate smart compression types by commas (,).
Default Value N/A |
file_type |
No |
String |
Definition Types of files to compress. Constraints N/A Range
Default Value The default value is .js,.html,.css,.xml,.json,.shtml,.htm when smart compression is used for the first time. When this function is used again and this value is left empty, the result of the previous setting is used. |
compress_min_length |
No |
Integer |
Definition Minimum size of files to be compressed. Constraints CDN compresses files between 0 MB and 30 MB if no specific file size is set. Range
Default Value N/A |
compress_max_length |
No |
Integer |
Definition Maximum size of files to be compressed. Constraints CDN compresses files between 0 MB and 30 MB if no specific file size is set. Range
Default Value N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
type |
Yes |
String |
Definition IP ACL type. Constraints N/A Range
Default Value N/A |
value |
No |
String |
Definition IP ACL.
NOTE:
IPv6 is supported. IP addresses and CIDR blocks in the IP address/Subnet mask format are supported.
Constraints
Range N/A Default Value N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
type |
Yes |
String |
Definition Type of the referer blacklist or whitelist. Constraints N/A Range
Default Value N/A |
value |
No |
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.
Constraints
Range N/A Default Value N/A |
include_empty |
No |
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. Constraints N/A Range
Default Value false |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
type |
Yes |
String |
Definition User-Agent ACL type. Constraints N/A Range
Default Value N/A |
value |
No |
String |
Definition User-Agent ACL content.
NOTE:
This old parameter will be deprecated recently. Use ua_list to set a User-Agent ACL.
Constraints
Range
Default Value N/A |
include_empty |
No |
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. Constraints N/A Range true: Blank user agents are included. false: Blank user agents are not included. Default Value
|
ua_list |
No |
Array of strings |
Definition User-Agent ACL. Constraints
|
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
strategy_type |
No |
String |
Definition Measurement type. Constraints N/A Range
Default Value N/A |
item_type |
No |
String |
Definition Usage cap type. Constraints N/A Range
Default Value N/A |
limit_value |
No |
String |
Definition Usage cap. When the usage of a domain name reaches this cap, CDN will be disabled for it. Constraints N/A Range The value must be a positive integer. Default Value N/A |
alarm_percent_threshold |
No |
String |
Definition Usage alarm threshold. When the domain name usage reaches this threshold, an alarm is sent. Constraints N/A Range 1 to 90. Default Value N/A |
ban_time |
No |
String |
Definition Capping period. Constraints Setting ban_time to 0 indicates that the domain name is not automatically unblocked. You need to manually unblock it. Range
Default Value N/A |
Response Parameters
Status code: 204
Success response
Status code: default
Parameter |
Type |
Description |
---|---|---|
error |
ErrMsg object |
Error code and error message. |
Example Requests
PUT https://cdn.myhuaweicloud.com/v1.0/cdn/configuration/templates/example********************tmlid { "tml_name" : "example", "remark" : "example remark", "configs" : { "http_response_header" : [ { "action" : "set", "name" : "Content-Disposition", "value" : "example" } ] } }
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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
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.*; import java.util.List; import java.util.ArrayList; public class UpdateDomainTemplateSolution { 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(); UpdateDomainTemplateRequest request = new UpdateDomainTemplateRequest(); request.withTmlId("{tml_id}"); CreateTemplateRequestBody body = new CreateTemplateRequestBody(); [](model.HttpResponseHeader) listConfigsHttpResponseHeader = new ArrayList<>(); listConfigsHttpResponseHeader.add( new HttpResponseHeader() .withName("Content-Disposition") .withValue("example") .withAction("set") ); TemplateConfigs configsbody = new TemplateConfigs(); configsbody.withHttpResponseHeader(listConfigsHttpResponseHeader); body.withConfigs(configsbody); body.withRemark("example remark"); body.withTmlName("example"); request.withBody(body); try { UpdateDomainTemplateResponse response = client.updateDomainTemplate(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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# 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 = UpdateDomainTemplateRequest() request.tml_id = "{tml_id}" listHttpResponseHeaderConfigs = [ HttpResponseHeader( name="Content-Disposition", value="example", action="set" ) ] configsbody = TemplateConfigs( http_response_header=listHttpResponseHeaderConfigs ) request.body = CreateTemplateRequestBody( configs=configsbody, remark="example remark", tml_name="example" ) response = client.update_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 48 49 50 51 52 53 |
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.UpdateDomainTemplateRequest{} request.TmlId = "{tml_id}" valueHttpResponseHeader:= "example" var listHttpResponseHeaderConfigs = []model.HttpResponseHeader{ { Name: "Content-Disposition", Value: &valueHttpResponseHeader, Action: "set", }, } configsbody := &model.TemplateConfigs{ HttpResponseHeader: &listHttpResponseHeaderConfigs, } remarkCreateTemplateRequestBody:= "example remark" request.Body = &model.CreateTemplateRequestBody{ Configs: configsbody, Remark: &remarkCreateTemplateRequestBody, TmlName: "example", } response, err := client.UpdateDomainTemplate(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 |
---|---|
204 |
Success response |
default |
Abnormal response |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank 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