//native
type Digitalocean = {
token: string;
};
/**
* Delete an SSH Key
* To destroy a public SSH key that you have in your account, send a DELETE request to `/v2/account/keys/$KEY_ID` or `/v2/account/keys/$KEY_FINGERPRINT`.
A 204 status will be returned, indicating that the action was successful and that the response body is empty.
*/
export async function main(auth: Digitalocean, ssh_key_identifier: string) {
const url = new URL(
`https://api.digitalocean.com/v2/account/keys/${ssh_key_identifier}`,
);
const response = await fetch(url, {
method: "DELETE",
headers: {
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 536 days ago