evo-files 0.2.2__tar.gz → 0.2.4__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: evo-files
3
- Version: 0.2.2
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,7 +1,7 @@
1
1
  [project]
2
2
  name = "evo-files"
3
3
  description = "Python SDK for using the Seequent Evo File API"
4
- version = "0.2.2"
4
+ version = "0.2.4"
5
5
  requires-python = ">=3.10"
6
6
  license-files = ["LICENSE.md"]
7
7
  dynamic = ["readme"]
@@ -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
 
@@ -24,7 +24,7 @@ For more information on using the File API, see [Overview](https://developer.see
24
24
 
25
25
 
26
26
  This code is generated from the OpenAPI specification for File API.
27
- API version: 2.8.0
27
+ API version: 2.10.0
28
28
  """
29
29
 
30
30
  # Import endpoint apis.
@@ -24,11 +24,12 @@ For more information on using the File API, see [Overview](https://developer.see
24
24
 
25
25
 
26
26
  This code is generated from the OpenAPI specification for File API.
27
- API version: 2.8.0
27
+ API version: 2.10.0
28
28
  """
29
29
 
30
30
  from evo.common.connector import APIConnector
31
31
  from evo.common.data import EmptyResponse, RequestMethod
32
+ from evo.common.utils import get_header_metadata
32
33
 
33
34
  from ..models import * # noqa: F403
34
35
 
@@ -95,7 +96,7 @@ class FileV2Api:
95
96
  }
96
97
 
97
98
  # Prepare the header parameters.
98
- _header_params = {}
99
+ _header_params = {} | get_header_metadata(__name__)
99
100
  if additional_headers is not None:
100
101
  _header_params.update(additional_headers)
101
102
 
@@ -161,7 +162,7 @@ class FileV2Api:
161
162
  }
162
163
 
163
164
  # Prepare the header parameters.
164
- _header_params = {}
165
+ _header_params = {} | get_header_metadata(__name__)
165
166
  if additional_headers is not None:
166
167
  _header_params.update(additional_headers)
167
168
 
@@ -249,7 +250,7 @@ class FileV2Api:
249
250
  # Prepare the header parameters.
250
251
  _header_params = {
251
252
  "Accept": "application/json",
252
- }
253
+ } | get_header_metadata(__name__)
253
254
  if additional_headers is not None:
254
255
  _header_params.update(additional_headers)
255
256
 
@@ -332,7 +333,7 @@ class FileV2Api:
332
333
  # Prepare the header parameters.
333
334
  _header_params = {
334
335
  "Accept": "application/json",
335
- }
336
+ } | get_header_metadata(__name__)
336
337
  if additional_headers is not None:
337
338
  _header_params.update(additional_headers)
338
339
 
@@ -458,7 +459,7 @@ class FileV2Api:
458
459
  # Prepare the header parameters.
459
460
  _header_params = {
460
461
  "Accept": "application/json",
461
- }
462
+ } | get_header_metadata(__name__)
462
463
  if additional_headers is not None:
463
464
  _header_params.update(additional_headers)
464
465
 
@@ -546,7 +547,7 @@ class FileV2Api:
546
547
  # Prepare the header parameters.
547
548
  _header_params = {
548
549
  "Accept": "application/json",
549
- }
550
+ } | get_header_metadata(__name__)
550
551
  if additional_headers is not None:
551
552
  _header_params.update(additional_headers)
552
553
 
@@ -626,7 +627,7 @@ class FileV2Api:
626
627
  # Prepare the header parameters.
627
628
  _header_params = {
628
629
  "Accept": "application/json",
629
- }
630
+ } | get_header_metadata(__name__)
630
631
  if additional_headers is not None:
631
632
  _header_params.update(additional_headers)
632
633
 
File without changes
File without changes
File without changes