//native
type Digitalocean = {
token: string;
};
/**
* Update Garbage Collection
* To cancel the currently-active garbage collection for a registry, send a PUT request to `/v2/registry/$REGISTRY_NAME/garbage-collection/$GC_UUID` and specify one or more of the attributes below.
*/
export async function main(
auth: Digitalocean,
registry_name: string,
garbage_collection_uuid: string,
body: { cancel?: false | true },
) {
const url = new URL(
`https://api.digitalocean.com/v2/registry/${registry_name}/garbage-collection/${garbage_collection_uuid}`,
);
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