//native
type Digitalocean = {
token: string;
};
/**
* Retrieve an Existing SSH Key
* To get information about a key, send a GET request to `/v2/account/keys/$KEY_ID` or `/v2/account/keys/$KEY_FINGERPRINT`.
The response will be a JSON object with the key `ssh_key` and value an ssh_key object which contains the standard ssh_key attributes.
*/
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: "GET",
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 537 days ago