//native
type Planetscale = {
serviceTokenId: string;
serviceToken: string;
};
/**
* Delete a database
*
### Authorization
A service token or OAuth token must have at least one of the following access or scopes in order to use this API endpoint:
**Service Token Accesses**
`delete_database`
**OAuth Scopes**
| Resource | Scopes |
| :------- | :---------- |
| Organization | `delete_databases` |
| Database | `delete_database` |
*/
export async function main(
auth: Planetscale,
organization: string,
name: string,
) {
const url = new URL(
`https://api.planetscale.com/v1/organizations/${organization}/databases/${name}`,
);
const response = await fetch(url, {
method: "DELETE",
headers: {
Authorization: `${auth.serviceTokenId}:${auth.serviceToken}`,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.text();
}
Submitted by hugo697 235 days ago