//native
type Digitalocean = {
token: string;
};
/**
* Update Database Clusters' Metrics Endpoint Credentials
* To update the credentials for all database clusters' metrics endpoints, send a PUT request to `/v2/databases/metrics/credentials`. A successful request will receive a 204 No Content status code with no body in response.
*/
export async function main(
auth: Digitalocean,
body: {
credentials?: {
basic_auth_username?: string;
basic_auth_password?: string;
};
},
) {
const url = new URL(
`https://api.digitalocean.com/v2/databases/metrics/credentials`,
);
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