export type GetApiApiAuditLogsExportArgs = {projectId?: string | undefined, userId?: string | undefined, fromDate?: string | undefined, toDate?: string | undefined}; export type GetApiApiAuditLogsExportOptions = {baseUrl: string, personalAccessToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * Export audit logs * * GET /api/audit-logs/export * * Also accepts auth: internalAuth */ export const getApiApiAuditLogsExport = async (args: GetApiApiAuditLogsExportArgs, options: GetApiApiAuditLogsExportOptions) => { const {baseUrl, fetch: fetchFn = fetch, personalAccessToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/csv") if (args.projectId != null) query.append("projectId", String(args.projectId)) if (args.userId != null) query.append("userId", String(args.userId)) if (args.fromDate != null) query.append("fromDate", String(args.fromDate)) if (args.toDate != null) query.append("toDate", String(args.toDate)) if (personalAccessToken !== undefined) headers.set('authorization', `Bearer ${personalAccessToken}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/audit-logs/export${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() };