//native
type Digitalocean = {
token: string;
};
/**
* Retrieve an Existing Database User
* To show information about an existing database user, send a GET request to
`/v2/databases/$DATABASE_ID/users/$USERNAME`.
Note: User management is not supported for Redis clusters.
The response will be a JSON object with a `user` key. This will be set to an object
containing the standard database user attributes.
For MySQL clusters, additional options will be contained in the `mysql_settings`
object.
For Kafka clusters, additional options will be contained in the `settings` object.
*/
export async function main(
auth: Digitalocean,
database_cluster_uuid: string,
username: string,
) {
const url = new URL(
`https://api.digitalocean.com/v2/databases/${database_cluster_uuid}/users/${username}`,
);
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