export type GetApiApiV1AlertsAlertPkRootCauseArgs = {pk: string}; export type GetApiApiV1AlertsAlertPkRootCauseOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Get the details of an alert for a specific location along with any root cause analysis data * * GET /api/v1/alerts/alert/{pk}/root-cause/ */ export const getApiApiV1AlertsAlertPkRootCause = async (args: GetApiApiV1AlertsAlertPkRootCauseArgs, options: GetApiApiV1AlertsAlertPkRootCauseOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/alerts/alert/${encodeURIComponent(String(args.pk))}/root-cause/${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 undefined };