pydo.cdn.create_endpoint()
Generated on 25 November 2024
from pydo
version v0.6.0
Description
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.
Request Sample
import os
from pydo import Client
client = Client ( token = os . environ . get ( "DIGITALOCEAN_TOKEN" ))
create_req = { "origin" : "static-images.nyc3.digitaloceanspaces.com" , "ttl" : 3600 }
create_resp = client . cdn . create_endpoint ( create_req )
Responses
See the API spec for this endpoint to view additional detail on responses, headers, parameters, and more.
The response will be a JSON object with an endpoint
key. This will be set to an object containing the standard CDN endpoint attributes.
Click to expand an example response for CDN Endpoint.
{
"value" : {
"endpoint" : {
"id" : "19f06b6a-3ace-4315-b086-499a0e521b76" ,
"origin" : "static-images.nyc3.digitaloceanspaces.com" ,
"endpoint" : "static-images.nyc3.cdn.digitaloceanspaces.com" ,
"created_at" : "2018-07-19T15:04:16Z" ,
"ttl" : 3600
}
}
}
Click to expand an example response for CDN Endpoint With Custom Domain.
{
"value" : {
"endpoint" : {
"id" : "19f06b6a-3ace-4315-b086-499a0e521b76" ,
"origin" : "static-images.nyc3.digitaloceanspaces.com" ,
"endpoint" : "static-images.nyc3.cdn.digitaloceanspaces.com" ,
"created_at" : "2018-07-19T15:04:16Z" ,
"certificate_id" : "892071a0-bb95-49bc-8021-3afd67a210bf" ,
"custom_domain" : "static.example.com" ,
"ttl" : 3600
}
}
}
Unauthorized
Click to expand an example response.
{
"id" : "unauthorized" ,
"message" : "Unable to authenticate you."
}
API Rate limit exceeded
Click to expand an example response.
{
"id" : "too_many_requests" ,
"message" : "API Rate limit exceeded."
}
Server error.
Click to expand an example response.
{
"id" : "server_error" ,
"message" : "Unexpected server-side error"
}
Unexpected error
Click to expand an example response.
{
"id" : "example_error" ,
"message" : "some error message"
}