//native
type Digitalocean = {
token: string;
};
/**
* Create Logging Destination
* To create a new destination, send a POST request to `/v2/monitoring/sinks/destinations`.
*/
export async function main(
auth: Digitalocean,
body: {
name?: string;
type: "opensearch_dbaas" | "opensearch_ext";
config: {
credentials?: { username?: string; password?: string };
endpoint: string;
cluster_uuid?: string;
cluster_name?: string;
index_name?: string;
retention_days?: number;
};
},
) {
const url = new URL(
`https://api.digitalocean.com/v2/monitoring/sinks/destinations`,
);
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 537 days ago