evo-files 0.2.3__py3-none-any.whl → 0.2.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
evo/files/client.py CHANGED
@@ -15,7 +15,16 @@ from pathlib import PurePosixPath
15
15
  from uuid import UUID
16
16
 
17
17
  from evo import logging
18
- from evo.common import APIConnector, BaseAPIClient, Environment, HealthCheckType, Page, ServiceHealth, ServiceUser
18
+ from evo.common import (
19
+ APIConnector,
20
+ BaseAPIClient,
21
+ Environment,
22
+ HealthCheckType,
23
+ Page,
24
+ ServiceHealth,
25
+ ServiceUser,
26
+ )
27
+ from evo.common.data import EmptyResponse
19
28
  from evo.common.utils import get_service_health
20
29
 
21
30
  from .data import FileMetadata, FileVersion
@@ -123,6 +132,7 @@ class FileAPIClient(BaseAPIClient):
123
132
  offset: int = 0,
124
133
  limit: int = 5000,
125
134
  name: str | None = None,
135
+ deleted: bool = False,
126
136
  ) -> Page[FileMetadata]:
127
137
  """List up to `limit` files in the workspace, starting at `offset`.
128
138
 
@@ -132,6 +142,7 @@ class FileAPIClient(BaseAPIClient):
132
142
  :param offset: The number of files to skip before listing.
133
143
  :param limit: Max number of files to list.
134
144
  :param name: Filter files by name.
145
+ :param deleted: Only include deleted files in the listing.
135
146
 
136
147
  :return: A page of all files from the query.
137
148
  """
@@ -143,6 +154,7 @@ class FileAPIClient(BaseAPIClient):
143
154
  limit=limit,
144
155
  offset=offset,
145
156
  file_name=name,
157
+ deleted=deleted,
146
158
  )
147
159
  return Page(
148
160
  offset=offset,
@@ -151,20 +163,23 @@ class FileAPIClient(BaseAPIClient):
151
163
  items=[self._metadata_from_listed_file(file) for file in response.files],
152
164
  )
153
165
 
154
- async def list_all_files(self, limit_per_request: int = 5000, name: str | None = None) -> list[FileMetadata]:
166
+ async def list_all_files(
167
+ self, limit_per_request: int = 5000, name: str | None = None, deleted: bool = False
168
+ ) -> list[FileMetadata]:
155
169
  """List all files in the workspace.
156
170
 
157
171
  This method makes multiple calls to the `list_files` endpoint until all files have been listed.
158
172
 
159
173
  :param limit_per_request: The maximum number of files to list in one request.
160
174
  :param name: Filter files by name.
175
+ :param deleted: Only include deleted files in the listing.
161
176
 
162
177
  :return: A list of all files in the workspace.
163
178
  """
164
179
  items = []
165
180
  offset = 0
166
181
  while True:
167
- page = await self.list_files(offset=offset, limit=limit_per_request, name=name)
182
+ page = await self.list_files(offset=offset, limit=limit_per_request, name=name, deleted=deleted)
168
183
  items += page.items()
169
184
  if page.is_last:
170
185
  break
@@ -186,11 +201,12 @@ class FileAPIClient(BaseAPIClient):
186
201
  )
187
202
  return self._metadata_from_endpoint_model(file_response)
188
203
 
189
- async def get_file_by_id(self, file_id: UUID, version_id: str | None = None) -> FileMetadata:
204
+ async def get_file_by_id(self, file_id: UUID, version_id: str | None = None, deleted: bool = False) -> FileMetadata:
190
205
  """Get a file by its ID.
191
206
 
192
207
  :param file_id: UUID of a file
193
208
  :param version_id: ID of the desired file version. By default, the response will return the latest version.
209
+ :param deleted: Optional flag to include deleted files.
194
210
  :return: A FileMetadata representation of the file on the service
195
211
  """
196
212
  file_response = await self._api.get_file_by_id(
@@ -198,6 +214,7 @@ class FileAPIClient(BaseAPIClient):
198
214
  workspace_id=str(self._environment.workspace_id),
199
215
  file_id=str(file_id),
200
216
  version_id=version_id,
217
+ deleted=deleted,
201
218
  )
202
219
  return self._metadata_from_endpoint_model(file_response)
203
220
 
@@ -215,10 +232,11 @@ class FileAPIClient(BaseAPIClient):
215
232
  )
216
233
  return _versions_from_listed_versions(file_response.versions)
217
234
 
218
- async def list_versions_by_id(self, file_id: UUID) -> list[FileVersion]:
235
+ async def list_versions_by_id(self, file_id: UUID, deleted: bool = False) -> list[FileVersion]:
219
236
  """List the versions of a file by ID
220
237
 
221
238
  :param file_id: UUID of the file.
239
+ :param deleted: Optional flag to include deleted files.
222
240
  :return: A sorted list of file versions. The latest version is the first element of the list.
223
241
  """
224
242
  file_response = await self._api.get_file_by_id(
@@ -226,6 +244,7 @@ class FileAPIClient(BaseAPIClient):
226
244
  workspace_id=str(self._environment.workspace_id),
227
245
  file_id=str(file_id),
228
246
  include_versions=True,
247
+ deleted=deleted,
229
248
  )
230
249
  return _versions_from_listed_versions(file_response.versions)
231
250
 
@@ -246,12 +265,14 @@ class FileAPIClient(BaseAPIClient):
246
265
  metadata = self._metadata_from_endpoint_model(response)
