export type GetApiApiV3TeamsTeamIdAuditLogArgs = {team_id: string}; export type GetApiApiV3TeamsTeamIdAuditLogOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download team audit log as CSV * * GET /api/v3/teams/{team_id}/audit-log */ export const getApiApiV3TeamsTeamIdAuditLog = async (args: GetApiApiV3TeamsTeamIdAuditLogArgs, options?: GetApiApiV3TeamsTeamIdAuditLogOptions) => { const {baseUrl = "https://codemagic.io", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/csv") if (apiKey !== undefined) headers.set("x-auth-token", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/api/v3/teams/${encodeURIComponent(String(args.team_id))}/audit-log${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.text() };