pangea-sdk 3.8.0__py3-none-any.whl → 5.3.0__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.
Files changed (51) hide show
  1. pangea/__init__.py +2 -1
  2. pangea/asyncio/__init__.py +1 -0
  3. pangea/asyncio/file_uploader.py +39 -0
  4. pangea/asyncio/request.py +46 -23
  5. pangea/asyncio/services/__init__.py +2 -0
  6. pangea/asyncio/services/audit.py +46 -20
  7. pangea/asyncio/services/authn.py +123 -61
  8. pangea/asyncio/services/authz.py +57 -31
  9. pangea/asyncio/services/base.py +21 -2
  10. pangea/asyncio/services/embargo.py +2 -2
  11. pangea/asyncio/services/file_scan.py +24 -9
  12. pangea/asyncio/services/intel.py +104 -30
  13. pangea/asyncio/services/redact.py +52 -3
  14. pangea/asyncio/services/sanitize.py +217 -0
  15. pangea/asyncio/services/share.py +733 -0
  16. pangea/asyncio/services/vault.py +1709 -766
  17. pangea/crypto/rsa.py +135 -0
  18. pangea/deep_verify.py +7 -1
  19. pangea/dump_audit.py +9 -8
  20. pangea/file_uploader.py +35 -0
  21. pangea/request.py +70 -49
  22. pangea/response.py +36 -17
  23. pangea/services/__init__.py +2 -0
  24. pangea/services/audit/audit.py +57 -29
  25. pangea/services/audit/models.py +12 -3
  26. pangea/services/audit/signing.py +6 -5
  27. pangea/services/audit/util.py +3 -3
  28. pangea/services/authn/authn.py +120 -66
  29. pangea/services/authn/models.py +167 -11
  30. pangea/services/authz.py +53 -30
  31. pangea/services/base.py +16 -2
  32. pangea/services/embargo.py +2 -2
  33. pangea/services/file_scan.py +32 -15
  34. pangea/services/intel.py +155 -30
  35. pangea/services/redact.py +132 -3
  36. pangea/services/sanitize.py +388 -0
  37. pangea/services/share/file_format.py +170 -0
  38. pangea/services/share/share.py +1440 -0
  39. pangea/services/vault/models/asymmetric.py +120 -18
  40. pangea/services/vault/models/common.py +439 -141
  41. pangea/services/vault/models/keys.py +94 -0
  42. pangea/services/vault/models/secret.py +27 -3
  43. pangea/services/vault/models/symmetric.py +68 -22
  44. pangea/services/vault/vault.py +1690 -766
  45. pangea/tools.py +6 -7
  46. pangea/utils.py +94 -33
  47. pangea/verify_audit.py +270 -83
  48. {pangea_sdk-3.8.0.dist-info → pangea_sdk-5.3.0.dist-info}/METADATA +21 -29
  49. pangea_sdk-5.3.0.dist-info/RECORD +56 -0
  50. {pangea_sdk-3.8.0.dist-info → pangea_sdk-5.3.0.dist-info}/WHEEL +1 -1
  51. pangea_sdk-3.8.0.dist-info/RECORD +0 -46
