//native
/**
* List Users
* List users in your org. Filter with a SCIM `filter` expression, a free-text `search`, or a simple `q` startsWith match on name/email. Page with `limit` (default 200) and the `after` cursor from the previous response's Link header.
*/
export async function main(
auth: RT.Okta,
q: string | undefined,
filter: string | undefined,
search: string | undefined,
limit: number | undefined,
after: string | undefined
) {
const url = new URL(`${auth.org_url}/api/v1/users`)
if (q !== undefined && q !== "") url.searchParams.append("q", q)
if (filter !== undefined && filter !== "")
url.searchParams.append("filter", filter)
if (search !== undefined && search !== "")
url.searchParams.append("search", search)
if (limit !== undefined) url.searchParams.append("limit", String(limit))
if (after !== undefined && after !== "")
url.searchParams.append("after", after)
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: `SSWS ${auth.token}`,
Accept: "application/json",
},
})
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 6 days ago