//native
/**
* List Services
* List services (systems/apps that generate incidents), optionally filtered by a search query or team IDs.
*/
export async function main(
auth: RT.Pagerduty,
query: string | undefined,
team_ids: string[] | undefined,
limit: number | undefined,
offset: number | undefined,
) {
const url = new URL("https://api.pagerduty.com/services")
if (query !== undefined && query !== "") url.searchParams.append("query", query)
if (team_ids) for (const t of team_ids) url.searchParams.append("team_ids[]", t)
if (limit !== undefined) url.searchParams.append("limit", String(limit))
if (offset !== undefined) url.searchParams.append("offset", String(offset))
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: `Token token=${auth.token}`,
Accept: "application/vnd.pagerduty+json;version=2",
},
})
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 5 days ago