Help Center> Content Delivery Network> API Reference> API> Domain Name Configuration> Modifying the Full Domain Configuration
Updated on 2024-05-30 GMT+08:00

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, and geo-blocking settings.

Calling Method

For details, see Calling APIs.

URI

PUT /v1.1/cdn/configuration/domains/{domain_name}/configs

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

domain_name

Yes

String

Domain name.

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

enterprise_project_id

No

String

ID of the enterprise project that the domain name to be modified belongs to. This parameter is valid only when the enterprise project function is enabled. The value all indicates all projects.

NOTE:

This parameter is mandatory when you use an IAM user to call this API. Obtain the enterprise project ID by calling the ListEnterpriseProject API of Enterprise Project Management Service (EPS).

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token. It can be obtained by calling the IAM API used to obtain a user token. The value of X-Subject-Token in the response header is the user token.

Table 4 Request body parameters

Parameter

Mandatory

Type

Description

configs

No

Configs object

Configuration items.

Table 5 Configs

Parameter

Mandatory

Type

Description

business_type

No

String

Service type:

  • web: website acceleration.

  • download: file download acceleration.

  • video: on-demand service acceleration.

NOTE:

Currently, whole site acceleration cannot be changed to other service types.

service_area

No

String

Service area.

  • mainland_china: Chinese mainland.

  • global: global.

  • outside_mainland_china: outside the Chinese mainland.

NOTE:

Currently, the service area cannot be changed between mainland_china and outside_mainland_china.

remark

No

String

Remarks of the domain name. The value contains up to 200 characters.

origin_request_header

No

Array of OriginRequestHeader objects

Origin request header settings. Original settings of all headers will be overwritten. When using this API, upload information of all headers.

http_response_header

No

Array of HttpResponseHeader objects

HTTP header settings. Original settings of all headers will be overwritten. When using this API, upload information of all headers.

url_auth

No

UrlAuth object

Token authentication.

https

No

HttpPutBody object

Certificate settings.

sources

No

Array of SourcesConfig objects

Origin server settings.

origin_protocol

No

String

Origin protocol. Possible values: follow (same as user requests), http (HTTP, default value), and https (HTTPS).

origin_follow302_status

No

String

Redirect from origin. Possible values: on (enabled) and off (disabled).

cache_rules

No

Array of CacheRules objects

Cache rules.

ip_filter

No

IpFilter object

IP address blacklist or whitelist.

referer

No

RefererConfig object

Referer validation.

force_redirect

No

ForceRedirectConfig object

Force redirect.

compress

No

Compress object

Smart compression.

cache_url_parameter_filter

No

CacheUrlParameterFilter object

Settings of caching URL parameters.

NOTE:

This old parameter will be deprecated recently. You are advised to use CacheRules.

ipv6_accelerate

No

Integer

IPv6 settings. Possible values: 1 (enabled) and 0 (disabled).

error_code_cache

No

Array of ErrorCodeCache objects

Status code cache TTL.

origin_range_status

No

String

Whether range requests are enabled during origin pull. Possible values: on (enabled) and off (disabled).

NOTE:

To enable range requests during origin pull, the origin server must support range requests, that is, requests with the Range field in the headers. Otherwise, origin pull may fail.

user_agent_filter

No

UserAgentFilter object

User-Agent blacklist or whitelist settings.

origin_request_url_rewrite

No

Array of OriginRequestUrlRewrite objects

Rules of rewriting origin request URLs. Up to 20 rules can be configured.

flexible_origin

No

Array of flexibleOrigins objects

Advanced origins. Up to 20 rules can be configured.

slice_etag_status

No

String

Whether ETag is verified during origin pull. Possible values: on (yes) and off (no).

origin_receive_timeout

No

Integer

Origin response timeout. The value ranges from 5 to 60, in seconds.

remote_auth

No

commonRemoteAuth object

Remote authentication settings.

websocket

No

webSocketSeek object

WebSocket settings.

NOTE:

Only domain names for whole site acceleration support this configuration item.

video_seek

No

videoSeek object

Video seek settings.

NOTE:

You have configured a cache rule for FLV and MP4 files and ignored all URL parameters in user requests. Time-based FLV seek is valid only when video seek is enabled.

request_limit_rules

No

Array of RequestLimitRules objects

Request rate limiting.

ip_frequency_limit

No

