export type UpdateApiTeamsIdUsersUserIdArgs = {Accept: string, 'Content-Type': 'application/json', id: string, user_id: string, body: {role?: ('observer' | 'responder' | 'manager') | undefined}}; export type UpdateApiTeamsIdUsersUserIdOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Add a user to a team * * PUT /teams/{id}/users/{user_id} */ export const updateApiTeamsIdUsersUserId = async (args: UpdateApiTeamsIdUsersUserIdArgs, options?: UpdateApiTeamsIdUsersUserIdOptions) => { const {baseUrl = "https://api.pagerduty.com", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.Accept != null) headers.set("Accept", String(args.Accept)) if (args['Content-Type'] != null) headers.set("Content-Type", String(args['Content-Type'])) if (apiKey !== undefined) headers.set("Authorization", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/teams/${encodeURIComponent(String(args.id))}/users/${encodeURIComponent(String(args.user_id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };