|
5 | 5 | from requests_toolbelt.sessions import BaseUrlSession |
6 | 6 | from time import sleep, time |
7 | 7 | from typing import Optional, Iterator |
| 8 | +from warnings import warn |
8 | 9 |
|
9 | 10 | from codeocean.components import Ownership, SortOrder, SearchFilter, Permissions |
10 | 11 | from codeocean.computation import PipelineProcess, Param |
11 | 12 | from codeocean.enum import StrEnum |
12 | | -from codeocean.folder import Folder, DownloadFileURL |
| 13 | +from codeocean.folder import FileURLs, Folder, DownloadFileURL |
13 | 14 |
|
14 | 15 |
|
15 | 16 | class DataAssetType(StrEnum): |
@@ -849,14 +850,32 @@ def list_data_asset_files(self, data_asset_id: str, path: str = "") -> Folder: |
849 | 850 | return Folder.from_dict(res.json()) |
850 | 851 |
|
851 | 852 | def get_data_asset_file_download_url(self, data_asset_id: str, path: str) -> DownloadFileURL: |
852 | | - """Generate a download URL for a specific file from an internal data asset.""" |
| 853 | + """(Deprecated) Generate a download URL for a specific file from an internal data asset. |
| 854 | +
|
| 855 | + Deprecated: Use get_data_asset_file_urls instead. |
| 856 | + """ |
| 857 | + warn( |
| 858 | + "get_data_asset_file_download_url is deprecated and will be removed in a future release. " |
| 859 | + "Use get_data_asset_file_urls instead.", |
| 860 | + DeprecationWarning, |
| 861 | + stacklevel=2, |
| 862 | + ) |
853 | 863 | res = self.client.get( |
854 | 864 | f"data_assets/{data_asset_id}/files/download_url", |
855 | 865 | params={"path": path}, |
856 | 866 | ) |
857 | 867 |
|
858 | 868 | return DownloadFileURL.from_dict(res.json()) |
859 | 869 |
|
| 870 | + def get_data_asset_file_urls(self, data_asset_id: str, path: str) -> FileURLs: |
| 871 | + """Generate view and download URLs for a specific file from an internal data asset.""" |
| 872 | + res = self.client.get( |
| 873 | + f"data_assets/{data_asset_id}/files/urls", |
| 874 | + params={"path": path}, |
| 875 | + ) |
| 876 | + |
| 877 | + return FileURLs.from_dict(res.json()) |
| 878 | + |
860 | 879 | def transfer_data_asset(self, data_asset_id: str, transfer_params: TransferDataParams): |
861 | 880 | """ |
862 | 881 | Transfer a data asset's files to a different S3 storage location (Admin only). |
|
0 commit comments