IpFrequencyLimit object

IP access frequency limit. 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.

hsts

No

Hsts object

HSTS settings. HSTS forces clients (such as browsers) to use HTTPS to access your server, improving access security.

quic

No

Quic object

QUIC protocol.

error_code_redirect_rules

No

Array of ErrorCodeRedirectRules objects

Custom error page.

sni

No

Sni object

Origin SNI.

request_url_rewrite

No

Array of RequestUrlRewrite objects

Access URL rewriting.

browser_cache_rules

No

Array of BrowserCacheRules objects

Browser cache TTL.

access_area_filter

No

Array of AccessAreaFilter objects

Geo-blocking.

NOTE:
  • To use this function, submit a service ticket.

  • CDN periodically updates the IP address library. The locations of IP addresses that are not in the library cannot be identified. CDN allows requests from such IP addresses and returns resources to the users.

Table 6 OriginRequestHeader

Parameter

Mandatory

Type

Description

name

Yes

String

Name of an origin request header. The value contains 1 to 64 characters, including letters, digits, and hyphens (-). It must start with a letter.

value

No

String

Value of the origin request header. This parameter is optional for the delete operation. The value contains 1 to 1,000 characters. Variables, for example, $client_ip and $remote_port, are not supported.

action

Yes

String

Operation type of the origin request header. Possible values: delete and set. A request header field can only be deleted or set. set: If the header does not exist in the original origin pull request, add the header before setting its value.

Table 7 HttpResponseHeader

Parameter

Mandatory

Type

Description

name

Yes

String

HTTP response header. Possible values: Content-Disposition, Content-Language, Access-Control-Allow-Origin, Access-Control-Allow-Methods, Access-Control-Max-Age, Access-Control-Expose-Headers, or custom headers. The value contains 1 to 100 characters, including letters, digits, and hyphens (-). It must start with a letter.

value

No

String

Value of the HTTP response header. This parameter is optional for the delete operation. The value of a custom HTTP response header contains 1 to 1,000 characters, including letters, digits, and special characters such as .-_*#!&+|^~'"/:;,=@?<>.

action

Yes

String

Operation type of the HTTP response header. The value can be set or delete.

Table 8 UrlAuth

Parameter

Mandatory

Type

Description

status

Yes

String

Whether token authentication is enabled. Possible values: on (enabled) and off (disabled).

type

No

String

Signing method. type_a: method A. type_b: method B. type_c1: method C1. type_c2: method C2.

expire_time

No

Integer

Expiration time. The value ranges from 0 to 31,536,000, in seconds.

sign_method

No

String

Encryption algorithm. The value can be md5 or sha256.

match_type

No

String

Authentication scope. Currently, the value can only be all (all files are authenticated).

inherit_config

No

InheritConfig object

Authentication inheritance. Add authentication parameters to TS and MP4 files under M3U8/MPD index files, so that the files can be played after authentication succeeds.

key

No

String

Signing key. The value contains 6 to 32 characters, including letters and digits.

backup_key

No

String

Secondary key. The value contains 6 to 32 characters, including letters and digits.

sign_arg

No

String

Authentication parameter. The value contains 1 to 100 characters, including letters, digits, and underscores (_). The value cannot start with a digit.

time_format

No

String

Time format. dec: decimal. hex: hexadecimal. Method A supports only the decimal format. Method B supports only the decimal format. Method C1 supports only the hexadecimal format. Method C2 supports both decimal and hexadecimal formats.

Table 9 InheritConfig

Parameter

Mandatory

Type

Description

status

Yes

String

Whether authentication inheritance is enabled. The options are on (enabled) and off (disabled).

inherit_type

No

String

Authentication inheritance settings. The value can be m3u8, mpd, or m3u8,mpd.

NOTE:

This parameter is mandatory when authentication inheritance is enabled.

inherit_time_type

No

String

Time type of the files that inherits authentication settings. sys_time: current system time. parent_url_time: time when a user accesses the M3U8/MPD file.

NOTE:

This parameter is mandatory when authentication inheritance is enabled.

Table 10 HttpPutBody

Parameter

Mandatory

Type

Description

https_status

No

String

Whether HTTPS is enabled. Possible values: on (enabled) and off (disabled).

certificate_type

No

String

Certificate type. server: international certificate; server_sm: Chinese (SM2) certificate.

certificate_source

No

