//native
type Vercel = {
token: string;
};
/**
* Retrieves a list of all the Log Drains
* Retrieves a list of all the Log Drains owned by the account. This endpoint must be called with an account AccessToken (integration OAuth2 clients are not allowed). Only log drains owned by the authenticated account can be accessed.
*/
export async function main(
auth: Vercel,
projectId: string | undefined,
projectIdOrName: string | undefined,
teamId: string | undefined,
slug: string | undefined,
) {
const url = new URL(`https://api.vercel.com/v1/log-drains`);
for (const [k, v] of [
["projectId", projectId],
["projectIdOrName", projectIdOrName],
["teamId", teamId],
["slug", slug],
]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
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 428 days ago