Modifying the Full Domain Configuration
Function
This API is used to modify the domain name configuration. You can modify the service type, service area, remarks, IPv6, origin protocol, origin URL rewriting, advanced origin, range request, redirect from origin, ETag verification, origin response timeout, origin request header, HTTPS, TLS version, force redirect, HSTS, HTTP/2, OCSP stapling, QUIC, cache rule, status code cache TTL, referer validation, IP ACL, User-Agent ACL, token authentication, remote authentication, IP access frequency, HTTP header, custom error page, smart compression, request rate limiting, WebSocket, video seek, origin SNI, access URL rewriting, browser cache TTL, geo-blocking settings, and client certificate settings.
-
A single tenant can call this API 200 times per minute.
Calling Method
For details, see Calling APIs.
URI
PUT /v1.1/cdn/configuration/domains/{domain_name}/configs
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
domain_name |
Yes |
String |
Definition Acceleration domain name. Constraints N/A Range N/A Default Value N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
enterprise_project_id |
No |
String |
Definition Enterprise project ID. Obtain the enterprise project ID by calling the ListEnterpriseProject API of EPS. Constraints This parameter indicates the ID of the enterprise project to which the resource to be queried belongs. It is valid only when the enterprise project function is enabled. The value all indicates all projects. Range N/A Default Value N/A |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
Definition User token, which can be obtained by calling the IAM API (value of X-Subject-Token in the response header). Constraints N/A Range N/A Default Value N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
configs |
No |
Configs object |
Definition Configuration items. Constraints N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
business_type |
No |
String |
Definition Service type. Constraints Whole site acceleration cannot be changed to other service types. Range
Default Value N/A |
service_area |
No |
String |
Definition Service area of the acceleration domain name. Client access requests are scheduled to CDN PoPs in the service area. You can select a proper area based on your user location. Constraints
Range
Default Value N/A |
remark |
No |
String |
Definition Domain name remarks. Constraints N/A Range 0 to 10,000 characters. Default Value N/A |
origin_request_header |
No |
Array of OriginRequestHeader objects |
Definition Origin request headers. During origin pull, CDN PoPs perform operations on HTTP origin request headers based on your settings. Constraints
|
http_response_header |
No |
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. Constraints
|
url_auth |
No |
UrlAuth object |
Definition Token authentication, which protects your website resources from being downloaded by malicious users. Constraints N/A |
https |
No |
HttpPutBody object |
Definition Add a certificate on CDN PoPs to allow clients to access PoPs using HTTPS. Constraints N/A |
sources |
No |
Array of SourcesConfig objects |
Definition Origin server of the acceleration domain name. CDN caches origin content on PoPs so that your content loads faster. Constraints N/A |
origin_protocol |
No |
String |
Definition Request protocol for CDN origin pull. Constraints N/A Range
Default Value http |
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 |
cache_rules |
No |
Array of CacheRules objects |
Definition Parameters used to control the cache TTL of origin server resources on CDN PoPs. Constraints There must be a rule for all file types. |
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 |
force_redirect |
No |
ForceRedirectConfig object |
Definition This parameter is used to force clients to use HTTPS or HTTP when accessing CDN PoPs. Constraints 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 |
cache_url_parameter_filter |
No |
CacheUrlParameterFilter object |
Definition Settings of caching URL parameters.
NOTE:
This old parameter will be deprecated recently. You are advised to use CacheRules.
Constraints N/A |
ipv6_accelerate |
No |
Integer |
Definition Whether to enable IPv6 to allow clients to access CDN using IPv6. Constraints N/A Range
Default Value N/A |
error_code_cache |
No |
Array of ErrorCodeCache objects |
Definition You can cache error codes returned by the origin server on CDN PoPs. When users request the same resources, CDN directly returns the error codes to the users. 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 |
user_agent_filter |
No |
UserAgentFilter object |
Definition User-Agent ACL, which filters out requests from specific proxies. Constraints N/A |
origin_request_url_rewrite |
No |
Array of OriginRequestUrlRewrite objects |
Definition Origin URL rewrite rules. This ensures that an origin request URL matches the URL of the origin server content. Constraints Up to 20 rules. |
flexible_origin |
No |
Array of flexibleOrigins objects |
Definition Advanced origin rules. CDN can pull content from different origin servers by resource type or path. Constraints Up to 20 rules. |
slice_etag_status |
No |
String |
Definition Whether to verify the ETag during origin pull. After this function is enabled, when a user requests a cached content from a PoP again, the ETag value is added for determining whether the cache expires. Constraints N/A Range
Default Value N/A |
origin_receive_timeout |
No |
Integer |
Definition Timeout interval for CDN PoP origin pull. If this time expires, origin pull fails. Constraints N/A Range 5 to 300, in seconds. Default Value N/A |
remote_auth |
No |
commonRemoteAuth object |
Definition Remote authentication. CDN can forward user requests to the authentication server you specify and determine whether to return requested content to users based on the server response. Constraints N/A |
websocket |
No |
webSocketSeek object |
Definition Whether to allow clients to access CDN PoPs using WebSocket.
NOTE:
WebSocket works only for resources whose TTL is set to 0, TTL source is set to CDN, and forcible cache is enabled.
Constraints
|
video_seek |
No |
videoSeek object |
Definition Video seek settings. Users can seek to any position in a video without affecting the playback effect. Constraints
|
request_limit_rules |
No |
Array of RequestLimitRules objects |
Definition Request rate limiting. This limits the user request rate within a specific range to reduce costs and the risk of burst bandwidth. Constraints N/A |
ip_frequency_limit |
No |
IpFrequencyLimit object |
Definition IP access frequency. You can limit the number of times that a single IP address accesses a single PoP per second to defend against CC attacks and malicious theft.
NOTE:
When the threshold is reached, CDN returns status code 403. The restriction is removed 10 minutes later.
Constraints N/A |
hsts |
No |
Hsts object |
Definition HSTS, which forces clients (such as browsers) to use HTTPS to access your server, improving access security. Constraints N/A |
quic |
No |
Quic object |
Definition QUIC. Using QUIC to access CDN PoPs improves transmission security, reduces transmission and connection latency, and prevents network congestion. Constraints N/A |
error_code_redirect_rules |
No |
Array of ErrorCodeRedirectRules objects |
Definition Custom error page. When an error occurs during user access, CDN returns this error page to clients, optimizing user experience. Constraints N/A |
sni |
No |
Sni object |
Definition Origin SNI. If your origin server IP address is bound to multiple domain names and CDN visits the origin server using HTTPS, specify the domain name to be visited by CDN during handshake. Constraints N/A |
request_url_rewrite |
No |
Array of RequestUrlRewrite objects |
Definition Access URL rewrite rules, which are used to redirect user requests to the URLs of cached content. Constraints N/A |
browser_cache_rules |
No |
Array of BrowserCacheRules objects |
Definition Browser cache TTL, during which users can obtain content directly from their browser cache (if available). Constraints N/A |
access_area_filter |
No |
Array of AccessAreaFilter objects |
Definition Geo-blocking, which prevents users in certain geographical locations from accessing your content.
NOTE:
IP addresses belong to carriers and change irregularly. Although Huawei Cloud periodically updates the IP address library, the update may be delayed. As a result, some access control functions may occasionally block or allow requests, or client requests may not be scheduled to the optimal PoP.
Constraints N/A |
client_cert |
No |
ClientCert object |
Definition Client certificate, which enforces mutual certificate authentication between clients and CDN PoPs, securing website communication. Constraints N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
name |
Yes |
String |
Definition Name of an origin request header. Constraints N/A Range
Default Value N/A |
value |
No |
String |
Definition Value of the origin request header. Constraints N/A Range
Default Value N/A |
action |
Yes |
String |
Definition Operation type of the origin request header. Constraints
Range
Default Value 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 |
---|---|---|---|
status |
Yes |
String |
Definition Whether to enable token authentication. Constraints N/A Range
Default Value N/A |
type |
No |
String |
Definition Signing method. Constraints N/A Range
Default Value N/A |
expire_time |
No |
Integer |
Definition How long a signed URL remains effective. Constraints N/A Range 0 to 31,536,000, in seconds. Default Value N/A |
sign_method |
No |
String |
Definition Encryption algorithm. Constraints N/A Range
Default Value N/A |
match_type |
No |
String |
Definition Authentication scope, that is, files to authenticate. Constraints N/A Range
Default Value N/A |
match_rule |
No |
String |
Definition Rules for matching files to authenticate. Constraints N/A Range
Default Value N/A |
inherit_config |
No |
InheritConfig object |
Definition Authentication inheritance. Authentication parameters are added to TS and MP4 files under M3U8/MPD index files, so that the files can be played after authentication succeeds. Constraints N/A |
key |
No |
String |
Definition Authentication key. Constraints N/A Range
Default Value N/A |
backup_key |
No |
String |
Definition Secondary authentication key. If you want both the old and new keys to take effect, you can set the old key as the secondary key. Users can access content only after CDN verifies the primary or secondary key. Constraints N/A Range
Default Value N/A |
sign_arg |
No |
String |
Definition Authentication parameter carried in a URL. Constraints Mandatory when signing method A or C2 is used. Range
Default Value auth_key |
time_format |
No |
String |
Definition Time format. Constraints
Range
Default Value N/A |
time_arg |
No |
String |
Definition Time parameter name. Constraints Optional when signing method C2 is used. Range
Default Value timestamp |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
status |
Yes |
String |
Definition Whether to enable authentication inheritance. Constraints N/A Range
Default Value N/A |
inherit_type |
No |
String |
Definition Authentication inheritance settings. Constraints
Range
Default Value N/A |
inherit_time_type |
No |
String |
Definition Inheritance start time. Constraints This parameter is mandatory when authentication inheritance is enabled. Range
Default Value N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
https_status |
No |
String |
Definition Certificate status. Constraints N/A Range
Default Value N/A |
certificate_type |
No |
String |
Definition Certificate type. Constraints N/A Range
Default Value N/A |
certificate_source |
No |
Integer |
Definition Certificate source. Constraints Mandatory when a certificate is configured. Range
Default Value N/A |
scm_certificate_id |
No |
String |
Definition SCM certificate ID, which can be obtained using the CCM API for listing certificates. Constraints Mandatory when an SCM certificate is configured. Range N/A Default Value N/A |
certificate_name |
No |
String |
Definition Certificate name. Constraints
Range N/A Default Value N/A |
certificate_value |
No |
String |
Definition Certificate used by the HTTPS protocol. Constraints
Range The certificate chain cannot exceed 20 KB. Default Value N/A |
private_key |
No |
String |
Definition Private key used by the HTTPS protocol. Constraints
Range N/A Default Value N/A |
enc_certificate_value |
No |
String |
Definition Encryption certificate content. Constraints
Range N/A Default Value N/A |
enc_private_key |
No |
String |
Definition Encryption private key. Constraints
Range N/A Default Value N/A |
certificates |
No |
Array of CertificatesPutBody objects |
Definition Certificate configuration request body. Constraints
|
http2_status |
No |
String |
Definition Whether to enable HTTP/2 to allow clients to use HTTP/2 when accessing CDN PoPs. Constraints When https_status is set to off, this parameter does not take effect. Range
Default Value off |
tls_version |
No |
String |
Definition Transport Layer Security (TLS) protocol, that is, TLS version settings. Constraints
Range Range: TLSv1.0, TLSv1.1, TLSv1.2, and TLSv1.3. Default Value TLSv1.1,TLSv1.2,TLSv1.3 |
ocsp_stapling_status |
No |
String |
Definition Whether to enable OCSP stapling. Constraints N/A Range
Default Value N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
certificate_source |
No |
Integer |
Definition Certificate source. Constraints N/A Range
Default Value N/A |
scm_certificate_id |
No |
String |
Definition SCM certificate ID, which can be obtained using the CCM API for listing certificates. Constraints Mandatory when an SCM certificate is configured. Range N/A Default Value N/A |
certificate_type |
Yes |
String |
Definition Certificate type. Constraints N/A Range
Default Value N/A |
certificate_name |
Yes |
String |
Definition Certificate name. Constraints N/A Range 3 to 64 characters. Default Value N/A |
certificate_value |
Yes |
String |
Definition Certificate used by the HTTPS protocol. Constraints Only the PEM format is supported. Range N/A Default Value N/A |
private_key |
Yes |
String |
Definition Private key used by the HTTPS protocol. Constraints Only the PEM format is supported. Range N/A Default Value N/A |
enc_certificate_value |
No |
String |
Definition Encryption certificate content. Constraints
Range N/A Default Value N/A |
enc_private_key |
No |
String |
Definition Encryption private key. Constraints
Range N/A Default Value N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
origin_type |
Yes |
String |
Definition Origin server type. Constraints N/A Range
Default Value N/A |
origin_addr |
Yes |
String |
Definition IP address or domain name of the origin server. Constraints N/A Range N/A Default Value N/A |
priority |
Yes |
Integer |
Definition Origin server priority. Constraints N/A Range 1 to 100. Default Value N/A |
weight |
No |
Integer |
Definition Weight. Constraints N/A Range 1 to 100. Default Value N/A |
obs_web_hosting_status |
No |
String |
Definition Whether to enable OBS static website hosting. Constraints Mandatory when the origin server type is set to obs_bucket. Range
Default Value N/A |
http_port |
No |
Integer |
Definition HTTP port. Constraints N/A Range 1 to 65,535. Default Value 80 |
https_port |
No |
Integer |
Definition HTTPS port. Constraints N/A Range 1 to 65,535. Default Value 443 |
host_name |
No |
String |
Definition Host header. Constraints N/A Range N/A Default Value Acceleration domain name. |
obs_bucket_type |
No |
String |
Definition OBS pull authentication status. This function applies when an OBS bucket is used as an origin server. Enable the function if access to the bucket requires authentication. In this way, CDN PoPs carry the authentication information during origin pull. If the information does not match the OBS bucket, origin pull fails, preventing unauthorized traffic theft. Constraints Mandatory when the origin server is an OBS bucket. Range
Default Value public |
bucket_access_key |
No |
String |
Definition Access key ID (AK) for accessing the third-party bucket. Constraints Mandatory when the origin server is a third-party bucket. Range N/A Default Value N/A |
bucket_secret_key |
No |
String |
Definition Secret access key (SK) for accessing the third-party bucket. Constraints Mandatory when the origin server is a third-party bucket. Range N/A Default Value N/A |
bucket_region |
No |
String |
Definition Region of the third-party bucket. Constraints Mandatory when the origin server is a third-party bucket. Range N/A Default Value N/A |
bucket_name |
No |
String |
Definition Name of the third-party bucket. Constraints Mandatory when the origin server is a third-party bucket. Range N/A 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 |
---|---|---|---|
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 |
---|---|---|---|
status |
Yes |
String |
Definition Force redirect status. Constraints N/A Range
Default Value N/A |
type |
No |
String |
Definition Protocol to which requests are forcibly redirected. Constraints If force redirect to HTTPS is enabled, an HTTPS certificate must be configured. Otherwise, the access will fail. Range
Default Value N/A |
redirect_code |
No |
Integer |
Definition Redirect status code. Constraints N/A Range
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 |
No |
String |
Definition Operation type of URL parameters, that is, the URL parameters to cache when a resource is cached. Constraints N/A Range
NOTE:
The following parameters of this API are adjusted:
Replaced del_args with del_params. Replaced reserve_args with reserve_params. Default Value N/A |
value |
No |
String |
Definition URL parameters. Constraints Separate parameters by semicolons (;). Range N/A Default Value N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
code |
No |
Integer |
Definition Error codes to cache. Constraints N/A Range
Default Value N/A |
ttl |
No |
Integer |
Definition Error code cache TTL. Constraints N/A Range 0 to 31,536,000, in seconds.
NOTE:
The cache TTL of 3XX status codes ranges from 0s to 20s.
Default Value N/A |
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 |
---|---|---|---|
priority |
Yes |
Integer |
Definition Priority of a URL rewrite rule.
NOTE:
A larger value indicates a higher priority. CDN executes the URL rewrite rule with a higher priority.
Constraints
Range 1 to 100. Default Value N/A |
match_type |
Yes |
String |
Definition Match type. Constraints N/A Range
Default Value N/A |
source_url |
No |
String |
Definition URI to rewrite. Constraints If the match mode is set to all files, this parameter cannot be configured. Range
Default Value N/A |
target_url |
Yes |
String |
Definition URI after rewrite. Constraints Range
NOTE:
The nth wildcard (*) field can be captured by $n, where n = 1, 2, 3, .... Example: /newtest/$1/$2.jpg.
Default Value N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
match_type |
Yes |
String |
Definition URI match mode. Constraints N/A Range
Default Value N/A |
match_pattern |
Yes |
String |
Definition URI match rule. Constraints When match_type is set to file_extension:
When match_type is set to file_path:
NOTE:
File types are case-sensitive.
Range 1 to 512 characters. Default Value N/A |
priority |
Yes |
Integer |
Definition Priority.
NOTE:
A larger value indicates a higher priority.
Constraints N/A Range 1 to 100. Default Value N/A |
back_sources |
Yes |
Array of backSources objects |
Definition Origin server accessed by CDN PoPs for origin pull when a client request matches this rule. Constraints Only one origin server in each rule. Range N/A Default Value N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
sources_type |
Yes |
String |
Definition Origin server type. Constraints N/A Range
Default Value N/A |
ip_or_domain |
Yes |
String |
Definition IP address or domain name of the origin server. Constraints N/A Range N/A Default Value N/A |
obs_bucket_type |
No |
String |
Definition OBS bucket type. Constraints N/A Range
Default Value public |
http_port |
No |
Integer |
Definition HTTP port. Constraints N/A Range 1 to 65,535. Default Value 80 |
https_port |
No |
Integer |
Definition HTTPS port. Constraints N/A Range 1 to 65,535. Default Value 443 |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
remote_authentication |
Yes |
String |
Definition Whether to enable remote authentication. Constraints N/A Range
Default Value N/A |
remote_auth_rules |
Yes |
RemoteAuthRule object |
Definition Remote authentication settings. Constraints N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
auth_server |
Yes |
String |
Definition Address of a reachable authentication server. Constraints
Range N/A Default Value N/A |
request_method |
Yes |
String |
Definition Request method supported by the authentication server. Constraints N/A Range
Default Value N/A |
file_type_setting |
Yes |
String |
Definition Range of files to authenticate. Constraints N/A Range
NOTE:
File types are case-insensitive. For example, jpg and JPG indicate the same file type. File types are separated by vertical bars (|).
Default Value N/A |
specified_file_type |
No |
String |
Definition Types of files to authenticate. Constraints
Range
Default Value N/A |
reserve_args_setting |
Yes |
String |
Definition Whether to retain or ignore parameters for authentication. Constraints N/A Range
Default Value N/A |
reserve_args |
No |
String |
Definition Parameters. Constraints
Range N/A Default Value N/A |
add_custom_args_rules |
No |
Array of customArgs objects |
Definition Parameters to be added when CDN PoPs forward user requests to the remote authentication server. Constraints N/A Range N/A Default Value N/A |
reserve_headers_setting |
Yes |
String |
Definition Whether to retain or ignore request headers when CDN PoPs forward user requests to the remote authentication server. Constraints N/A Range
Default Value N/A |
add_custom_headers_rules |
No |
Array of customArgs objects |
Definition Request headers to authenticate. Constraints N/A Range N/A Default Value N/A |
auth_success_status |
Yes |
String |
Definition Status code returned by the remote authentication server to CDN PoPs when authentication is successful. Constraints N/A Range
Default Value N/A |
auth_failed_status |
Yes |
String |
Definition Status code returned by the remote authentication server to CDN PoPs when authentication fails. Constraints N/A Range
Default Value N/A |
response_status |
Yes |
String |
Definition Status code returned by CDN PoPs to users when authentication fails. Constraints N/A Range
Default Value N/A |
timeout |
Yes |
Integer |
Definition Authentication timeout interval, that is, the interval from the time when a CDN PoP forwards an authentication request to the time when the CDN PoP receives the result returned by the remote authentication server. Constraints N/A Range 0 or 50 to 3,000, in milliseconds. Default Value N/A |
timeout_action |
Yes |
String |
Definition Method used by CDN PoPs to process a user request after authentication times out. Constraints N/A Range
Default Value N/A |
reserve_headers |
No |
String |
Definition Request headers to retain. Constraints
Range N/A Default Value N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
type |
Yes |
String |
Definition Parameter type. Constraints N/A Range
Default Value N/A |
key |
Yes |
String |
Definition Parameter name. Constraints N/A Range
Default Value N/A |
value |
Yes |
String |
Definition Parameter value. Constraints N/A Range
Default Value N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
status |
Yes |
String |
Definition Whether to enable the WebSocket protocol. Constraints N/A Range
Default Value N/A |
timeout |
No |
Integer |
Definition Duration for keeping a connection open. Constraints N/A Range 1 to 300, in seconds. This parameter is mandatory when status is set to on. Default Value N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
enable_video_seek |
Yes |
Boolean |
Definition Video seek status. Constraints When this parameter is set to false, the API for querying domain name configuration does not return the video seek settings. Range
Default Value N/A |
enable_flv_by_time_seek |
No |
Boolean |
Definition Time-based FLV seek status. Constraints N/A Range
Default Value N/A |
start_parameter |
No |
String |
Definition Start parameter of video playback in URLs requested by users. Constraints N/A Range
Default Value N/A |
end_parameter |
No |
String |
Definition End parameter of video playback in URLs requested by users. Constraints N/A Range
Default Value N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
status |
No |
String |
Definition Whether to enable request rate limiting.
NOTE:
Constraints If request_limit_rules is left empty, request rate limiting is disabled. Range on Default Value N/A |
priority |
Yes |
Integer |
Definition Priority.
NOTE:
A larger value indicates a higher priority.
Constraints The priority of a rule must be unique. Range 1 to 100. Default Value N/A |
match_type |
Yes |
String |
Definition Match type. Constraints N/A Range
Default Value N/A |
match_value |
No |
String |
Definition Match type value. Constraints
Range N/A Default Value N/A |
type |
Yes |
String |
Definition Rate limit mode. Constraints Currently, only rate limit by traffic is supported. This parameter can only be set to size. Range N/A Default Value N/A |
limit_rate_after |
Yes |
Long |
Definition Rate limit condition.
NOTE:
For example, type=size,limit_rate_after=50 indicates that the speed is limited to the value of limit_rate_value after 50 bytes are transmitted.
Constraints N/A Range 0 to 1,073,741,824, in bytes. Default Value N/A |
limit_rate_value |
Yes |
Integer |
Definition Rate limit, that is, the maximum access speed after the rate limit is reached. Constraints N/A Range 0 to 104,857,600, in bit/s. Default Value N/A |
limit_time |
No |
String |
Definition Periods when the rate is limited. Constraints
Range N/A Default Value 0000-2400 |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
status |
Yes |
String |
Definition IP access frequency status. Constraints N/A Range
Default Value N/A |
qps |
No |
Integer |
Definition Access threshold. Constraints This parameter is mandatory when IP access frequency is enabled. Range 1 to 100,000, in requests per second. Default Value N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
status |
Yes |
String |
Definition HSTS status. Constraints N/A Range
Default Value N/A |
max_age |
No |
Integer |
Definition Expiration time, that is, the TTL of the response header Strict-Transport-Security on clients. Constraints This parameter is mandatory when status is set to on. Range 0 to 63,072,000, in seconds. Default Value N/A |
include_subdomains |
No |
String |
Definition Whether to include subdomain names. Constraints This parameter is mandatory when status is set to on. Range
Default Value N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
status |
Yes |
String |
Definition QUIC status. Constraints N/A Range
Default Value N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
error_code |
Yes |
Integer |
Definition Redirection error code. Constraints N/A Range
Default Value N/A |
target_code |
Yes |
Integer |
Definition Redirection status code. Constraints N/A Range
Default Value N/A |
target_link |
Yes |
String |
Definition Destination URL. Constraints Start with http:// or https://. Range N/A Default Value N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
status |
Yes |
String |
Definition Whether to enable origin SNI. Constraints N/A Range
Default Value N/A |
server_name |
No |
String |
Definition SNI domain name used for HTTPS handshake during CDN PoP origin pull. Constraints
Range
Default Value |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
condition |
Yes |
UrlRewriteCondition object |
Definition Match condition. Constraints N/A Range N/A Default Value N/A |
redirect_status_code |
No |
Integer |
Definition Redirection status code. Constraints N/A Range
Default Value N/A |
redirect_url |
Yes |
String |
Definition Redirection URL. Constraints
Range N/A Default Value N/A |
redirect_host |
No |
String |
Definition Domain name to which client requests are redirected. Constraints N/A Range
Default Value Acceleration domain name. |
execution_mode |
Yes |
String |
Definition Action. Constraints N/A 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 |
Yes |
String |
Definition Match content. Constraints
Range N/A Default Value N/A |
priority |
Yes |
Integer |
Definition Priority of the access URL rewrite rule.
NOTE:
A larger value indicates a higher priority.
Constraints The priority of a rule must be unique. Range 1 to 100. Default Value N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
condition |
Yes |
BrowserCacheRulesCondition object |
Definition Match condition. Constraints N/A Range N/A Default Value N/A |
cache_type |
Yes |
String |
Definition Cache effective type. Constraints N/A Range
Default Value N/A |
ttl |
No |
Integer |
Definition Cache TTL. Constraints
Range N/A Default Value N/A |
ttl_unit |
No |
String |
Definition Unit of the cache TTL. Constraints Mandatory when the cache effective type is set to ttl. 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 content based on the cache rule. Constraints
Range N/A Default Value N/A |
priority |
Yes |
Integer |
Definition Priority of the browser cache rule. A larger value indicates a higher priority. Constraints The priority of a rule must be unique. Range N/A Default Value 1 to 100. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
type |
Yes |
String |
Definition Rule type. Constraints N/A Range
Default Value N/A |
content_type |
Yes |
String |
Definition Content type. Constraints N/A Range
Default Value N/A |
content_value |
No |
String |
Definition Rule. Constraints
Range N/A Default Value N/A |
area |
Yes |
String |
Definition Regions to which the rule applies. Constraints
Range N/A Default Value N/A |
exception_ip |
No |
String |
Definition Exception IP addresses excluded from this rule. Constraints N/A Range N/A Default Value N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
status |
Yes |
String |
Definition Client certificate status. Constraints N/A Range
Default Value N/A |
trusted_cert |
Yes |
String |
Definition Content of the client CA certificate. Constraints Only the PEM format is supported. Range N/A Default Value N/A |
hosts |
No |
String |
Definition Domain names specified in the client CA certificate. Constraints
Range N/A Default Value N/A |
Response Parameters
Status code: 204
Request succeeded.
None
Example Requests
PUT https://cdn.myhuaweicloud.com/v1.1/cdn/configuration/domains/www.example.com/configs { "configs" : { "origin_request_header" : [ { "name" : "test-name", "value" : "test_value", "action" : "set" } ], "http_response_header" : [ { "name" : "test-name", "value" : "test_value", "action" : "set" } ], "url_auth" : { "status" : "off" }, "compress" : { "status" : "off" }, "force_redirect" : { "status" : "on", "type" : "http", "redirect_code" : 301 }, "origin_protocol" : "follow", "referer" : { "type" : "black", "value" : "192.168.0.0", "include_empty" : true }, "ip_filter" : { "type" : "black", "value" : "192.168.0.0" }, "origin_follow302_status" : "off", "cache_rules" : [ { "match_type" : "file_extension", "match_value" : ".zip", "ttl" : 0, "ttl_unit" : "h", "priority" : 10, "follow_origin" : "off", "url_parameter_type" : "del_params", "url_parameter_value" : "test_param" } ], "sources" : [ { "origin_addr" : "www.example.com", "origin_type" : "domain", "priority" : 70, "http_port" : 80, "https_port" : 443 } ], "flexible_origin" : [ { "priority" : 1, "match_type" : "file_path", "match_pattern" : "/test", "back_sources" : [ { "sources_type" : "domain", "ip_or_domain" : "www.back.example.com" } ] } ], "slice_etag_status" : "off", "ipv6_accelerate" : 1, "origin_receive_timeout" : 30, "remote_auth" : { "remote_authentication" : "on", "remote_auth_rules" : { "auth_server" : "https://192.168.0.0", "request_method" : "GET", "file_type_setting" : "all", "reserve_args_setting" : "reserve_all_args", "reserve_headers_setting" : "reserve_specific_headers", "auth_success_status" : "200", "auth_failed_status" : "403", "response_status" : "403", "timeout" : 500, "timeout_action" : "pass", "reserve_headers" : "sf", "add_custom_args_rules" : [ { "type" : "nginx_preset_var", "key" : "http_host", "value" : "$http_host" } ], "add_custom_headers_rules" : [ { "type" : "nginx_preset_var", "key" : "http_host", "value" : "$http_host" } ] } }, "websocket" : { "status" : "on", "timeout" : 60 }, "video_seek" : { "enable_video_seek" : true, "enable_flv_by_time_seek" : true, "start_parameter" : "start", "end_parameter" : "end" }, "request_limit_rules" : [ { "status" : "on", "match_type" : "catalog", "match_value" : "/test", "type" : "size", "limit_rate_after" : 1024, "limit_rate_value" : 50, "priority" : 88 } ], "sni" : { "status" : "on", "server_name" : "test.example.com" }, "request_url_rewrite" : [ { "condition" : { "match_type" : "full_path", "match_value" : "/test/*.jpg", "priority" : 10 }, "redirect_status_code" : 301, "redirect_url" : "/test/index.html", "redirect_host" : "http://www.example.com", "execution_mode" : "redirect" } ], "browser_cache_rules" : [ { "condition" : { "match_type" : "full_path", "match_value" : "/test/*.jpg", "priority" : 10 }, "cache_type" : "ttl", "ttl" : 20, "ttl_unit" : "h" } ], "access_area_filter" : [ { "type" : "black", "content_type" : "all", "area" : "CN_IN,AU", "exception_ip" : "0.0.0.0" } ], "client_cert" : { "status" : "on", "trusted_cert" : "certificate_example", "hosts" : "www.example.com" } } }
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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
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 UpdateDomainFullConfigSolution { 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(); UpdateDomainFullConfigRequest request = new UpdateDomainFullConfigRequest(); request.withDomainName("{domain_name}"); ModifyDomainConfigRequestBody body = new ModifyDomainConfigRequestBody(); ClientCert clientCertConfigs = new ClientCert(); clientCertConfigs.withStatus("on") .withTrustedCert("certificate_example") .withHosts("www.example.com"); List<AccessAreaFilter> listConfigsAccessAreaFilter = new ArrayList<>(); listConfigsAccessAreaFilter.add( new AccessAreaFilter() .withType("black") .withContentType("all") .withArea("CN_IN,AU") .withExceptionIp("0.0.0.0") ); BrowserCacheRulesCondition conditionBrowserCacheRules = new BrowserCacheRulesCondition(); conditionBrowserCacheRules.withMatchType("full_path") .withMatchValue("/test/*.jpg") .withPriority(10); List<BrowserCacheRules> listConfigsBrowserCacheRules = new ArrayList<>(); listConfigsBrowserCacheRules.add( new BrowserCacheRules() .withCondition(conditionBrowserCacheRules) .withCacheType("ttl") .withTtl(20) .withTtlUnit("h") ); UrlRewriteCondition conditionRequestUrlRewrite = new UrlRewriteCondition(); conditionRequestUrlRewrite.withMatchType("full_path") .withMatchValue("/test/*.jpg") .withPriority(10); List<RequestUrlRewrite> listConfigsRequestUrlRewrite = new ArrayList<>(); listConfigsRequestUrlRewrite.add( new RequestUrlRewrite() .withCondition(conditionRequestUrlRewrite) .withRedirectStatusCode(301) .withRedirectUrl("/test/index.html") .withRedirectHost("http://www.example.com") .withExecutionMode("redirect") ); Sni sniConfigs = new Sni(); sniConfigs.withStatus("on") .withServerName("test.example.com"); List<RequestLimitRules> listConfigsRequestLimitRules = new ArrayList<>(); listConfigsRequestLimitRules.add( new RequestLimitRules() .withStatus("on") .withPriority(88) .withMatchType("catalog") .withMatchValue("/test") .withType("size") .withLimitRateAfter(1024L) .withLimitRateValue(50) ); VideoSeek videoSeekConfigs = new VideoSeek(); videoSeekConfigs.withEnableVideoSeek(true) .withEnableFlvByTimeSeek(true) .withStartParameter("start") .withEndParameter("end"); WebSocketSeek websocketConfigs = new WebSocketSeek(); websocketConfigs.withStatus("on") .withTimeout(60); List<CustomArgs> listRemoteAuthRulesAddCustomHeadersRules = new ArrayList<>(); listRemoteAuthRulesAddCustomHeadersRules.add( new CustomArgs() .withType("nginx_preset_var") .withKey("http_host") .withValue("$http_host") ); List<CustomArgs> listRemoteAuthRulesAddCustomArgsRules = new ArrayList<>(); listRemoteAuthRulesAddCustomArgsRules.add( new CustomArgs() .withType("nginx_preset_var") .withKey("http_host") .withValue("$http_host") ); RemoteAuthRule remoteAuthRulesRemoteAuth = new RemoteAuthRule(); remoteAuthRulesRemoteAuth.withAuthServer("https://192.168.0.0") .withRequestMethod("GET") .withFileTypeSetting("all") .withReserveArgsSetting("reserve_all_args") .withAddCustomArgsRules(listRemoteAuthRulesAddCustomArgsRules) .withReserveHeadersSetting("reserve_specific_headers") .withAddCustomHeadersRules(listRemoteAuthRulesAddCustomHeadersRules) .withAuthSuccessStatus("200") .withAuthFailedStatus("403") .withResponseStatus("403") .withTimeout(500) .withTimeoutAction("pass") .withReserveHeaders("sf"); CommonRemoteAuth remoteAuthConfigs = new CommonRemoteAuth(); remoteAuthConfigs.withRemoteAuthentication("on") .withRemoteAuthRules(remoteAuthRulesRemoteAuth); List<BackSources> listFlexibleOriginBackSources = new ArrayList<>(); listFlexibleOriginBackSources.add( new BackSources() .withSourcesType("domain") .withIpOrDomain("www.back.example.com") ); List<FlexibleOrigins> listConfigsFlexibleOrigin = new ArrayList<>(); listConfigsFlexibleOrigin.add( new FlexibleOrigins() .withMatchType("file_path") .withMatchPattern("/test") .withPriority(1) .withBackSources(listFlexibleOriginBackSources) ); Compress compressConfigs = new Compress(); compressConfigs.withStatus("off"); ForceRedirectConfig forceRedirectConfigs = new ForceRedirectConfig(); forceRedirectConfigs.withStatus("on") .withType("http") .withRedirectCode(301); RefererConfig refererConfigs = new RefererConfig(); refererConfigs.withType("black") .withValue("192.168.0.0") .withIncludeEmpty(true); IpFilter ipFilterConfigs = new IpFilter(); ipFilterConfigs.withType("black") .withValue("192.168.0.0"); List<CacheRules> listConfigsCacheRules = new ArrayList<>(); listConfigsCacheRules.add( new CacheRules() .withMatchType("file_extension") .withMatchValue(".zip") .withTtl(0) .withTtlUnit("h") .withPriority(10) .withFollowOrigin("off") .withUrlParameterType("del_params") .withUrlParameterValue("test_param") ); List<SourcesConfig> listConfigsSources = new ArrayList<>(); listConfigsSources.add( new SourcesConfig() .withOriginType("domain") .withOriginAddr("www.example.com") .withPriority(70) .withHttpPort(80) .withHttpsPort(443) ); UrlAuth urlAuthConfigs = new UrlAuth(); urlAuthConfigs.withStatus("off"); List<HttpResponseHeader> listConfigsHttpResponseHeader = new ArrayList<>(); listConfigsHttpResponseHeader.add( new HttpResponseHeader() .withName("test-name") .withValue("test_value") .withAction("set") ); List<OriginRequestHeader> listConfigsOriginRequestHeader = new ArrayList<>(); listConfigsOriginRequestHeader.add( new OriginRequestHeader() .withName("test-name") .withValue("test_value") .withAction("set") ); Configs configsbody = new Configs(); configsbody.withOriginRequestHeader(listConfigsOriginRequestHeader) .withHttpResponseHeader(listConfigsHttpResponseHeader) .withUrlAuth(urlAuthConfigs) .withSources(listConfigsSources) .withOriginProtocol("follow") .withOriginFollow302Status("off") .withCacheRules(listConfigsCacheRules) .withIpFilter(ipFilterConfigs) .withReferer(refererConfigs) .withForceRedirect(forceRedirectConfigs) .withCompress(compressConfigs) .withIpv6Accelerate(1) .withFlexibleOrigin(listConfigsFlexibleOrigin) .withSliceEtagStatus("off") .withOriginReceiveTimeout(30) .withRemoteAuth(remoteAuthConfigs) .withWebsocket(websocketConfigs) .withVideoSeek(videoSeekConfigs) .withRequestLimitRules(listConfigsRequestLimitRules) .withSni(sniConfigs) .withRequestUrlRewrite(listConfigsRequestUrlRewrite) .withBrowserCacheRules(listConfigsBrowserCacheRules) .withAccessAreaFilter(listConfigsAccessAreaFilter) .withClientCert(clientCertConfigs); body.withConfigs(configsbody); request.withBody(body); try { UpdateDomainFullConfigResponse response = client.updateDomainFullConfig(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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
# 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 = UpdateDomainFullConfigRequest() request.domain_name = "{domain_name}" clientCertConfigs = ClientCert( status="on", trusted_cert="certificate_example", hosts="www.example.com" ) listAccessAreaFilterConfigs = [ AccessAreaFilter( type="black", content_type="all", area="CN_IN,AU", exception_ip="0.0.0.0" ) ] conditionBrowserCacheRules = BrowserCacheRulesCondition( match_type="full_path", match_value="/test/*.jpg", priority=10 ) listBrowserCacheRulesConfigs = [ BrowserCacheRules( condition=conditionBrowserCacheRules, cache_type="ttl", ttl=20, ttl_unit="h" ) ] conditionRequestUrlRewrite = UrlRewriteCondition( match_type="full_path", match_value="/test/*.jpg", priority=10 ) listRequestUrlRewriteConfigs = [ RequestUrlRewrite( condition=conditionRequestUrlRewrite, redirect_status_code=301, redirect_url="/test/index.html", redirect_host="http://www.example.com", execution_mode="redirect" ) ] sniConfigs = Sni( status="on", server_name="test.example.com" ) listRequestLimitRulesConfigs = [ RequestLimitRules( status="on", priority=88, match_type="catalog", match_value="/test", type="size", limit_rate_after=1024, limit_rate_value=50 ) ] videoSeekConfigs = VideoSeek( enable_video_seek=True, enable_flv_by_time_seek=True, start_parameter="start", end_parameter="end" ) websocketConfigs = WebSocketSeek( status="on", timeout=60 ) listAddCustomHeadersRulesRemoteAuthRules = [ CustomArgs( type="nginx_preset_var", key="http_host", value="$http_host" ) ] listAddCustomArgsRulesRemoteAuthRules = [ CustomArgs( type="nginx_preset_var", key="http_host", value="$http_host" ) ] remoteAuthRulesRemoteAuth = RemoteAuthRule( auth_server="https://192.168.0.0", request_method="GET", file_type_setting="all", reserve_args_setting="reserve_all_args", add_custom_args_rules=listAddCustomArgsRulesRemoteAuthRules, reserve_headers_setting="reserve_specific_headers", add_custom_headers_rules=listAddCustomHeadersRulesRemoteAuthRules, auth_success_status="200", auth_failed_status="403", response_status="403", timeout=500, timeout_action="pass", reserve_headers="sf" ) remoteAuthConfigs = CommonRemoteAuth( remote_authentication="on", remote_auth_rules=remoteAuthRulesRemoteAuth ) listBackSourcesFlexibleOrigin = [ BackSources( sources_type="domain", ip_or_domain="www.back.example.com" ) ] listFlexibleOriginConfigs = [ FlexibleOrigins( match_type="file_path", match_pattern="/test", priority=1, back_sources=listBackSourcesFlexibleOrigin ) ] compressConfigs = Compress( status="off" ) forceRedirectConfigs = ForceRedirectConfig( status="on", type="http", redirect_code=301 ) refererConfigs = RefererConfig( type="black", value="192.168.0.0", include_empty=True ) ipFilterConfigs = IpFilter( type="black", value="192.168.0.0" ) listCacheRulesConfigs = [ CacheRules( match_type="file_extension", match_value=".zip", ttl=0, ttl_unit="h", priority=10, follow_origin="off", url_parameter_type="del_params", url_parameter_value="test_param" ) ] listSourcesConfigs = [ SourcesConfig( origin_type="domain", origin_addr="www.example.com", priority=70, http_port=80, https_port=443 ) ] urlAuthConfigs = UrlAuth( status="off" ) listHttpResponseHeaderConfigs = [ HttpResponseHeader( name="test-name", value="test_value", action="set" ) ] listOriginRequestHeaderConfigs = [ OriginRequestHeader( name="test-name", value="test_value", action="set" ) ] configsbody = Configs( origin_request_header=listOriginRequestHeaderConfigs, http_response_header=listHttpResponseHeaderConfigs, url_auth=urlAuthConfigs, sources=listSourcesConfigs, origin_protocol="follow", origin_follow302_status="off", cache_rules=listCacheRulesConfigs, ip_filter=ipFilterConfigs, referer=refererConfigs, force_redirect=forceRedirectConfigs, compress=compressConfigs, ipv6_accelerate=1, flexible_origin=listFlexibleOriginConfigs, slice_etag_status="off", origin_receive_timeout=30, remote_auth=remoteAuthConfigs, websocket=websocketConfigs, video_seek=videoSeekConfigs, request_limit_rules=listRequestLimitRulesConfigs, sni=sniConfigs, request_url_rewrite=listRequestUrlRewriteConfigs, browser_cache_rules=listBrowserCacheRulesConfigs, access_area_filter=listAccessAreaFilterConfigs, client_cert=clientCertConfigs ) request.body = ModifyDomainConfigRequestBody( configs=configsbody ) response = client.update_domain_full_config(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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 |
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.UpdateDomainFullConfigRequest{} request.DomainName = "{domain_name}" hostsClientCert:= "www.example.com" clientCertConfigs := &model.ClientCert{ Status: "on", TrustedCert: "certificate_example", Hosts: &hostsClientCert, } typeAccessAreaFilter:= "black" contentTypeAccessAreaFilter:= "all" areaAccessAreaFilter:= "CN_IN,AU" exceptionIpAccessAreaFilter:= "0.0.0.0" var listAccessAreaFilterConfigs = []model.AccessAreaFilter{ { Type: &typeAccessAreaFilter, ContentType: &contentTypeAccessAreaFilter, Area: &areaAccessAreaFilter, ExceptionIp: &exceptionIpAccessAreaFilter, }, } matchValueCondition:= "/test/*.jpg" conditionBrowserCacheRules := &model.BrowserCacheRulesCondition{ MatchType: "full_path", MatchValue: &matchValueCondition, Priority: int32(10), } ttlBrowserCacheRules:= int32(20) ttlUnitBrowserCacheRules:= "h" var listBrowserCacheRulesConfigs = []model.BrowserCacheRules{ { Condition: conditionBrowserCacheRules, CacheType: "ttl", Ttl: &ttlBrowserCacheRules, TtlUnit: &ttlUnitBrowserCacheRules, }, } conditionRequestUrlRewrite := &model.UrlRewriteCondition{ MatchType: "full_path", MatchValue: "/test/*.jpg", Priority: int32(10), } redirectStatusCodeRequestUrlRewrite:= int32(301) redirectHostRequestUrlRewrite:= "http://www.example.com" var listRequestUrlRewriteConfigs = []model.RequestUrlRewrite{ { Condition: conditionRequestUrlRewrite, RedirectStatusCode: &redirectStatusCodeRequestUrlRewrite, RedirectUrl: "/test/index.html", RedirectHost: &redirectHostRequestUrlRewrite, ExecutionMode: "redirect", }, } serverNameSni:= "test.example.com" sniConfigs := &model.Sni{ Status: "on", ServerName: &serverNameSni, } statusRequestLimitRules:= "on" matchValueRequestLimitRules:= "/test" var listRequestLimitRulesConfigs = []model.RequestLimitRules{ { Status: &statusRequestLimitRules, Priority: int32(88), MatchType: "catalog", MatchValue: &matchValueRequestLimitRules, Type: "size", LimitRateAfter: int64(1024), LimitRateValue: int32(50), }, } enableFlvByTimeSeekVideoSeek:= true startParameterVideoSeek:= "start" endParameterVideoSeek:= "end" videoSeekConfigs := &model.VideoSeek{ EnableVideoSeek: true, EnableFlvByTimeSeek: &enableFlvByTimeSeekVideoSeek, StartParameter: &startParameterVideoSeek, EndParameter: &endParameterVideoSeek, } websocketConfigs := &model.WebSocketSeek{ Status: "on", Timeout: int32(60), } var listAddCustomHeadersRulesRemoteAuthRules = []model.CustomArgs{ { Type: "nginx_preset_var", Key: "http_host", Value: "$http_host", }, } var listAddCustomArgsRulesRemoteAuthRules = []model.CustomArgs{ { Type: "nginx_preset_var", Key: "http_host", Value: "$http_host", }, } reserveHeadersRemoteAuthRules:= "sf" remoteAuthRulesRemoteAuth := &model.RemoteAuthRule{ AuthServer: "https://192.168.0.0", RequestMethod: "GET", FileTypeSetting: "all", ReserveArgsSetting: "reserve_all_args", AddCustomArgsRules: &listAddCustomArgsRulesRemoteAuthRules, ReserveHeadersSetting: "reserve_specific_headers", AddCustomHeadersRules: &listAddCustomHeadersRulesRemoteAuthRules, AuthSuccessStatus: "200", AuthFailedStatus: "403", ResponseStatus: "403", Timeout: int32(500), TimeoutAction: "pass", ReserveHeaders: &reserveHeadersRemoteAuthRules, } remoteAuthConfigs := &model.CommonRemoteAuth{ RemoteAuthentication: "on", RemoteAuthRules: remoteAuthRulesRemoteAuth, } var listBackSourcesFlexibleOrigin = []model.BackSources{ { SourcesType: "domain", IpOrDomain: "www.back.example.com", }, } var listFlexibleOriginConfigs = []model.FlexibleOrigins{ { MatchType: "file_path", MatchPattern: "/test", Priority: int32(1), BackSources: listBackSourcesFlexibleOrigin, }, } compressConfigs := &model.Compress{ Status: "off", } typeForceRedirect:= "http" redirectCodeForceRedirect:= int32(301) forceRedirectConfigs := &model.ForceRedirectConfig{ Status: "on", Type: &typeForceRedirect, RedirectCode: &redirectCodeForceRedirect, } valueReferer:= "192.168.0.0" includeEmptyReferer:= true refererConfigs := &model.RefererConfig{ Type: "black", Value: &valueReferer, IncludeEmpty: &includeEmptyReferer, } valueIpFilter:= "192.168.0.0" ipFilterConfigs := &model.IpFilter{ Type: "black", Value: &valueIpFilter, } matchTypeCacheRules:= "file_extension" matchValueCacheRules:= ".zip" ttlCacheRules:= int32(0) followOriginCacheRules:= "off" urlParameterTypeCacheRules:= "del_params" urlParameterValueCacheRules:= "test_param" var listCacheRulesConfigs = []model.CacheRules{ { MatchType: &matchTypeCacheRules, MatchValue: &matchValueCacheRules, Ttl: &ttlCacheRules, TtlUnit: "h", Priority: int32(10), FollowOrigin: &followOriginCacheRules, UrlParameterType: &urlParameterTypeCacheRules, UrlParameterValue: &urlParameterValueCacheRules, }, } httpPortSources:= int32(80) httpsPortSources:= int32(443) var listSourcesConfigs = []model.SourcesConfig{ { OriginType: "domain", OriginAddr: "www.example.com", Priority: int32(70), HttpPort: &httpPortSources, HttpsPort: &httpsPortSources, }, } urlAuthConfigs := &model.UrlAuth{ Status: "off", } valueHttpResponseHeader:= "test_value" var listHttpResponseHeaderConfigs = []model.HttpResponseHeader{ { Name: "test-name", Value: &valueHttpResponseHeader, Action: "set", }, } valueOriginRequestHeader:= "test_value" var listOriginRequestHeaderConfigs = []model.OriginRequestHeader{ { Name: "test-name", Value: &valueOriginRequestHeader, Action: "set", }, } originProtocolConfigs:= "follow" originFollow302StatusConfigs:= "off" ipv6AccelerateConfigs:= int32(1) sliceEtagStatusConfigs:= "off" originReceiveTimeoutConfigs:= int32(30) configsbody := &model.Configs{ OriginRequestHeader: &listOriginRequestHeaderConfigs, HttpResponseHeader: &listHttpResponseHeaderConfigs, UrlAuth: urlAuthConfigs, Sources: &listSourcesConfigs, OriginProtocol: &originProtocolConfigs, OriginFollow302Status: &originFollow302StatusConfigs, CacheRules: &listCacheRulesConfigs, IpFilter: ipFilterConfigs, Referer: refererConfigs, ForceRedirect: forceRedirectConfigs, Compress: compressConfigs, Ipv6Accelerate: &ipv6AccelerateConfigs, FlexibleOrigin: &listFlexibleOriginConfigs, SliceEtagStatus: &sliceEtagStatusConfigs, OriginReceiveTimeout: &originReceiveTimeoutConfigs, RemoteAuth: remoteAuthConfigs, Websocket: websocketConfigs, VideoSeek: videoSeekConfigs, RequestLimitRules: &listRequestLimitRulesConfigs, Sni: sniConfigs, RequestUrlRewrite: &listRequestUrlRewriteConfigs, BrowserCacheRules: &listBrowserCacheRulesConfigs, AccessAreaFilter: &listAccessAreaFilterConfigs, ClientCert: clientCertConfigs, } request.Body = &model.ModifyDomainConfigRequestBody{ Configs: configsbody, } response, err := client.UpdateDomainFullConfig(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 |
Request succeeded. |
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