Integer

Certificate source. 0 indicates your own certificate.

NOTE:

This parameter is mandatory when a certificate is configured.

certificate_name

No

String

Certificate name, which contains 3 to 64 characters.

NOTE:

This parameter is mandatory when a certificate is configured.

certificate_value

No

String

Content of the certificate used by the HTTPS protocol. This parameter is mandatory when a certificate is configured.

NOTE:

The value must be PEM encoded.

private_key

No

String

Private key used by the HTTPS protocol. This parameter is mandatory when a certificate is configured.

NOTE:

The value must be PEM encoded.

enc_certificate_value

No

String

Encryption certificate. This parameter is mandatory for a Chinese (SM2) certificate.

NOTE:

The value must be PEM encoded.

enc_private_key

No

String

Encryption private key. This parameter is mandatory for a Chinese (SM2) certificate.

NOTE:

The value must be PEM encoded.

certificates

No

Array of CertificatesPutBody objects

This parameter is mandatory when an international certificate and a Chinese (SM2) certificate are configured. Both certificates must be passed. You cannot pass two international certificates or two Chinese (SM2) certificates.

NOTE:
  • You can also pass an international certificate or a Chinese (SM2) certificate in the certificates parameter.

  • If an international certificate, Chinese (SM2) certificate, or both certificates are passed in certificates, the outer certificate settings become invalid. The certificate information specified by this parameter is used.

http2_status

No

String

Whether HTTP/2 is used. Possible values: on (yes) and off (no).

NOTE:

Default value: off. When https_status is set to off, this parameter does not take effect.

tls_version

No

String

Transport Layer Security (TLS). Currently, TLS 1.0, TLS 1.1, TLS 1.2, and TLS 1.3 are supported. By default, TLS 1.1, TLS 1.2, and TLS 1.3 are enabled. At least one version must be enabled.

NOTE:
  1. A single version or consecutive versions must be enabled. For example, you cannot enable TLS 1.0 and TLS 1.2 but disable TLS 1.1.

  2. Versions are separated by commas (,), for example, TLSv1.1,TLSv1.2.

ocsp_stapling_status

No

String

Whether Online Certificate Status Protocol (OCSP) stapling is enabled. Possible values: on (yes) and off (no).

Table 11 CertificatesPutBody

Parameter

Mandatory

Type

Description

certificate_type

Yes

String

Certificate type. server: international certificate; server_sm: Chinese (SM2) certificate.

certificate_name

Yes

String

Certificate name, which contains 3 to 64 characters.

certificate_value

Yes

String

Certificate used by the HTTPS protocol.

NOTE:

The value must be PEM encoded.

private_key

Yes

String

Private key used by the HTTPS protocol.

NOTE:

The value must be PEM encoded.

enc_certificate_value

No

String

Encryption certificate. This parameter is mandatory for a Chinese (SM2) certificate.

NOTE:

The value must be PEM encoded.

enc_private_key

No

String

Encryption private key. This parameter is mandatory for a Chinese (SM2) certificate.

NOTE:

The value must be PEM encoded.

Table 12 SourcesConfig

Parameter

Mandatory

Type

Description

origin_type

Yes

String

Origin server type.

  • ipaddr: IP address.

  • domain: origin server domain name.

  • obs_bucket: OBS bucket domain name.

  • third_bucket: third-party bucket.

origin_addr

Yes

String

IP address or domain name of the origin server.

priority

Yes

Integer

Origin server priority. Possible values: 70 (primary) and 30 (standby).

weight

No

Integer

Weight. The value ranges from 1 to 100.

obs_web_hosting_status

No

String

Whether static website hosting is enabled for the OBS bucket. This parameter is mandatory when the origin server type is obs_bucket. Possible values: off (disabled) and on (enabled).

http_port

No

Integer

HTTP port. Default value: 80. The port number ranges from 1 to 65535.

https_port

No

Integer

HTTPS port. Default value: 443. The port number ranges from 1 to 65535.

host_name

No

String

Host header. The default value is the acceleration domain name.

obs_bucket_type

No

String

OBS bucket type. This parameter is mandatory when the origin server type is OBS bucket. Default value: public.

  • private: private bucket (Users except those authorized by the bucket ACL do not have the permission to access the bucket.)

  • public: public bucket (Any user can read objects in the bucket.)

bucket_access_key

No

