//native
type Segment = {
token: string;
baseUrl: string;
};
/**
* List Functions
* Lists all Functions in a Workspace.
• In order to successfully call this endpoint, the specified Workspace needs to have the Functions feature enabled. Please reach out to your customer success manager for more information.
*/
export async function main(
auth: Segment,
pagination: string | undefined,
resourceType:
| "DESTINATION"
| "INSERT_DESTINATION"
| "INSERT_SOURCE"
| "SOURCE"
| undefined,
) {
const url = new URL(`${auth.baseUrl}/functions`);
for (const [k, v] of [
["pagination", pagination],
["resourceType", resourceType],
]) {
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 235 days ago