Cloud CDN API, REST: ResourceRules.create
Create new resource rule with specified unique name and rule patter.
HTTP request
POST https://cdn.api.cloud.yandex.net/cdn/v1/rules
Body parameters
{
"resourceId": "string",
"name": "string",
"rulePattern": "string",
"options": {
"disableCache": {
"enabled": true,
"value": true
},
"edgeCacheSettings": {
"enabled": true,
// `options.edgeCacheSettings` includes only one of the fields `value`, `defaultValue`
"value": {
"simpleValue": "string",
"customValues": "object"
},
"defaultValue": "string",
// end of the list of possible fields`options.edgeCacheSettings`
},
"browserCacheSettings": {
"enabled": true,
"value": "string"
},
"cacheHttpHeaders": {
"enabled": true,
"value": [
"string"
]
},
"queryParamsOptions": {
// `options.queryParamsOptions` includes only one of the fields `ignoreQueryString`, `queryParamsWhitelist`, `queryParamsBlacklist`
"ignoreQueryString": {
"enabled": true,
"value": true
},
"queryParamsWhitelist": {
"enabled": true,
"value": [
"string"
]
},
"queryParamsBlacklist": {
"enabled": true,
"value": [
"string"
]
},
// end of the list of possible fields`options.queryParamsOptions`
},
"slice": {
"enabled": true,
"value": true
},
"compressionOptions": {
// `options.compressionOptions` includes only one of the fields `fetchCompressed`, `gzipOn`, `brotliCompression`
"fetchCompressed": {
"enabled": true,
"value": true
},
"gzipOn": {
"enabled": true,
"value": true
},
"brotliCompression": {
"enabled": true,
"value": [
"string"
]
},
// end of the list of possible fields`options.compressionOptions`
},
"redirectOptions": {
// `options.redirectOptions` includes only one of the fields `redirectHttpToHttps`, `redirectHttpsToHttp`
"redirectHttpToHttps": {
"enabled": true,
"value": true
},
"redirectHttpsToHttp": {
"enabled": true,
"value": true
},
// end of the list of possible fields`options.redirectOptions`
},
"hostOptions": {
// `options.hostOptions` includes only one of the fields `host`, `forwardHostHeader`
"host": {
"enabled": true,
"value": "string"
},
"forwardHostHeader": {
"enabled": true,
"value": true
},
// end of the list of possible fields`options.hostOptions`
},
"staticHeaders": {
"enabled": true,
"value": "object"
},
"cors": {
"enabled": true,
"value": [
"string"
]
},
"stale": {
"enabled": true,
"value": [
"string"
]
},
"allowedHttpMethods": {
"enabled": true,
"value": [
"string"
]
},
"proxyCacheMethodsSet": {
"enabled": true,
"value": true
},
"disableProxyForceRanges": {
"enabled": true,
"value": true
},
"staticRequestHeaders": {
"enabled": true,
"value": "object"
},
"customServerName": {
"enabled": true,
"value": "string"
},
"ignoreCookie": {
"enabled": true,
"value": true
},
"rewrite": {
"enabled": true,
"body": "string",
"flag": "string"
},
"secureKey": {
"enabled": true,
"key": "string",
"type": "string"
},
"ipAddressAcl": {
"enabled": true,
"policyType": "string",
"exceptedValues": [
"string"
]
}
}
}
Field | Description |
---|---|
resourceId | string Required. ID of resource. The maximum string length in characters is 50. |
name | string Required. Name of created resource rule. The maximum string length in characters is 50. |
rulePattern | string Required. Resource rule pattern. The maximum string length in characters is 100. |
options | object A major set of various resource options. |
options. disableCache |
object Set up a cache status. Set up bool values. |
options. disableCache. enabled |
boolean (boolean) True - the option is enabled and its |
options. disableCache. value |
boolean (boolean) Value of the option. |
options. edgeCacheSettings |
object Set up A set of the edge cache parameters. |
options. edgeCacheSettings. enabled |
boolean (boolean) True - the option is enabled and its |
options. edgeCacheSettings. value |
object Value of the option. options.edgeCacheSettings includes only one of the fields value , defaultValue |
options. edgeCacheSettings. value. simpleValue |
string (int64) Caching time for a response with codes 200, 206, 301, 302. Responses with codes 4xx, 5xx will not be cached. Use |
options. edgeCacheSettings. value. customValues |
object Caching time for a response with specific codes. These settings have a higher priority than the value field. Response code ( |
options. edgeCacheSettings. defaultValue |
string (int64) options.edgeCacheSettings includes only one of the fields value , defaultValue Content will be cached according to origin cache settings. The value applies for a response with codes 200, 201, 204, 206, 301, 302, 303, 304, 307, 308 if an origin server does not have caching HTTP headers. Responses with other codes will not be cached. |
options. browserCacheSettings |
object Using A set of the numeric parameters. |
options. browserCacheSettings. enabled |
boolean (boolean) True - the option is enabled and its |
options. browserCacheSettings. value |
string (int64) Value of the option. |
options. cacheHttpHeaders |
object List HTTP headers that must be included in responses to clients. A set of the string list parameters. |
options. cacheHttpHeaders. enabled |
boolean (boolean) True - the option is enabled and its |
options. cacheHttpHeaders. value[] |
string Value of the option. |
options. queryParamsOptions |
object Set up A set of the query parameters. |
options. queryParamsOptions. ignoreQueryString |
object Using ResourceOptionsBoolOption . Selected by default. Files with different query parameters are cached as objects with the same key regardless of the parameter value. options.queryParamsOptions includes only one of the fields ignoreQueryString , queryParamsWhitelist , queryParamsBlacklist |
options. queryParamsOptions. ignoreQueryString. enabled |
boolean (boolean) True - the option is enabled and its |
options. queryParamsOptions. ignoreQueryString. value |
boolean (boolean) Value of the option. |
options. queryParamsOptions. queryParamsWhitelist |
object Ignore All Except. Files with the specified query parameters are cached as objects with different keys, files with other parameters are cached as objects with the same key. options.queryParamsOptions includes only one of the fields ignoreQueryString , queryParamsWhitelist , queryParamsBlacklist |
options. queryParamsOptions. queryParamsWhitelist. enabled |
boolean (boolean) True - the option is enabled and its |
options. queryParamsOptions. queryParamsWhitelist. value[] |
string Value of the option. |
options. queryParamsOptions. queryParamsBlacklist |
object Ignore only. Files with the specified query parameters are cached as objects with the same key, files with other parameters are cached as objects with different keys. options.queryParamsOptions includes only one of the fields ignoreQueryString , queryParamsWhitelist , queryParamsBlacklist |
options. queryParamsOptions. queryParamsBlacklist. enabled |
boolean (boolean) True - the option is enabled and its |
options. queryParamsOptions. queryParamsBlacklist. value[] |
string Value of the option. |
options. slice |
object Files larger than 10 MB will be requested and cached in parts (no larger than 10 MB each part). It reduces time to first byte. The origin must support HTTP Range requests. By default the option is disabled. Set up bool values. |
options. slice. enabled |
boolean (boolean) True - the option is enabled and its |
options. slice. value |
boolean (boolean) Value of the option. |
options. compressionOptions |
object Set up compression variant. A set of the compression variant parameters. |
options. compressionOptions. fetchCompressed |
object The Fetch compressed option helps you to reduce the bandwidth between origin and CDN servers. Also, content delivery speed becomes higher because of reducing the time for compressing files in a CDN. options.compressionOptions includes only one of the fields fetchCompressed , gzipOn , brotliCompression |
options. compressionOptions. fetchCompressed. enabled |
boolean (boolean) True - the option is enabled and its |
options. compressionOptions. fetchCompressed. value |
boolean (boolean) Value of the option. |
options. compressionOptions. gzipOn |
object Using ResourceOptionsBoolOption . GZip compression at CDN servers reduces file size by 70% and can be as high as 90%. options.compressionOptions includes only one of the fields fetchCompressed , gzipOn , brotliCompression |
options. compressionOptions. gzipOn. enabled |
boolean (boolean) True - the option is enabled and its |
options. compressionOptions. gzipOn. value |
boolean (boolean) Value of the option. |
options. compressionOptions. brotliCompression |
object The option allows to compress content with brotli on the CDN's end. Compression is performed on the Origin Shielding. If a pre-cache server doesn't active for a resource, compression does not occur even if the option is enabled. Specify the content-type for each type of content you wish to have compressed. CDN servers will request only uncompressed content from the origin. options.compressionOptions includes only one of the fields fetchCompressed , gzipOn , brotliCompression |
options. compressionOptions. brotliCompression. enabled |
boolean (boolean) True - the option is enabled and its |
options. compressionOptions. brotliCompression. value[] |
string Value of the option. |
options. redirectOptions |
object Set up redirects. A set of the redirect parameters. |
options. redirectOptions. redirectHttpToHttps |
object Using ResourceOptionsBoolOption . Set up a redirect from HTTPS to HTTP. options.redirectOptions includes only one of the fields redirectHttpToHttps , redirectHttpsToHttp |
options. redirectOptions. redirectHttpToHttps. enabled |
boolean (boolean) True - the option is enabled and its |
options. redirectOptions. redirectHttpToHttps. value |
boolean (boolean) Value of the option. |
options. redirectOptions. redirectHttpsToHttp |
object Using ResourceOptionsBoolOption . Set up a redirect from HTTP to HTTPS. options.redirectOptions includes only one of the fields redirectHttpToHttps , redirectHttpsToHttp |
options. redirectOptions. redirectHttpsToHttp. enabled |
boolean (boolean) True - the option is enabled and its |
options. redirectOptions. redirectHttpsToHttp. value |
boolean (boolean) Value of the option. |
options. hostOptions |
object Set up host parameters. A set of the host parameters. |
options. hostOptions. host |
object Custom value for the Host header. Your server must be able to process requests with the chosen header. Default value (if enabled is false ) is Resource.cname. options.hostOptions includes only one of the fields host , forwardHostHeader |
options. hostOptions. host. enabled |
boolean (boolean) True - the option is enabled and its |
options. hostOptions. host. value |
string Value of the option. |
options. hostOptions. forwardHostHeader |
object Using ResourceOptionsBoolOption . Choose the Forward Host header option if is important to send in the request to the Origin the same Host header as was sent in the request to CDN server. options.hostOptions includes only one of the fields host , forwardHostHeader |
options. hostOptions. forwardHostHeader. enabled |
boolean (boolean) True - the option is enabled and its |
options. hostOptions. forwardHostHeader. value |
boolean (boolean) Value of the option. |
options. staticHeaders |
object Set up static headers that CDN servers send in responses to clients. A set of the strings map parameters. |
options. staticHeaders. enabled |
boolean (boolean) True - the option is enabled and its |
options. staticHeaders. value |
object Value of the option. |
options. cors |
object Parameter that lets browsers get access to selected resources from a domain different to a domain from which the request is received. Read more. A set of the string list parameters. |
options. cors. enabled |
boolean (boolean) True - the option is enabled and its |
options. cors. value[] |
string Value of the option. |
options. stale |
object List of errors which instruct CDN servers to serve stale content to clients. Possible values: A set of the string list parameters. |
options. stale. enabled |
boolean (boolean) True - the option is enabled and its |
options. stale. value[] |
string Value of the option. |
options. allowedHttpMethods |
object HTTP methods for your CDN content. By default the following methods are allowed: GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS. In case some methods are not allowed to the user, they will get the 405 (Method Not Allowed) response. If the method is not supported, the user gets the 501 (Not Implemented) response. A set of the string list parameters. |
options. allowedHttpMethods. enabled |
boolean (boolean) True - the option is enabled and its |
options. allowedHttpMethods. value[] |
string Value of the option. |
options. proxyCacheMethodsSet |
object Allows caching for GET, HEAD and POST requests. Set up bool values. |
options. proxyCacheMethodsSet. enabled |
boolean (boolean) True - the option is enabled and its |
options. proxyCacheMethodsSet. value |
boolean (boolean) Value of the option. |
options. disableProxyForceRanges |
object Disabling proxy force ranges. Set up bool values. |
options. disableProxyForceRanges. enabled |
boolean (boolean) True - the option is enabled and its |
options. disableProxyForceRanges. value |
boolean (boolean) Value of the option. |
options. staticRequestHeaders |
object Set up custom headers that CDN servers send in requests to origins. The Header name field can contain letters (A-Z, a-z), numbers (0-9), dashes (-) and underscores (). The Value field can contain letters (A-Z, a-z), numbers (0-9), dashes (-), underscores (), slashes (/), colons (:), equal (=), dots (.), and spaces. A set of the strings map parameters. |
options. staticRequestHeaders. enabled |
boolean (boolean) True - the option is enabled and its |
options. staticRequestHeaders. value |
object Value of the option. |
options. customServerName |
object Wildcard additional CNAME. If a resource has a wildcard additional CNAME, you can use your own certificate for content delivery via HTTPS. Read-only. A set of the string parameters. |
options. customServerName. enabled |
boolean (boolean) True - the option is enabled and its |
options. customServerName. value |
string Value of the option. |
options. ignoreCookie |
object Using Set up bool values. |
options. ignoreCookie. enabled |
boolean (boolean) True - the option is enabled and its |
options. ignoreCookie. value |
boolean (boolean) Value of the option. |
options. rewrite |
object Changing or redirecting query paths. An option for changing or redirecting query paths. |
options. rewrite. enabled |
boolean (boolean) True - the option is enabled and its |
options. rewrite. body |
string Pattern for rewrite. The value must have the following format: |
options. rewrite. flag |
string Break flag is applied to the option by default. It is not shown in the field. RewriteFlag defines flag for the Rewrite option.
|
options. secureKey |
object Secure token to protect contect and limit access by IP addresses and time limits. |
options. secureKey. enabled |
boolean (boolean) True - the option is enabled and its [flag] is applied to the resource. False - the option is disabled and its default value of the [flag] is used for the resource. |
options. secureKey. key |
string The key for the URL signing. |
options. secureKey. type |
string The type of the URL signing. The URL could be available for all IP addresses or for the only one IP. SecureKeyURLType defines type of the URL signing.
|
options. ipAddressAcl |
object Manage the state of the IP access policy option. The option controls access to content from the specified IP addresses. |
options. ipAddressAcl. enabled |
boolean (boolean) True - the option is enabled and its [flag] is applied to the resource. False - the option is disabled and its default value of the [flag] is used for the resource. |
options. ipAddressAcl. policyType |
string The policy type. One of allow or deny value. PolicyType defines type of the policy in IP address acl rules.
|
options. ipAddressAcl. exceptedValues[] |
string The list of IP addresses to be allowed or denied. |
Response
HTTP Code: 200 - OK
{
"id": "string",
"description": "string",
"createdAt": "string",
"createdBy": "string",
"modifiedAt": "string",
"done": true,
"metadata": "object",
// includes only one of the fields `error`, `response`
"error": {
"code": "integer",
"message": "string",
"details": [
"object"
]
},
"response": "object",
// end of the list of possible fields
}
An Operation resource. For more information, see Operation.
Field | Description |
---|---|
id | string ID of the operation. |
description | string Description of the operation. 0-256 characters long. |
createdAt | string (date-time) Creation timestamp. String in RFC3339 text format. The range of possible values is from To work with values in this field, use the APIs described in the Protocol Buffers reference. In some languages, built-in datetime utilities do not support nanosecond precision (9 digits). |
createdBy | string ID of the user or service account who initiated the operation. |
modifiedAt | string (date-time) The time when the Operation resource was last modified. String in RFC3339 text format. The range of possible values is from To work with values in this field, use the APIs described in the Protocol Buffers reference. In some languages, built-in datetime utilities do not support nanosecond precision (9 digits). |
done | boolean (boolean) If the value is |
metadata | object Service-specific metadata associated with the operation. It typically contains the ID of the target resource that the operation is performed on. Any method that returns a long-running operation should document the metadata type, if any. |
error | object The error result of the operation in case of failure or cancellation. includes only one of the fields error , response |
error. code |
integer (int32) Error code. An enum value of google.rpc.Code. |
error. message |
string An error message. |
error. details[] |
object A list of messages that carry the error details. |
response | object includes only one of the fields error , response The normal response of the operation in case of success. If the original method returns no data on success, such as Delete, the response is google.protobuf.Empty. If the original method is the standard Create/Update, the response should be the target resource of the operation. Any method that returns a long-running operation should document the response type, if any. |