String

Access key of the third-party bucket.

NOTE:

This parameter is mandatory when the origin server is a third-party bucket.

bucket_secret_key

No

String

Secret key of the third-party bucket.

NOTE:

This parameter is mandatory when the origin server is a third-party bucket.

bucket_region

No

String

Region of the third-party bucket.

NOTE:

This parameter is mandatory when the origin server is a third-party bucket.

bucket_name

No

String

Name of the third-party bucket.

NOTE:

This parameter is mandatory when the origin server is a third-party bucket.

Table 13 CacheRules

Parameter

Mandatory

Type

Description

match_type

No

String

Match type.

  • all: all files.

  • file_extension: file name extension.

  • catalog: directory.

  • full_path: full path.

  • home_page: homepage.

    NOTE:

    This parameter is optional when a single cache rule is configured. The default value is all. This parameter is mandatory when multiple cache rules are configured.

match_value

No

String

Cache content based on the cache rule. If match_type is set to all, this parameter is left blank. If match_type is set to file_extension, the value of this parameter is a list of file types. A file type starts with a period (.). File types are separated by commas (,), for example, .jpg,.zip,.exe. Up to 20 file types are supported. If match_type is set to catalog, the value of this parameter is a list of directories. A directory starts with a slash (/). Directories are separated by commas (,), for example, /test/folder01,/test/folder02. Up to 20 directories are supported. If match_type is set to full_path, the value of this parameter is a full path. A full path starts with a slash (/) and supports wildcard characters (*). A cache rule can contain only one full path, for example, /test/index.html or /test/*.jpg. If match_type is set to home_page, this parameter is left blank.

ttl

No

Integer

Cache TTL. The maximum TTL is 365 days.

NOTE:

The default value is 0.

ttl_unit

Yes

String

Unit of the cache TTL. Possible values: s (second), m (minute), h (hour), and d (day).

priority

Yes

Integer

Priority of the cache rule. The default value is 1 and the value ranges from 1 to 100. A larger value indicates a higher priority. The priority of a rule must be unique.

follow_origin

No

String

Origin cache control status. Possible values: on (enabled) and off (disabled). > The default value is off.

url_parameter_type

No

String

URL parameters.

  • del_params: Ignore specific URL parameters.

  • reserve_params: Retain specific URL parameters.

  • ignore_url_params: Ignore all URL parameters.

  • full_url: Retain all URL parameters.

    NOTE:

    The default value is full_url.

url_parameter_value

No

String

URL parameters, which are separated by commas (,). Up to 10 parameters can be set. > This parameter is mandatory when url_parameter_type is set to del_params or reserve_params.

Table 14 IpFilter

Parameter

Mandatory

Type

Description

type

Yes

String

IP ACL type. off: Disable the IP ACL. black: IP address blacklist. white: IP address whitelist.

value

No

String

IP address blacklist or whitelist. This parameter is optional when type is set to off. A list contains up to 500 IP addresses and IP address segments, which are separated by commas (,). IPv6 addresses are supported. Duplicate IP addresses and IP address segments will be removed. Addresses with wildcard characters are not supported, for example, 192.168.0.*.

Table 15 RefererConfig

Parameter

Mandatory

Type

Description

type

Yes

String

Referer validation type. off: Disable referer validation. black: referer blacklist. white: referer whitelist.

value

No

String

Domain names or IP addresses, which are separated by commas (,). Wildcard domain names and domain names with port numbers are supported. Enter up to 400 domain names and IP addresses. The port number ranges from 1 to 65535.

include_empty

No

Boolean

Whether blank referers are included. 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. Possible values: true (included) and false (default value, excluded).

Table 16 ForceRedirectConfig

Parameter

Mandatory

Type

Description

status

Yes

String

Whether force redirect is enabled. Possible values: on (enabled) and off (disabled).

type

No

String

Force redirect type. Possible values: http (force redirect to HTTP) and https (force redirect to HTTPS).

redirect_code

No

Integer

Redirect status code 301 or 302.

Table 17 Compress

Parameter

Mandatory

Type

Description

status

Yes

String

Whether smart compression is enabled. Possible values: on (enabled) and off (disabled).

type

No

String

Smart compression type. Possible values: gzip (gzip) and br (Brotli).

file_type

No

String

Formats of files to be compressed. Enter up to 200 characters. Multiple formats are separated by commas (,). Each format contains up to 50 characters. 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.

Table 18 CacheUrlParameterFilter

Parameter

Mandatory

Type

Description

type

No

String

Operation type of caching URL parameters.

  • full_url: Cache all parameters.

  • ignore_url_params: Ignore all parameters.

  • del_params: Ignore specific URL parameters.

  • reserve_params: Retain specific URL parameters.

    NOTE:

    The following parameters of this API are adjusted:

    • Replaced del_args with del_params.

    • Replaced reserve_args with reserve_params.

value

No

String

Parameter values, separated by semicolons (;).

Table 19 ErrorCodeCache

Parameter

Mandatory

Type

Description

code

No

Integer

Error codes 400, 403, 404, 405, 414, 500, 501, 502, 503, and 504 are supported.

ttl

No

Integer

Error code cache TTL, in seconds. The value ranges from 0 to 31,536,000 (365 days each year by default).

Table 20 UserAgentFilter

Parameter

Mandatory

Type

Description

type

Yes

String

User-Agent blacklist or whitelist type. off: The User-Agent blacklist/whitelist is disabled. black: User-Agent blacklist. white: User-Agent whitelist.

value

No

String

User-Agent blacklist or whitelist. This parameter is optional when type is set to off. Up to 10 rules can be configured. A single rule contains up to 100 characters. Rules are separated by commas (,).

ua_list

No

Array of strings

User-Agent blacklist or whitelist. This parameter is optional when type is set to off. Up to 10 rules can be configured. A rule contains up to 100 characters. When ua_list and value are both set, ua_list is used.

Table 21 OriginRequestUrlRewrite

Parameter

Mandatory

Type

Description

priority

Yes

Integer

Priority of a URL rewrite rule. The priority of a rule is mandatory and must be unique. The rule with the highest priority will be used for matching first. Enter an integer ranging from 1 to 100. A greater number indicates a higher priority.

match_type

Yes

String

Match type. all: all files. file_path: URI path. wildcard full_path

source_url

No

String

URI to be rewritten. A URI starts with a slash (/) and does not contain http://, https://, or the domain name. The value contains up to 512 characters. Wildcards (*) are supported, for example, /test/*/*.mp4. If the match mode is set to all files, parameters cannot be configured.

