export type SourceContext = {external_id?: (string | null) | undefined, root_collection_path?: (string | null) | undefined, root_collection_storage_id?: (string | null) | undefined, storage_id?: (string | null) | undefined}; export type TransferCollectionToStorageRequest = {all_versions?: boolean | undefined, delete_only_from_source?: boolean | undefined, delete_only_from_source_context?: SourceContext | undefined, delete_original?: 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}; export type BulkTransferCollectionRequestSchema = {objects?: Array | undefined}; export type CreateApiV2CollectionsStoragesStorageIdBulkTransferArgs = {'Auth-Token': string, 'App-ID': string, storage_id: string, allow_host_transfer?: boolean | undefined, body: BulkTransferCollectionRequestSchema}; export type CreateApiV2CollectionsStoragesStorageIdBulkTransferOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Transfer multiple objects. * * POST /v2/collections/storages/{storage_id}/bulk/transfer/ */ export const createApiV2CollectionsStoragesStorageIdBulkTransfer = async (args: CreateApiV2CollectionsStoragesStorageIdBulkTransferArgs, options: CreateApiV2CollectionsStoragesStorageIdBulkTransferOptions) => { 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/storages/${encodeURIComponent(String(args.storage_id))}/bulk/transfer/${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 };