export type RestoreCollectionToStorageRequest = {all_versions?: boolean | undefined, destination_directory_path?: (string | null) | undefined, formats?: Array | undefined, id: string, keep_collection_structure?: boolean | undefined, keep_parent_collection_structure?: boolean | undefined, preferred_original_storage_id?: (string | null) | undefined, restore_priority?: ('LOW' | 'MID' | 'HIGH' | 'null' | null) | undefined, version_ids?: Array | undefined}; export type BulkRestoreCollectionRequestSchema = {destination_storage_id?: (string | null) | undefined, objects?: Array | undefined}; export type CreateApiV2CollectionsBulkRestoreArgs = {'Auth-Token': string, 'App-ID': string, allow_host_transfer?: boolean | undefined, body: BulkRestoreCollectionRequestSchema}; export type CreateApiV2CollectionsBulkRestoreOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Restore multiple collections to a storage. * * POST /v2/collections/bulk/restore/ */ export const createApiV2CollectionsBulkRestore = async (args: CreateApiV2CollectionsBulkRestoreArgs, options: CreateApiV2CollectionsBulkRestoreOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['Auth-Token'] != null) headers.set("Auth-Token", String(args['Auth-Token'])) if (args['App-ID'] != null) headers.set("App-ID", String(args['App-ID'])) if (args.allow_host_transfer != null) query.append("allow_host_transfer", String(args.allow_host_transfer)) const url = `${baseUrl.replace(/\/+$/, '')}/v2/collections/bulk/restore/${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 };