target_url

Yes

String

A URI starts with a slash (/) and does not contain http://, https://, or the domain name. The value contains up to 256 characters. The nth wildcard (*) field can be substituted with $n, where n = 1, 2, 3..., for example, /newtest/$1/$2.jpg.

Table 22 flexibleOrigins

Parameter

Mandatory

Type

Description

match_type

Yes

String

URI match mode. The value can be file_extension or file_path.

match_pattern

Yes

String

file_extension: All file types are supported. A file type starts with a period (.). File types are separated by semicolons (;). Up to 20 file types are supported. file_path: A path starts with a slash (/). Paths are separated by semicolons (;). Up to 20 paths are supported.

priority

Yes

Integer

The priority value ranges from 1 to 100. The larger the value, the higher the priority.

back_sources

Yes

Array of backSources objects

Origin information.

NOTE:

Only one origin server is allowed in each directory.

Table 23 backSources

Parameter

Mandatory

Type

Description

sources_type

Yes

String

Origin server type. Possible values: ipaddr (IP address), domain (domain name), and obs_bucket (OBS bucket).

ip_or_domain

Yes

String

IP address or domain name of the origin server.

obs_bucket_type

No

String

OBS bucket type.

  • private: private bucket.

  • public: public bucket.

http_port

No

Integer

HTTP port, ranging from 1 to 65535.

https_port

No

Integer

HTTPS port, ranging from 1 to 65535.

Table 24 commonRemoteAuth

Parameter

Mandatory

Type

Description

remote_authentication

Yes

String

Whether remote authentication is enabled. Possible values: on (enabled) and off (disabled).

remote_auth_rules

Yes

RemoteAuthRule object

Remote authentication settings.

Table 25 RemoteAuthRule

Parameter

Mandatory

Type

Description

auth_server

Yes

String

Address of a reachable authentication server. The URL must contain http:// or https://. The address cannot be a local address such as localhost or 127.0.0.1. The address cannot be an acceleration domain name added on CDN.

request_method

Yes

String

Request method supported by the authentication server. GET, POST, and HEAD are supported.

