export type ApplyRequest = {operations: {add?: Array | undefined, remove?: Array | undefined}, objects: {annotations?: Array | undefined}}; export type CreateApiApiV1LabelsApplyArgs = {body: ApplyRequest}; export type CreateApiApiV1LabelsApplyOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Add/remove annotation labels * * POST /api/v1/labels/apply */ export const createApiApiV1LabelsApply = async (args: CreateApiApiV1LabelsApplyArgs, options?: CreateApiApiV1LabelsApplyOptions) => { const {baseUrl = "https://example.rossum.app", fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/labels/apply${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 };