export type CreateIncidentRequestModel = {provider_id: string, http_url: string, title: string, issued_at: string, started_at?: string | undefined, ended_at?: string | undefined, git_ref?: string | undefined, teams?: Array | undefined, services?: Array | undefined, repository_urls?: Array | undefined}; export type CreateApiApiV1IncidentsArgs = {body: CreateIncidentRequestModel}; export type CreateApiApiV1IncidentsOptions = {baseUrl?: string | undefined, APIKeyHeader?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create Incident * * POST /api/v1/incidents */ export const createApiApiV1Incidents = async (args: CreateApiApiV1IncidentsArgs, options?: CreateApiApiV1IncidentsOptions) => { const {baseUrl = "https://public-api.linearb.io", fetch: fetchFn = fetch, APIKeyHeader} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (APIKeyHeader !== undefined) headers.set("x-api-key", APIKeyHeader) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/incidents${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", 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 };