file_type_setting

Yes

String

all: Requests for all files are authenticated. specific_file: Requests for files of specific types are authenticated. Example: jpg|MP4 File types are case insensitive. For example, jpg and JPG indicate the same file type. File types are separated by vertical bars (|).

specified_file_type

No

String

The value contains up to 512 characters. This parameter is mandatory when file_type_setting is set to specific_file. In other cases, this parameter is left blank. The value contains letters and digits. File types are separated by vertical bars (|), for example, jpg|mp4. This field is verified only when it is mandatory.

reserve_args_setting

Yes

String

Parameters that need to be authenticated in user requests. The options are reserve_all_args (retain all URL parameters), reserve_specific_args (retain specified URL parameters), and ignore_all_args (ignore all URL parameters).

reserve_args

No

String

This parameter is mandatory when reserve_args_setting is set to reserve_specific_args. In other cases, this parameter is left blank. Parameters are separated by vertical bars (|), for example, key1|key2.

add_custom_args_rules

No

Array of customArgs objects

Token authentication parameters.

reserve_headers_setting

Yes

String

Headers to be authenticated in user requests. The options are reserve_all_headers (retain all request headers), reserve_specific_headers (retain specified request headers), and ignore_all_headers (ignore all request headers).

add_custom_headers_rules

No

Array of customArgs objects

Request header authentication parameters.

auth_success_status

Yes

String

Status code returned by the remote authentication server to CDN PoPs when authentication is successful. Value range: 2xx and 3xx.

auth_failed_status

Yes

String

Status code returned by the remote authentication server to CDN PoPs when authentication fails. Value range: 4xx and 5xx.

response_status

Yes

String

Status code returned by CDN PoPs to users when authentication fails. Value range: 2xx, 3xx, 4xx, and 5xx.

timeout

Yes

Integer

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. Enter 0 or a value ranging from 50 to 3,000. The unit is millisecond.

timeout_action

Yes

String

Method used by CDN PoPs to process a user request after authentication times out. pass: The user request is allowed and the corresponding resource is returned after the authentication times out. forbid: The user request is rejected after the authentication times out and the configured status code is returned to the user.

reserve_headers

No

String

This parameter is mandatory when reserve_headers_setting is set to reserve_specific_headers. In other cases, this parameter is left blank. Request headers are separated by vertical bars (|), for example, key1|key2.

Table 26 customArgs

Parameter

Mandatory

Type

Description

type

Yes

String

Parameter type. Possible values: custom_var (custom) and nginx_preset_var (preset).

key

Yes

String

Parameter, which containing 1 to 256 characters. Only letters, digits, and the following special characters are allowed: ._-*#%|+^@?=

value

Yes

String

When type is set to custom_var, the value contains 1 to 256 characters. Only letters, digits, and the following special characters are allowed: ._-*#%|+^@?= When type is set to nginx_preset_var, the value can only be set to $http_host, $http_user_agent, $http_referer, $http_x_forwarded_for, $http_content_type, $remote_addr, $scheme, $server_protocol, $request_uri, $uri, $args, and $request_method.

Table 27 webSocketSeek

Parameter

Mandatory

Type

Description

status

Yes

String

Status. on: enabled; off: disabled.

timeout

Yes

Integer

Session hold time after a connection is set up. The value ranges from 1 to 300, in seconds.

Table 28 videoSeek

Parameter

Mandatory

Type

Description

enable_video_seek

Yes

Boolean

Video seek status. true: enabled; false: disabled.

NOTE:

When this parameter is set to false, the API for querying domain name configuration does not return the video seek setting information.

enable_flv_by_time_seek

No

Boolean

Time-based FLV seek status. true: enabled; false: disabled.

start_parameter

No

String

Video playback start parameter in user request URLs. The value contains up to 64 characters. Only letters, digits, and underscores (_) are allowed.

end_parameter

No

String

Video playback end parameter in user request URLs. The value contains up to 64 characters. Only letters, digits, and underscores (_) are allowed.

Table 29 RequestLimitRules

Parameter

Mandatory

Type

Description

status

No

String

Status. The value can only be on.

NOTE:

If request_limit_rules is left empty, request rate limiting is disabled. This parameter is used in earlier APIs and will be deprecated.

priority

Yes

Integer

Priority. A larger value indicates a higher priority. The value ranges from 1 to 100.

