type Bitbucket = {
username: string;
password: string;
};
/**
* Delete a SSH key
* Deletes a specific SSH public key from a user's account.
*/
export async function main(
auth: Bitbucket,
key_id: string,
selected_user: string
) {
const url = new URL(
`https://api.bitbucket.org/2.0/users/${selected_user}/ssh-keys/${key_id}`
);
const response = await fetch(url, {
method: "DELETE",
headers: {
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.text();
}
Submitted by hugo697 401 days ago
type Bitbucket = {
username: string;
password: string;
};
/**
* Delete a SSH key
* Deletes a specific SSH public key from a user's account
Example:
```
$ curl -X DELETE https://api.bitbucket.org/2.0/users/{ed08f5e1-605b-4f4a-aee4-6c97628a673e}/ssh-keys/{b15b6026-9c02-4626-b4ad-b905f99f763a}
```
*/
export async function main(
auth: Bitbucket,
key_id: string,
selected_user: string
) {
const url = new URL(
`https://api.bitbucket.org/2.0/users/${selected_user}/ssh-keys/${key_id}`
);
const response = await fetch(url, {
method: "DELETE",
headers: {
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.text();
}
Submitted by hugo697 407 days ago