//native
type Digitalocean = {
token: string;
};
/**
* Selectively Delete a Cluster and its Associated Resources
* To delete a Kubernetes cluster along with a subset of its associated resources,
send a DELETE request to `/v2/kubernetes/clusters/$K8S_CLUSTER_ID/destroy_with_associated_resources/selective`.
*/
export async function main(
auth: Digitalocean,
cluster_id: string,
body: {
load_balancers?: string[];
volumes?: string[];
volume_snapshots?: string[];
},
) {
const url = new URL(
`https://api.digitalocean.com/v2/kubernetes/clusters/${cluster_id}/destroy_with_associated_resources/selective`,
);
const response = await fetch(url, {
method: "DELETE",
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