247
266
  return FileAPIDownload(connector=self._connector, metadata=metadata, initial_url=response.download)
248
267
 
249
- async def prepare_download_by_id(self, file_id: UUID, version_id: str | None = None) -> FileAPIDownload:
268
+ async def prepare_download_by_id(
269
+ self, file_id: UUID, version_id: str | None = None, deleted: bool = False
270
+ ) -> FileAPIDownload:
250
271
  """Prepares a file for download by ID.
251
272
 
252
273
  :param file_id: UUID of the file.
253
274
  :param version_id: Version of the file.
254
-
275
+ :param deleted: Optional flag to include deleted files.
255
276
  :return: A FileAPIDownload object.
256
277
  """
257
278
  response = await self._api.get_file_by_id(
@@ -259,6 +280,7 @@ class FileAPIClient(BaseAPIClient):
259
280
  workspace_id=str(self._environment.workspace_id),
260
281
  file_id=str(file_id),
261
282
  version_id=version_id,
283
+ deleted=deleted,
262
284
  )
263
285
  metadata = self._metadata_from_endpoint_model(response)
264
286
  return FileAPIDownload(connector=self._connector, metadata=metadata, initial_url=response.download)
@@ -304,6 +326,30 @@ class FileAPIClient(BaseAPIClient):
304
326
  initial_url=response.upload,
305
327
  )
306
328
 
329
+ async def restore_file_by_id(self, file_id: UUID) -> FileMetadata | None:
330
+ """Restore a deleted file by ID.
331
+
332
+ :param file_id: UUID of the file.
333
+
334
+ :return: FileMetadata if the file path changed during restore (HTTP 303),
335
+ None if the file was restored without path change (HTTP 204).
336
+ """
337
+ response = await self._api.update_file_by_id(
338
+ organisation_id=str(self._environment.org_id),
339
+ workspace_id=str(self._environment.workspace_id),
340
+ file_id=str(file_id),
341
+ deleted=False,
342
+ )
343
+
344
+ if isinstance(response, DownloadFileResponse):
345
+ # HTTP 303: File restored with path change (e.g., rename on restore)
346
+ return self._metadata_from_endpoint_model(response)
347
+ elif isinstance(response, EmptyResponse):
348
+ # HTTP 204: File restored without path change
349
+ return None
350
+ else:
351
+ return None
352
+
307
353
  async def delete_file_by_path(self, path: str) -> None:
308
354
  """Deletes a file by path.
309
355
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: evo-files
3
- Version: 0.2.3
3
+ Version: 0.2.4
4
4
  Summary: Python SDK for using the Seequent Evo File API
5
5
  Project-URL: Source, https://github.com/SeequentEvo/evo-python-sdk
6
6
  Project-URL: Tracker, https://github.com/SeequentEvo/evo-python-sdk/issues
@@ -1,6 +1,6 @@
1
1
  evo/files/__init__.py,sha256=jX2_a4BNg92QZFNEXaBpvpcSgbqRyOXrWx1JIkLUZqk,887
2
2
  evo/files/_model_config.py,sha256=612yrPQyY-vquEboZdmSWkt8nT2ttbfBy476FyruV30,827
3
- evo/files/client.py,sha256=-zfbeym3l9_3t-OjenWj-1k5ZVpLtpsNdmTiMi3PUVU,12847
3
+ evo/files/client.py,sha256=K0xYOrN6-B5CGE9ICXYmTs8o70SlpUAPh_uOAyQs3XE,14485
4
4
  evo/files/data.py,sha256=J9hieUY6LAeYhmIpRorMNcgjsYuSsO5R7_s1qnDAIlM,2380
5
5
  evo/files/io.py,sha256=wlHEXusTOhSRLCU1FWUD4q0p7xiav6VPVEWNP4I40xk,6689
6
6
  evo/files/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -8,7 +8,7 @@ evo/files/endpoints/__init__.py,sha256=R2TBKqKH94CPUgEuftAAdm_gVp24Eepzv6romBDkD
8
8
  evo/files/endpoints/models.py,sha256=rz7wqkhfen9_wqQqj0mEUbKKnkA0AYniEe9QnoigdPY,4640
9
9
  evo/files/endpoints/api/__init__.py,sha256=dHngHmRPwy-Kixoz7BP4ur4qzV4z9T2e8ccTqBtpuio,650
10
10
  evo/files/endpoints/api/file_v2_api.py,sha256=1eLvxPuJuB_24u_pdPow-Dcsw8vP-nW0ghsAnzyt7qU,34401
11
- evo_files-0.2.3.dist-info/METADATA,sha256=suQ3vq7fFWUGfScEP_cmsqx0VrpFbkd4mLjk-eNFgEA,3703
12
- evo_files-0.2.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
13
- evo_files-0.2.3.dist-info/licenses/LICENSE.md,sha256=HcFeRdOI-VP5WPEymQerlwLvEj2z_1Yh66RkN-wN7Oc,10778
14
- evo_files-0.2.3.dist-info/RECORD,,
11
+ evo_files-0.2.4.dist-info/METADATA,sha256=QnaVgwpaB8yY2yFaBZupKAoKy1rLXS3v0Z13KzMmqCs,3703
12
+ evo_files-0.2.4.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
13
+ evo_files-0.2.4.dist-info/licenses/LICENSE.md,sha256=HcFeRdOI-VP5WPEymQerlwLvEj2z_1Yh66RkN-wN7Oc,10778
14
+ evo_files-0.2.4.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.27.0
2
+ Generator: hatchling 1.28.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any