//native
type Digitalocean = {
token: string;
};
/**
* Update a CDN Endpoint
* 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`.
*/
export async function main(
auth: Digitalocean,
cdn_id: string,
body: {
ttl?: 60 | 600 | 3600 | 86400 | 604800;
certificate_id?: string;
custom_domain?: string;
},
) {
const url = new URL(
`https://api.digitalocean.com/v2/cdn/endpoints/${cdn_id}`,
);
const response = await fetch(url, {
method: "PUT",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 536 days ago