//native
type Digitalocean = {
token: string;
};
/**
* Add a New Connection Pool (PostgreSQL)
* For PostgreSQL database clusters, connection pools can be used to allow a
database to share its idle connections.
*/
export async function main(
auth: Digitalocean,
database_cluster_uuid: string,
body: {
name: string;
mode: string;
size: number;
db: string;
user?: string;
connection?: {
uri?: string;
database?: string;
host?: string;
port?: number;
user?: string;
password?: string;
ssl?: false | true;
} & {};
private_connection?: {
uri?: string;
database?: string;
host?: string;
port?: number;
user?: string;
password?: string;
ssl?: false | true;
} & {};
standby_connection?: {
uri?: string;
database?: string;
host?: string;
port?: number;
user?: string;
password?: string;
ssl?: false | true;
} & {};
standby_private_connection?: {
uri?: string;
database?: string;
host?: string;
port?: number;
user?: string;
password?: string;
ssl?: false | true;
} & {};
},
) {
const url = new URL(
`https://api.digitalocean.com/v2/databases/${database_cluster_uuid}/pools`,
);
const response = await fetch(url, {
method: "POST",
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