//native
type Digitalocean = {
token: string;
};
/**
* Create Sink
* To create a new sink, send a POST request to `/v2/monitoring/sinks`. Forwards logs from the
resources identified in `resources` to the specified pre-existing destination.
*/
export async function main(
auth: Digitalocean,
body: {
destination_uuid?: string;
resources?: { urn: string; name?: string }[];
},
) {
const url = new URL(`https://api.digitalocean.com/v2/monitoring/sinks`);
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