//native
type Cockroachdb = {
token: string;
};
/**
* Get an API Key by ID
* Can be used by the following roles assigned at the organization scope:
- ORG_ADMIN
- CLUSTER_ADMIN
*/
export async function main(auth: Cockroachdb, id: string) {
const url = new URL(`https://cockroachlabs.cloud/api/v1/api-keys/${id}`);
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 235 days ago