match_type

Yes

String

Match type. The options are all (all files) and catalog (directory).

match_value

No

String

Match type value. When match_type is set to all, leave this parameter empty. When match_type is set to catalog, the value is a directory address starting with a slash (/), for example, /test.

NOTE:

This parameter is mandatory when match_type is set to catalog.

type

Yes

String

Rate limit mode. Currently, only rate limit by traffic is supported. This parameter can only be set to size.

limit_rate_after

Yes

Long

Rate limiting condition. type=size,limit_rate_after=50 indicates that the speed is limited to the value of limit_rate_after after 50 bytes are transmitted. Unit: byte. Value range: 0 to 1,073,741,824.

limit_rate_value

Yes

Integer

Rate limit, in bit/s. The value ranges from 0 to 104,857,600.

Table 30 IpFrequencyLimit

Parameter

Mandatory

Type

Description

status

Yes

String

Status. The options are on (enabled) and off (disabled).

qps

No

Integer

Access threshold, in times/second. The value ranges from 1 to 100,000.

NOTE:

This parameter is mandatory when IP access frequency is enabled.

Table 31 Hsts

Parameter

Mandatory

Type

Description

status

Yes

String

Status. The options are on (enabled) and off (disabled).

max_age

No

Integer

Expiration time, that is, the TTL of the response header Strict-Transport-Security on the client. Unit: second. Value range: 0 to 63,072,000.

NOTE:

This parameter is mandatory when status is set to on.

include_subdomains

No

String

Whether subdomain names are included. The options are on (included) and off (not included).

NOTE:

This parameter is mandatory when status is set to on.

Table 32 Quic

Parameter

Mandatory

Type

Description

status

Yes

String

Status. The options are on (enabled) and off (disabled).

Table 33 ErrorCodeRedirectRules

Parameter

Mandatory

Type

Description

error_code

Yes

Integer

Redirect error code. Currently, the following status codes are supported: 4xx: 400, 403, 404, 405, 414, 416, and 451 5xx: 500, 501, 502, 503, and 504

target_code

Yes

Integer

Redirect status code. The value can be 301 or 302.

target_link

Yes

String

Destination URL.

Table 34 Sni

Parameter

Mandatory

Type

Description

status

Yes

String

Origin SNI status. Possible values: on (enabled) and off (disabled).

server_name

No

String

Origin domain name to be accessed when CDN pulls origin content, for example, test.example.com.

NOTE:
  1. This parameter is mandatory when origin SNI is enabled.

  2. Wildcard domain names are not supported. Only letters, digits, hyphens (-), and periods (.) are supported.

Table 35 RequestUrlRewrite

Parameter

Mandatory

Type

Description

condition

Yes

UrlRewriteCondition object

Match condition.

redirect_status_code

No

Integer

Redirect status code. 301, 302, 303, and 307 are supported.

redirect_url

Yes

String

