export type TestSessionsV1CancelRequest = {sequenceId?: Array | undefined}; export type CreateApiV1TestSessionsTestSessionIdCancelArgs = {testSessionId: string, 'x-checkly-account'?: string | undefined, body: TestSessionsV1CancelRequest}; export type CreateApiV1TestSessionsTestSessionIdCancelOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Cancel a test session * * POST /v1/test-sessions/{testSessionId}/cancel */ export const createApiV1TestSessionsTestSessionIdCancel = async (args: CreateApiV1TestSessionsTestSessionIdCancelArgs, options?: CreateApiV1TestSessionsTestSessionIdCancelOptions) => { const {baseUrl = "https://api.checklyhq.com", fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['x-checkly-account'] != null) headers.set("x-checkly-account", String(args['x-checkly-account'])) if (Bearer !== undefined) headers.set('authorization', `Bearer ${Bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/test-sessions/${encodeURIComponent(String(args.testSessionId))}/cancel${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 };