Skip to main content

cdn_endpoints

Creates, updates, deletes, gets or lists a cdn_endpoints resource.

Overview

Namecdn_endpoints
TypeResource
Iddigitalocean.compute.cdn_endpoints

Fields

The following fields are returned by SELECT queries:

The response will be a JSON object with an endpoint key. This will be set to an object containing the standard CDN endpoint attributes.

NameDatatypeDescription
idstring (uuid)A unique ID that can be used to identify and reference a CDN endpoint. (example: 892071a0-bb95-49bc-8021-3afd67a210bf)
certificate_idstring (uuid)The ID of a DigitalOcean managed TLS certificate used for SSL when a custom subdomain is provided. (example: 892071a0-bb95-49bc-8021-3afd67a210bf)
created_atstring (date-time)A time value given in ISO8601 combined date and time format that represents when the CDN endpoint was created. (example: 2018-03-21T16:02:37Z)
custom_domainstring (hostname)The fully qualified domain name (FQDN) of the custom subdomain used with the CDN endpoint. (example: static.example.com)
endpointstring (hostname)The fully qualified domain name (FQDN) from which the CDN-backed content is served. (example: static-images.nyc3.cdn.digitaloceanspaces.com)
originstring (hostname)The fully qualified domain name (FQDN) for the origin server which provides the content for the CDN. This is currently restricted to a Space. (example: static-images.nyc3.digitaloceanspaces.com)
ttlintegerThe amount of time the content is cached by the CDN's edge servers in seconds. TTL must be one of 60, 600, 3600, 86400, or 604800. Defaults to 3600 (one hour) when excluded.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
cdn_get_endpointselectcdn_idTo show information about an existing CDN endpoint, send a GET request to /v2/cdn/endpoints/$ENDPOINT_ID.
cdn_list_endpointsselectper_page, pageTo list all of the CDN endpoints available on your account, send a GET request to /v2/cdn/endpoints.
cdn_create_endpointinsertdata__originTo create a new CDN endpoint, send a POST request to /v2/cdn/endpoints. The
origin attribute must be set to the fully qualified domain name (FQDN) of a
DigitalOcean Space. Optionally, the TTL may be configured by setting the ttl
attribute.

A custom subdomain may be configured by specifying the custom_domain and
certificate_id attributes.
cdn_update_endpointsreplacecdn_idTo update the TTL, certificate ID, or the FQDN of the custom subdomain for
an existing CDN endpoint, send a PUT request to
/v2/cdn/endpoints/$ENDPOINT_ID.
cdn_delete_endpointdeletecdn_idTo delete a specific CDN endpoint, send a DELETE request to
/v2/cdn/endpoints/$ENDPOINT_ID.

A status of 204 will be given. This indicates that the request was processed
successfully, but that no response body is needed.
cdn_purge_cacheexeccdn_id, filesTo purge cached content from a CDN endpoint, send a DELETE request to
/v2/cdn/endpoints/$ENDPOINT_ID/cache. The body of the request should include
a files attribute containing a list of cached file paths to be purged. A
path may be for a single file or may contain a wildcard (*) to recursively
purge all files under a directory. When only a wildcard is provided, all cached
files will be purged. There is a rate limit of 50 files per 20 seconds that can
be purged. CDN endpoints have a rate limit of 5 requests per 10 seconds.
Purging files using a wildcard path counts as a single request against the API's
rate limit. Two identical purge requests cannot be sent at the same time.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
cdn_idstring (uuid)A unique identifier for a CDN endpoint. (example: 19f06b6a-3ace-4315-b086-499a0e521b76)
pageintegerWhich 'page' of paginated results to return. (example: 1)
per_pageintegerNumber of items returned per page (example: 2)

SELECT examples

To show information about an existing CDN endpoint, send a GET request to /v2/cdn/endpoints/$ENDPOINT_ID.

SELECT
id,
certificate_id,
created_at,
custom_domain,
endpoint,
origin,
ttl
FROM digitalocean.compute.cdn_endpoints
WHERE cdn_id = '{{ cdn_id }}' -- required;

INSERT examples

To create a new CDN endpoint, send a POST request to /v2/cdn/endpoints. The
origin attribute must be set to the fully qualified domain name (FQDN) of a
DigitalOcean Space. Optionally, the TTL may be configured by setting the ttl
attribute.

A custom subdomain may be configured by specifying the custom_domain and
certificate_id attributes.

INSERT INTO digitalocean.compute.cdn_endpoints (
data__origin,
data__ttl,
data__certificate_id,
data__custom_domain
)
SELECT
'{{ origin }}' --required,
{{ ttl }},
'{{ certificate_id }}',
'{{ custom_domain }}'
RETURNING
endpoint
;

REPLACE examples

To update the TTL, certificate ID, or the FQDN of the custom subdomain for
an existing CDN endpoint, send a PUT request to
/v2/cdn/endpoints/$ENDPOINT_ID.

REPLACE digitalocean.compute.cdn_endpoints
SET
data__ttl = {{ ttl }},
data__certificate_id = '{{ certificate_id }}',
data__custom_domain = '{{ custom_domain }}'
WHERE
cdn_id = '{{ cdn_id }}' --required
RETURNING
endpoint;

DELETE examples

To delete a specific CDN endpoint, send a DELETE request to
/v2/cdn/endpoints/$ENDPOINT_ID.

A status of 204 will be given. This indicates that the request was processed
successfully, but that no response body is needed.

DELETE FROM digitalocean.compute.cdn_endpoints
WHERE cdn_id = '{{ cdn_id }}' --required;

Lifecycle Methods

To purge cached content from a CDN endpoint, send a DELETE request to
/v2/cdn/endpoints/$ENDPOINT_ID/cache. The body of the request should include
a files attribute containing a list of cached file paths to be purged. A
path may be for a single file or may contain a wildcard (*) to recursively
purge all files under a directory. When only a wildcard is provided, all cached
files will be purged. There is a rate limit of 50 files per 20 seconds that can
be purged. CDN endpoints have a rate limit of 5 requests per 10 seconds.
Purging files using a wildcard path counts as a single request against the API's
rate limit. Two identical purge requests cannot be sent at the same time.

EXEC digitalocean.compute.cdn_endpoints.cdn_purge_cache 
@cdn_id='{{ cdn_id }}' --required
@@json=
'{
"files": "{{ files }}"
}';