Redirect URL. A URL starts with a slash (/) and does not contain http://, https://, or the domain name. Example: /test/index.html.

  • When the match type is set to full path, the wildcard (*) can be captured by $1. For example, if the content is /test/*.jpg and the redirection URL is /newtest/$1.jpg, when a user requests /test/11.jpg, $1 is replaced by 11, so the requested URL after redirection is /newtest/11.jpg.

redirect_host

No

String

Domain name to which client requests are redirected.

NOTE:

By default, the acceleration domain name is used. The value contains 1 to 255 characters and starts with http:// or https://, for example, http://www.example.com.

execution_mode

Yes

String

Execution rule.

  • redirect: If the requested URL matches this rule, the request is redirected to the target URL. After this rule is executed, if other rules exist, CDN continues to execute these rules.

  • break: If the requested URL matches this rule, the request is redirected to the target URL. After this rule is executed, CDN does not execute any other rules and returns status code 200. You cannot set the redirection host or status code.

Table 36 UrlRewriteCondition

Parameter

Mandatory

Type

Description

match_type

Yes

String

Match type.

  • catalog: The rule is executed for files in the specified directory.

  • full_path: The rule is executed for the file of the specified path.

match_value

Yes

String

Match content. If match_type is set to catalog, the value of this parameter is a list of directories. A directory starts with a slash (/). Directories are separated by commas (,), for example, /test/folder01,/test/folder02. Up to 20 directories are supported. If match_type is set to full_path, the value of this parameter is a full path. A full path starts with a slash (/) and supports wildcard characters (*). A cache rule can contain only one full path, for example, /test/index.html or /test/*.jpg.

priority

Yes

Integer

Priority of the access URL rewrite rule. Enter an integer ranging from 1 to 100. A greater number indicates a higher priority. Each rule must have a unique priority.

Table 37 BrowserCacheRules

Parameter

Mandatory

Type

Description

condition

Yes

BrowserCacheRulesCondition object

Match condition.

cache_type

Yes

String

Cache effective type.

  • follow_origin: The cache policy of the origin server, that is, the setting of the Cache-Control header, is used.

  • ttl: The TTL set in this rule is used.

  • never: Browsers do not cache the resources.

ttl

No

Integer

Cache TTL. The maximum TTL is 365 days.

NOTE:

This parameter is mandatory when the cache effective type is set to ttl.

ttl_unit

No

String

Unit of the cache TTL. Possible values: s (second), m (minute), h (hour), and d (day).

NOTE:

This parameter is mandatory when the cache effective type is set to ttl.

Table 38 BrowserCacheRulesCondition

Parameter

Mandatory

Type

Description

match_type

Yes

String

Match type.

  • all: all files.

  • file_extension: file name extension.

  • catalog: directory.

  • full_path: full path.

  • home_page: homepage.

match_value

No

String

Cache content based on the cache rule. If match_type is set to all, this parameter is left blank. If match_type is set to file_extension, the value of this parameter is a list of file types. A file type starts with a period (.). File types are separated by commas (,), for example, .jpg,.zip,.exe. Up to 20 file types are supported. If match_type is set to catalog, the value of this parameter is a list of directories. A directory starts with a slash (/). Directories are separated by commas (,), for example, /test/folder01,/test/folder02. Up to 20 directories are supported. If match_type is set to full_path, the value of this parameter is a full path. A full path starts with a slash (/) and supports wildcard characters (*). A cache rule can contain only one full path, for example, /test/index.html or /test/*.jpg. If match_type is set to home_page, this parameter is left blank.

priority

Yes

Integer

Priority of the rule. Enter an integer ranging from 1 to 100. A greater number indicates a higher priority. Each rule must have a unique priority.

Table 39 AccessAreaFilter

Parameter

Mandatory

Type

Description

type

No

String

Rule type.

  • black: blacklist. Users in regions specified in the blacklist cannot access resources and status code 403 is returned.

  • white: whitelist. Only users in regions specified in the whitelist can access resources. Status code 403 is returned for other users.

content_type

No

String

Content type.

  • all: The rule takes effect for all files.

  • file_directory: The rule takes effect for resources in the specified directory.

  • file_path: The rule takes effect for resources corresponding to the path.

content_value

No

String

Rule. When content_type is set to all, this parameter is empty or not passed. When content_type is set to file_directory, the value must start with a slash (/) and multiple directories are separated by commas (,), for example, /test/folder01,/test/folder02. Up to 100 directories can be entered. When content_type is set to file_path, the value must start with a slash (/) or wildcard (*). Up to two wildcards (*) are allowed and they cannot be consecutive. Multiple paths are separated by commas (,), for example, /test/a.txt,/test/b.txt. Up to 100 paths can be entered.

NOTE:
  • Each whitelist or blacklist rule must be unique.

  • You can configure only one rule for all files.

area

No

String

Regions to which the rule applies. Multiple regions are separated by commas (,), for example, CN_IN,AF,IE,EG,AU (Chinese mainland, Afghanistan, Ireland, Egypt, and Australia). For details about the location codes, see the Appendix - Geographical Location Codes.

exception_ip

No

String

Exception IP addresses excluded from this rule.

Response Parameters

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"
    } ]
  }
}

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
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.withEnterpriseProjectId("<enterprise_project_id>");
        ModifyDomainConfigRequestBody body = new ModifyDomainConfigRequestBody();
        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);
        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
# coding: utf-8

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 = __import__('os').getenv("CLOUD_SDK_AK")
    sk = __import__('os').getenv("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.enterprise_project_id = "<enterprise_project_id>"
        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
        )
        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
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{}
	enterpriseProjectIdRequest:= "<enterprise_project_id>"
	request.EnterpriseProjectId = &enterpriseProjectIdRequest
	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,
	}
	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.