@@ -0,0 +1,733 @@
1
+ # Copyright 2022 Pangea Cyber Corporation
2
+ # Author: Pangea Cyber Corporation
3
+ from __future__ import annotations
4
+
5
+ import io
6
+ from typing import Dict, List, Optional, Tuple, Union
7
+
8
+ import pangea.services.share.share as m
9
+ from pangea.asyncio.services.base import ServiceBaseAsync
10
+ from pangea.config import PangeaConfig
11
+ from pangea.response import PangeaResponse, TransferMethod
12
+ from pangea.services.share.file_format import FileFormat
13
+ from pangea.utils import get_file_size, get_file_upload_params
14
+
15
+
16
+ class ShareAsync(ServiceBaseAsync):
17
+ """Secure Share service client."""
18
+
19
+ service_name = "share"
20
+
21
+ def __init__(
22
+ self, token: str, config: PangeaConfig | None = None, logger_name: str = "pangea", config_id: str | None = None
23
+ ) -> None:
24
+ """
25
+ Secure Share client
26
+
27
+ Initializes a new Secure Share client.
28
+
29
+ Args:
30
+ token: Pangea API token.
31
+ config: Configuration.
32
+ logger_name: Logger name.
33
+ config_id: Configuration ID.
34
+
35
+ Examples:
36
+ config = PangeaConfig(domain="aws.us.pangea.cloud")
37
+ authz = ShareAsync(token="pangea_token", config=config)
38
+ """
39
+
40
+ super().__init__(token, config, logger_name, config_id=config_id)
41
+
42
+ async def buckets(self) -> PangeaResponse[m.BucketsResult]:
43
+ """
44
+ Buckets
45
+
46
+ Get information on the accessible buckets.
47
+
48
+ OperationId: share_post_v1_buckets
49
+
50
+ Returns:
51
+ A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
52
+
53
+ Examples:
54
+ response = share.buckets()
55
+ """
56
+
57
+ return await self.request.post("v1/buckets", m.BucketsResult)
58
+
59
+ async def delete(
60
+ self,
61
+ id: Optional[str] = None,
62
+ force: Optional[bool] = None,
63
+ bucket_id: Optional[str] = None,
64
+ ) -> PangeaResponse[m.DeleteResult]:
65
+ """
66
+ Delete
67
+
68
+ Delete object by ID or path. If both are supplied, the path must match
69
+ that of the object represented by the ID.
70
+
71
+ OperationId: share_post_v1_delete
72
+
73
+ Args:
74
+ id (str, optional): The ID of the object to delete.
75
+ force (bool, optional): If true, delete a folder even if it's not empty.
76
+ bucket_id (str, optional): The bucket to use, if not the default.
77
+
78
+ Returns:
79
+ A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
80
+
81
+ Examples:
82
+ response = await share.delete(id="pos_3djfmzg2db4c6donarecbyv5begtj2bm")
83
+ """
84
+
85
+ input = m.DeleteRequest(id=id, force=force, bucket_id=bucket_id)
86
+ return await self.request.post("v1/delete", m.DeleteResult, data=input.model_dump(exclude_none=True))
87
+
88
+ async def folder_create(
89
+ self,
90
+ name: Optional[str] = None,
91
+ metadata: Optional[m.Metadata] = None,
92
+ parent_id: Optional[str] = None,
93
+ folder: Optional[str] = None,
94
+ tags: Optional[m.Tags] = None,
95
+ bucket_id: Optional[str] = None,
96
+ *,
97
+ file_ttl: Optional[str] = None,
98
+ root_folder: Optional[str] = None,
99
+ root_id: Optional[str] = None,
100
+ tenant_id: Optional[str] = None,
101
+ ) -> PangeaResponse[m.FolderCreateResult]:
102
+ """
103
+ Create a folder
104
+
105
+ Create a folder, either by name or path and parent_id.
106
+
107
+ OperationId: share_post_v1_folder_create
108
+
109
+ Args:
110
+ name (str, optional): The name of an object.
111
+ metadata (Metadata, optional): A set of string-based key/value pairs used to provide additional data about an object.
112
+ parent_id (str, optional): The ID of a stored object.
113
+ folder (str, optional): The folder to place the folder in. Must
114
+ match `parent_id` if also set.
115
+ tags (Tags, optional): A list of user-defined tags.
116
+ bucket_id (str, optional): The bucket to use, if not the default.
117
+ file_ttl: Duration until files within this folder are automatically
118
+ deleted.
119
+ root_folder: The path of a root folder to restrict the operation to. Must resolve to
120
+ `root_id` if also set.
121
+ root_id: The ID of a root folder to restrict the operation to. Must match
122
+ `root_folder` if also set.
123
+ tenant_id: A tenant to associate with this request.
124
+
125
+ Returns:
126
+ A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
127
+
128
+ Examples:
129
+ response = await share.folder_create(
130
+ metadata={
131
+ "created_by": "jim",
132
+ "priority": "medium",
133
+ },
134
+ parent_id="pos_3djfmzg2db4c6donarecbyv5begtj2bm",
135
+ folder="/",
136
+ tags=["irs_2023", "personal"],
137
+ )
138
+ """
139
+
140
+ input = m.FolderCreateRequest(
141
+ name=name,
142
+ metadata=metadata,
143
+ parent_id=parent_id,
144
+ folder=folder,
145
+ tags=tags,
146
+ bucket_id=bucket_id,
147
+ file_ttl=file_ttl,
148
+ root_folder=root_folder,
149
+ root_id=root_id,
150
+ tenant_id=tenant_id,
151
+ )
152
+ return await self.request.post(
153
+ "v1/folder/create", m.FolderCreateResult, data=input.model_dump(exclude_none=True)
154
+ )
155
+
156
+ async def get(
157
+ self,
158
+ id: Optional[str] = None,
159
+ transfer_method: Optional[TransferMethod] = None,
160
+ bucket_id: Optional[str] = None,
161
+ password: Optional[str] = None,
162
+ *,
163
+ tenant_id: Optional[str] = None,
164
+ ) -> PangeaResponse[m.GetResult]:
165
+ """
166
+ Get an object
167
+
168
+ Get object. If both ID and Path are supplied, the call will fail if the
169
+ target object doesn't match both properties.
170
+
171
+ OperationId: share_post_v1_get
172
+
173
+ Args:
174
+ id (str, optional): The ID of the object to retrieve.
175
+ transfer_method (TransferMethod, optional): The requested transfer method for the file data.
176
+ bucket_id (str, optional): The bucket to use, if not the default.
177
+ password (str, optional): If the file was protected with a password, the password to decrypt with.
178
+ tenant_id: A tenant to associate with this request.
179
+
180
+ Returns:
181
+ A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
182
+
183
+ Examples:
184
+ response = await share.get(
185
+ id="pos_3djfmzg2db4c6donarecbyv5begtj2bm",
186
+ folder="/",
187
+ )
188
+ """
189
+
190
+ input = m.GetRequest(
191
+ id=id, transfer_method=transfer_method, bucket_id=bucket_id, password=password, tenant_id=tenant_id
192
+ )
193
+ return await self.request.post("v1/get", m.GetResult, data=input.model_dump(exclude_none=True))
194
+
195
+ async def get_archive(
196
+ self,
197
+ ids: List[str] = [],
198
+ format: Optional[m.ArchiveFormat] = None,
199
+ transfer_method: Optional[TransferMethod] = None,
200
+ bucket_id: Optional[str] = None,
201
+ ) -> PangeaResponse[m.GetArchiveResult]:
202
+ """
203
+ Get archive
204
+
205
+ Get an archive file of multiple objects.
206
+
207
+ OperationId: share_post_v1_get_archive
208
+
209
+ Args:
210
+ ids (List[str]): The IDs of the objects to include in the archive. Folders include all children.
211
+ format (ArchiveFormat, optional): The format to use for the built archive.
212
+ transfer_method (TransferMethod, optional): The requested transfer method for the file data.
213
+ bucket_id (str, optional): The bucket to use, if not the default.
214
+
215
+ Returns:
216
+ A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
217
+
218
+ Examples:
219
+ response = await share.get_archive(
220
+ ids=["pos_3djfmzg2db4c6donarecbyv5begtj2bm"],
221
+ )
222
+ """
223
+
224
+ if (
225
+ transfer_method is not None
226
+ and transfer_method != TransferMethod.DEST_URL
227
+ and transfer_method != TransferMethod.MULTIPART
228
+ ):
229
+ raise ValueError(f"Only {TransferMethod.DEST_URL} and {TransferMethod.MULTIPART} are supported")
230
+
231
+ input = m.GetArchiveRequest(ids=ids, format=format, transfer_method=transfer_method, bucket_id=bucket_id)
232
+ return await self.request.post("v1/get_archive", m.GetArchiveResult, data=input.model_dump(exclude_none=True))
233
+
234
+ async def list(
235
+ self,
236
+ filter: Optional[Union[Dict[str, str], m.FilterList]] = None,
237
+ last: Optional[str] = None,
238
+ order: Optional[m.ItemOrder] = None,
239
+ order_by: Optional[m.ItemOrderBy] = None,
240
+ size: Optional[int] = None,
241
+ bucket_id: Optional[str] = None,
242
+ ) -> PangeaResponse[m.ListResult]:
243
+ """
244
+ List
245
+
246
+ List or filter/search records.
247
+
248
+ OperationId: share_post_v1_list
249
+
250
+ Args:
251
+ filter (Union[Dict[str, str], FilterList], optional):
252
+ last (str, optional): Reflected value from a previous response to obtain the next page of results.
253
+ order (ItemOrder, optional): Order results asc(ending) or desc(ending).
254
+ order_by (ItemOrderBy, optional): Which field to order results by.
255
+ size (int, optional): Maximum results to include in the response.
256
+ bucket_id (str, optional): The bucket to use, if not the default.
257
+
258
+ Returns:
259
+ A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
260
+
261
+ Examples:
262
+ response = await share.list()
263
+ """
264
+
265
+ input = m.ListRequest(filter=filter, last=last, order=order, order_by=order_by, size=size, bucket_id=bucket_id)
266
+ return await self.request.post("v1/list", m.ListResult, data=input.model_dump(exclude_none=True))
267
+
268
+ async def put(
269
+ self,
270
+ file: io.BufferedReader,
271
+ name: Optional[str] = None,
272
+ folder: Optional[str] = None,
273
+ format: Optional[FileFormat] = None,
274
+ metadata: Optional[m.Metadata] = None,
275
+ mimetype: Optional[str] = None,
276
+ parent_id: Optional[str] = None,
277
+ tags: Optional[m.Tags] = None,
278
+ transfer_method: Optional[TransferMethod] = TransferMethod.POST_URL,
279
+ crc32c: Optional[str] = None,
280
+ md5: Optional[str] = None,
281
+ sha1: Optional[str] = None,
282
+ sha256: Optional[str] = None,
283
+ sha512: Optional[str] = None,
284
+ size: Optional[int] = None,
285
+ bucket_id: Optional[str] = None,
286
+ password: Optional[str] = None,
287
+ password_algorithm: Optional[str] = None,
288
+ *,
289
+ file_ttl: Optional[str] = None,
290
+ root_folder: Optional[str] = None,
291
+ root_id: Optional[str] = None,
292
+ tenant_id: Optional[str] = None,
293
+ ) -> PangeaResponse[m.PutResult]:
294
+ """
295
+ Upload a file
296
+
297
+ Upload a file.
298
+
299
+ OperationId: share_post_v1_put
300
+
301
+ Args:
302
+ file (io.BufferedReader):
303
+ name (str, optional): The name of the object to store.
304
+ folder (str, optional): The path to the parent folder. Leave blank
305
+ for the root folder. Path must resolve to `parent_id` if also set.
306
+ format (FileFormat, optional): The format of the file, which will be verified by the server if provided. Uploads not matching the supplied format will be rejected.
307
+ metadata (Metadata, optional): A set of string-based key/value pairs used to provide additional data about an object.
308
+ mimetype (str, optional): The MIME type of the file, which will be verified by the server if provided. Uploads not matching the supplied MIME type will be rejected.
309
+ parent_id (str, optional): The parent ID of the object (a folder). Leave blank to keep in the root folder.
310
+ tags (Tags, optional): A list of user-defined tags.
311
+ transfer_method (TransferMethod, optional): The transfer method used to upload the file data.
312
+ crc32c (str, optional): The hexadecimal-encoded CRC32C hash of the file data, which will be verified by the server if provided.
313
+ md5 (str, optional): The hexadecimal-encoded MD5 hash of the file data, which will be verified by the server if provided.
314
+ sha1 (str, optional): The hexadecimal-encoded SHA1 hash of the file data, which will be verified by the server if provided.
315
+ sha256 (str, optional): The SHA256 hash of the file data, which will be verified by the server if provided.
316
+ sha512 (str, optional): The hexadecimal-encoded SHA512 hash of the file data, which will be verified by the server if provided.
317
+ size (str, optional): The size (in bytes) of the file. If the upload doesn't match, the call will fail.
318
+ bucket_id (str, optional): The bucket to use, if not the default.
319
+ password (str, optional): An optional password to protect the file with. Downloading the file will require this password.
320
+ password_algorithm (str, optional): An optional password algorithm to protect the file with. See symmetric vault password_algorithm.
321
+ file_ttl: The TTL before expiry for the file.
322
+ root_folder: The path of a root folder to restrict the operation to.
323
+ Must resolve to `root_id` if also set.
324
+ root_id: The ID of a root folder to restrict the operation to. Must
325
+ match `root_folder` if also set.
326
+ tenant_id: A tenant to associate with this request.
327
+
328
+ Returns:
329
+ A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
330
+
331
+ Examples:
332
+ try:
333
+ with open("./path/to/file.pdf", "rb") as f:
334
+ response = await share.put(file=f)
335
+ print(f"Response: {response.result}")
336
+ except pe.PangeaAPIException as e:
337
+ print(f"Request Error: {e.response.summary}")
338
+ for err in e.errors:
339
+ print(f"\\t{err.detail} \\n")
340
+ """
341
+
342
+ files: List[Tuple] = [("upload", (name, file, "application/octet-stream"))]
343
+
344
+ if transfer_method == TransferMethod.POST_URL:
345
+ params = get_file_upload_params(file)
346
+ crc32c = params.crc_hex
347
+ sha256 = params.sha256_hex
348
+ size = params.size
349
+ elif size is None and get_file_size(file=file) == 0:
350
+ # Needed to upload zero byte files
351
+ size = 0
352
+
353
+ input = m.PutRequest(
354
+ name=name,
355
+ format=format,
356
+ metadata=metadata,
357
+ mimetype=mimetype,
358
+ parent_id=parent_id,
359
+ folder=folder,
360
+ tags=tags,
361
+ transfer_method=transfer_method,
362
+ crc32c=crc32c,
363
+ md5=md5,
364
+ sha1=sha1,
365
+ sha256=sha256,
366
+ sha512=sha512,
367
+ size=size,
368
+ bucket_id=bucket_id,
369
+ password=password,
370
+ password_algorithm=password_algorithm,
371
+ file_ttl=file_ttl,
372
+ root_folder=root_folder,
373
+ root_id=root_id,
374
+ tenant_id=tenant_id,
375
+ )
376
+ data = input.model_dump(exclude_none=True)
377
+ return await self.request.post("v1/put", m.PutResult, data=data, files=files)
378
+
379
+ async def request_upload_url(
380
+ self,
381
+ name: Optional[str] = None,
382
+ folder: Optional[str] = None,
383
+ format: Optional[FileFormat] = None,
384
+ metadata: Optional[m.Metadata] = None,
385
+ mimetype: Optional[str] = None,
386
+ parent_id: Optional[str] = None,
387
+ tags: Optional[m.Tags] = None,
388
+ transfer_method: Optional[TransferMethod] = TransferMethod.PUT_URL,
389
+ md5: Optional[str] = None,
390
+ sha1: Optional[str] = None,
391
+ sha512: Optional[str] = None,
392
+ crc32c: Optional[str] = None,
393
+ sha256: Optional[str] = None,
394
+ size: Optional[int] = None,
395
+ bucket_id: Optional[str] = None,
396
+ *,
397
+ password: Optional[str] = None,
398
+ password_algorithm: Optional[str] = None,
399
+ file_ttl: Optional[str] = None,
400
+ root_folder: Optional[str] = None,
401
+ root_id: Optional[str] = None,
402
+ tenant_id: Optional[str] = None,
403
+ ) -> PangeaResponse[m.PutResult]:
404
+ """
405
+ Request upload URL
406
+
407
+ Request an upload URL.
408
+
409
+ OperationId: share_post_v1_put 2
410
+
411
+ Args:
412
+ name (str, optional): The name of the object to store.
413
+ folder (str, optional): The path to the parent folder. Leave blank
414
+ for the root folder. Path must resolve to `parent_id` if also set.
415
+ format (FileFormat, optional): The format of the file, which will be verified by the server if provided. Uploads not matching the supplied format will be rejected.
416
+ metadata (Metadata, optional): A set of string-based key/value pairs used to provide additional data about an object.
417
+ mimetype (str, optional): The MIME type of the file, which will be verified by the server if provided. Uploads not matching the supplied MIME type will be rejected.
418
+ parent_id (str, optional): The parent ID of the object (a folder). Leave blank to keep in the root folder.
419
+ tags (Tags, optional): A list of user-defined tags.
420
+ transfer_method (TransferMethod, optional): The transfer method used to upload the file data.
421
+ md5 (str, optional): The hexadecimal-encoded MD5 hash of the file data, which will be verified by the server if provided.
422
+ sha1 (str, optional): The hexadecimal-encoded SHA1 hash of the file data, which will be verified by the server if provided.
423
+ sha512 (str, optional): The hexadecimal-encoded SHA512 hash of the file data, which will be verified by the server if provided.
424
+ crc32c (str, optional): The hexadecimal-encoded CRC32C hash of the file data, which will be verified by the server if provided.
425
+ sha256 (str, optional): The SHA256 hash of the file data, which will be verified by the server if provided.
426
+ size (str, optional): The size (in bytes) of the file. If the upload doesn't match, the call will fail.
427
+ bucket_id (str, optional): The bucket to use, if not the default.
428
+ password: An optional password to protect the file with. Downloading
429
+ the file will require this password.
430
+ password_algorithm: An optional password algorithm to protect the
431
+ file with. See symmetric vault password_algorithm.
432
+ file_ttl: The TTL before expiry for the file.
433
+ root_folder: The path of a root folder to restrict the operation to.
434
+ Must resolve to `root_id` if also set.
435
+ root_id: The ID of a root folder to restrict the operation to. Must
436
+ match `root_folder` if also set.
437
+ tenant_id: A tenant to associate with this request.
438
+
439
+ Returns:
440
+ A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
441
+
442
+ Examples:
443
+ response = await share.request_upload_url(
444
+ transfer_method=TransferMethod.POST_URL,
445
+ crc32c="515f7c32",
446
+ sha256="c0b56b1a154697f79d27d57a3a2aad4c93849aa2239cd23048fc6f45726271cc",
447
+ size=222089,
448
+ metadata={
449
+ "created_by": "jim",
450
+ "priority": "medium",
451
+ },
452
+ parent_id="pos_3djfmzg2db4c6donarecbyv5begtj2bm",
453
+ folder="/",
454
+ tags=["irs_2023", "personal"],
455
+ )
456
+ """
457
+
458
+ input = m.PutRequest(
459
+ name=name,
460
+ format=format,
461
+ metadata=metadata,
462
+ mimetype=mimetype,
463
+ parent_id=parent_id,
464
+ folder=folder,
465
+ tags=tags,
466
+ transfer_method=transfer_method,
467
+ crc32c=crc32c,
468
+ md5=md5,
469
+ sha1=sha1,
470
+ sha256=sha256,
471
+ sha512=sha512,
472
+ size=size,
473
+ bucket_id=bucket_id,
474
+ password=password,
475
+ password_algorithm=password_algorithm,
476
+ file_ttl=file_ttl,
477
+ root_folder=root_folder,
478
+ root_id=root_id,
479
+ tenant_id=tenant_id,
480
+ )
481
+
482
+ data = input.model_dump(exclude_none=True)
483
+ return await self.request.request_presigned_url("v1/put", m.PutResult, data=data)
484
+
485
+ async def update(
486
+ self,
487
+ id: Optional[str] = None,
488
+ folder: Optional[str] = None,
489
+ add_metadata: Optional[m.Metadata] = None,
490
+ remove_metadata: Optional[m.Metadata] = None,
491
+ metadata: Optional[m.Metadata] = None,
492
+ add_tags: Optional[m.Tags] = None,
493
+ remove_tags: Optional[m.Tags] = None,
494
+ tags: Optional[m.Tags] = None,
495
+ parent_id: Optional[str] = None,
496
+ updated_at: Optional[str] = None,
497
+ bucket_id: Optional[str] = None,
498
+ *,
499
+ add_password: Optional[str] = None,
500
+ add_password_algorithm: Optional[str] = None,
501
+ remove_password: Optional[str] = None,
502
+ file_ttl: Optional[str] = None,
503
+ root_folder: Optional[str] = None,
504
+ root_id: Optional[str] = None,
505
+ tenant_id: Optional[str] = None,
506
+ ) -> PangeaResponse[m.UpdateResult]:
507
+ """
508
+ Update a file
509
+
510
+ Update a file.
511
+
512
+ OperationId: share_post_v1_update
513
+
514
+ Args:
515
+ id (str, optional): An identifier for the file to update.
516
+ folder (str, optional): Set the parent (folder). Leave blank for the
517
+ root folder. Path must resolve to `parent_id` if also set.
518
+ add_metadata (Metadata, optional): A list of Metadata key/values to set in the object. If a provided key exists, the value will be replaced.
519
+ remove_metadata (Metadata, optional): A list of Metadata key/values to remove in the object. It is not an error for a provided key to not exist. If a provided key exists but doesn't match the provided value, it will not be removed.
520
+ metadata (Metadata, optional): Set the object's Metadata.
521
+ add_tags (Tags, optional): A list of Tags to add. It is not an error to provide a tag which already exists.
522
+ remove_tags (Tags, optional): A list of Tags to remove. It is not an error to provide a tag which is not present.
523
+ tags (Tags, optional): Set the object's Tags.
524
+ parent_id (str, optional): Set the parent (folder) of the object.
525
+ updated_at (str, optional): The date and time the object was last updated. If included, the update will fail if this doesn't match what's stored.
526
+ bucket_id (str, optional): The bucket to use, if not the default.
527
+ add_password: Protect the file with the supplied password.
528
+ add_password_algorithm: The algorithm to use to password protect the
529
+ file.
530
+ remove_password: Remove the supplied password from the file.
531
+ file_ttl: Set the file TTL.
532
+ root_folder: The path of a root folder to restrict the operation to.
533
+ Must resolve to `root_id` if also set.
534
+ root_id: The ID of a root folder to restrict the operation to. Must
535
+ match `root_folder` if also set.
536
+ tenant_id: A tenant to associate with this request.
537
+
538
+ Returns:
539
+ A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
540
+
541
+ Examples:
542
+ response = await share.update(
543
+ id="pos_3djfmzg2db4c6donarecbyv5begtj2bm",
544
+ remove_metadata={
545
+ "created_by": "jim",
546
+ "priority": "medium",
547
+ },
548
+ remove_tags=["irs_2023", "personal"],
549
+ )
550
+ """
551
+
552
+ input = m.UpdateRequest(
553
+ id=id,
554
+ folder=folder,
555
+ add_metadata=add_metadata,
556
+ remove_metadata=remove_metadata,
557
+ metadata=metadata,
558
+ add_tags=add_tags,
559
+ remove_tags=remove_tags,
560
+ tags=tags,
561
+ parent_id=parent_id,
562
+ updated_at=updated_at,
563
+ bucket_id=bucket_id,
564
+ add_password=add_password,
565
+ add_password_algorithm=add_password_algorithm,
566
+ remove_password=remove_password,
567
+ file_ttl=file_ttl,
568
+ root_folder=root_folder,
569
+ root_id=root_id,
570
+ tenant_id=tenant_id,
571
+ )
572
+ return await self.request.post("v1/update", m.UpdateResult, data=input.model_dump(exclude_none=True))
573
+
574
+ async def share_link_create(
575
+ self, links: List[m.ShareLinkCreateItem], bucket_id: Optional[str] = None
576
+ ) -> PangeaResponse[m.ShareLinkCreateResult]:
577
+ """
578
+ Create share links
579
+
580
+ Create a share link.
581
+
582
+ OperationId: share_post_v1_share_link_create
583
+
584
+ Args:
585
+ links (List[ShareLinkCreateItem]):
586
+ bucket_id (str, optional): The bucket to use, if not the default.
587
+
588
+ Returns:
589
+ A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
590
+
591
+ Examples:
592
+ response = await share.share_link_create(
593
+ links=[
594
+ {
595
+ targets: ["pos_3djfmzg2db4c6donarecbyv5begtj2bm"],
596
+ link_type: LinkType.DOWNLOAD,
597
+ authenticators: [
598
+ {
599
+ "auth_type": AuthenticatorType.PASSWORD,
600
+ "auth_context": "my_fav_Pa55word",
601
+ }
602
+ ],
603
+ }
604
+ ],
605
+ )
606
+ """
607
+
608
+ input = m.ShareLinkCreateRequest(links=links, bucket_id=bucket_id)
609
+ return await self.request.post(
610
+ "v1/share/link/create", m.ShareLinkCreateResult, data=input.model_dump(exclude_none=True)
611
+ )
612
+
613
+ async def share_link_get(self, id: str) -> PangeaResponse[m.ShareLinkGetResult]:
614
+ """
615
+ Get share link
616
+
617
+ Get a share link.
618
+
619
+ OperationId: share_post_v1_share_link_get
620
+
621
+ Args:
622
+ id (str, optional): The ID of a share link.
623
+
624
+ Returns:
625
+ A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
626
+
627
+ Examples:
628
+ response = await share.share_link_get(
629
+ id="psl_3djfmzg2db4c6donarecbyv5begtj2bm"
630
+ )
631
+ """
632
+
633
+ input = m.ShareLinkGetRequest(id=id)
634
+ return await self.request.post(
635
+ "v1/share/link/get", m.ShareLinkGetResult, data=input.model_dump(exclude_none=True)
636
+ )
637
+
638
+ async def share_link_list(
639
+ self,
640
+ filter: Optional[Union[Dict[str, str], m.FilterShareLinkList]] = None,
641
+ last: Optional[str] = None,
642
+ order: Optional[m.ItemOrder] = None,
643
+ order_by: Optional[m.ShareLinkOrderBy] = None,
644
+ size: Optional[int] = None,
645
+ bucket_id: Optional[str] = None,
646
+ ) -> PangeaResponse[m.ShareLinkListResult]:
647
+ """
648
+ List share links
649
+
650
+ Look up share links by filter options.
651
+
652
+ OperationId: share_post_v1_share_link_list
653
+
654
+ Args:
655
+ filter (Union[Dict[str, str], ShareLinkListFilter], optional):
656
+ last (str, optional): Reflected value from a previous response to obtain the next page of results.
657
+ order (ItemOrder, optional): Order results asc(ending) or desc(ending).
658
+ order_by (ItemOrderBy, optional): Which field to order results by.
659
+ size (int, optional): Maximum results to include in the response.
660
+ bucket_id (str, optional): The bucket to use, if not the default.
661
+
662
+ Returns:
663
+ A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
664
+
665
+ Examples:
666
+ response = await share.share_link_list()
667
+ """
668
+
669
+ input = m.ShareLinkListRequest(
670
+ filter=filter, last=last, order=order, order_by=order_by, size=size, bucket_id=bucket_id
671
+ )
672
+ return await self.request.post(
673
+ "v1/share/link/list", m.ShareLinkListResult, data=input.model_dump(exclude_none=True)
674
+ )
675
+
676
+ async def share_link_delete(
677
+ self, ids: List[str], bucket_id: Optional[str] = None
678
+ ) -> PangeaResponse[m.ShareLinkDeleteResult]:
679
+ """
680
+ Delete share links
681
+
682
+ Delete share links.
683
+
684
+ OperationId: share_post_v1_share_link_delete
685
+
686
+ Args:
687
+ ids (List[str]): list of the share link's id to delete
688
+ bucket_id (str, optional): The bucket to use, if not the default.
689
+
690
+ Returns:
691
+ A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
692
+
693
+ Examples:
694
+ response = await share.share_link_delete(
695
+ ids=["psl_3djfmzg2db4c6donarecbyv5begtj2bm"]
696
+ )
697
+ """
698
+
699
+ input = m.ShareLinkDeleteRequest(ids=ids, bucket_id=bucket_id)
700
+ return await self.request.post(
701
+ "v1/share/link/delete", m.ShareLinkDeleteResult, data=input.model_dump(exclude_none=True)
702
+ )
703
+
704
+ async def share_link_send(
705
+ self, links: List[m.ShareLinkSendItem], sender_email: str, sender_name: Optional[str] = None
706
+ ) -> PangeaResponse[m.ShareLinkSendResult]:
707
+ """
708
+ Send share links
709
+
710
+ Send a secure share-link notification to a set of email addresses. The
711
+ notification email will contain an Open button that the recipient can
712
+ use to follow the secured share-link to authenticate and then access the
713
+ shared content.
714
+
715
+ OperationId: share_post_v1_share_link_send
716
+
717
+ Args:
718
+ sender_email: An email address.
719
+
720
+ Returns:
721
+ A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
722
+
723
+ Examples:
724
+ response = await share.share_link_send(
725
+ links=[ShareLinkSendItem(id=link.id, email="foo@example.org")],
726
+ sender_email="sender@example.org",
727
+ )
728
+ """
729
+
730
+ input = m.ShareLinkSendRequest(links=links, sender_email=sender_email, sender_name=sender_name)
731
+ return await self.request.post(
732
+ "v1/share/link/send", m.ShareLinkSendResult, data=input.model_dump(exclude_none=True)
733
+ )