export type BulkTransferToStorageSchema = {allow_duplicate_transfers?: boolean | undefined, delete_only_from_source_folder?: boolean | undefined, delete_original?: boolean | undefined, file_path?: (string | null) | undefined, format_name?: string | undefined, keep_collection_structure?: boolean | undefined, keep_parent_collection_structure?: boolean | undefined, object_ids: Array, object_type: 'assets' | 'collections' | 'playlists' | 'saved_searches', overwrite?: boolean | undefined, preferred_original_storage_id?: (string | null) | undefined}; export type CreateApiV1StoragesStorageIdBulkArgs = {'Auth-Token': string, 'App-ID': string, storage_id: string, allow_host_transfer?: boolean | undefined, body: BulkTransferToStorageSchema}; export type CreateApiV1StoragesStorageIdBulkOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Queue copying of files from current storage to specified one * * POST /v1/storages/{storage_id}/bulk/ */ export const createApiV1StoragesStorageIdBulk = async (args: CreateApiV1StoragesStorageIdBulkArgs, options: CreateApiV1StoragesStorageIdBulkOptions) => { 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(/\/+$/, '')}/v1/storages/${encodeURIComponent(String(args.storage_id))}/bulk/${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 };