export type OnCallPageTargetType = 'team_id' | 'team_handle' | 'user_id'; export type CreatePageRequestDataAttributesTarget = {identifier?: string | undefined, type?: OnCallPageTargetType | undefined}; export type RerouteOnCallPageRequestDataAttributes = {comment?: string | undefined, target: CreatePageRequestDataAttributesTarget}; export type RerouteOnCallPageRequestDataType = 'reroute'; export type RerouteOnCallPageRequestData = {attributes: RerouteOnCallPageRequestDataAttributes, type: RerouteOnCallPageRequestDataType}; export type RerouteOnCallPageRequest = {data: RerouteOnCallPageRequestData}; export type CreateApiApiV2OnCallPagesPageIdRerouteArgs = {page_id: string, body: RerouteOnCallPageRequest}; export type CreateApiApiV2OnCallPagesPageIdRerouteOptions = {baseUrl?: string | undefined, apiKeyAuth?: string | undefined, appKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Reroute On-Call Page * * POST /api/v2/on-call/pages/{page_id}/reroute * * Also accepts auth: AuthZ */ export const createApiApiV2OnCallPagesPageIdReroute = async (args: CreateApiApiV2OnCallPagesPageIdRerouteArgs, options?: CreateApiApiV2OnCallPagesPageIdRerouteOptions) => { const {baseUrl = "https://navy.oncall.datadoghq.com", fetch: fetchFn = fetch, apiKeyAuth, appKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (apiKeyAuth !== undefined) headers.set("DD-API-KEY", apiKeyAuth) if (appKeyAuth !== undefined) headers.set("DD-APPLICATION-KEY", appKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/api/v2/on-call/pages/${encodeURIComponent(String(args.page_id))}/reroute${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 };