pangea-sdk 3.8.0b4__py3-none-any.whl → 4.0.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.
- pangea/__init__.py +1 -2
- pangea/asyncio/request.py +17 -22
- pangea/asyncio/services/__init__.py +0 -2
- pangea/asyncio/services/audit.py +188 -23
- pangea/asyncio/services/authn.py +167 -108
- pangea/asyncio/services/authz.py +36 -45
- pangea/asyncio/services/embargo.py +2 -2
- pangea/asyncio/services/file_scan.py +3 -3
- pangea/asyncio/services/intel.py +44 -26
- pangea/asyncio/services/redact.py +60 -4
- pangea/asyncio/services/vault.py +145 -30
- pangea/dump_audit.py +1 -1
- pangea/request.py +30 -24
- pangea/response.py +34 -42
- pangea/services/__init__.py +0 -2
- pangea/services/audit/audit.py +202 -34
- pangea/services/audit/models.py +56 -8
- pangea/services/audit/util.py +3 -3
- pangea/services/authn/authn.py +116 -65
- pangea/services/authn/models.py +88 -4
- pangea/services/authz.py +51 -56
- pangea/services/base.py +23 -6
- pangea/services/embargo.py +2 -2
- pangea/services/file_scan.py +3 -2
- pangea/services/intel.py +25 -23
- pangea/services/redact.py +124 -4
- pangea/services/vault/models/common.py +121 -6
- pangea/services/vault/models/symmetric.py +2 -2
- pangea/services/vault/vault.py +143 -32
- pangea/utils.py +20 -109
- pangea/verify_audit.py +267 -83
- {pangea_sdk-3.8.0b4.dist-info → pangea_sdk-4.0.0.dist-info}/METADATA +12 -20
- pangea_sdk-4.0.0.dist-info/RECORD +46 -0
- {pangea_sdk-3.8.0b4.dist-info → pangea_sdk-4.0.0.dist-info}/WHEEL +1 -1
- pangea/asyncio/__init__.py +0 -1
- pangea/asyncio/file_uploader.py +0 -39
- pangea/asyncio/services/sanitize.py +0 -185
- pangea/asyncio/services/share.py +0 -573
- pangea/file_uploader.py +0 -35
- pangea/services/sanitize.py +0 -275
- pangea/services/share/file_format.py +0 -170
- pangea/services/share/share.py +0 -877
- pangea_sdk-3.8.0b4.dist-info/RECORD +0 -54
pangea/services/share/share.py
DELETED
@@ -1,877 +0,0 @@
|
|
1
|
-
# Copyright 2022 Pangea Cyber Corporation
|
2
|
-
# Author: Pangea Cyber Corporation
|
3
|
-
import enum
|
4
|
-
import io
|
5
|
-
from typing import Dict, List, NewType, Optional, Tuple, Union
|
6
|
-
|
7
|
-
from ..base import ServiceBase
|
8
|
-
from .file_format import FileFormat
|
9
|
-
from pangea.response import APIRequestModel, PangeaResponse, PangeaResponseResult, TransferMethod
|
10
|
-
from pangea.utils import get_file_size, get_file_upload_params
|
11
|
-
|
12
|
-
Metadata = NewType("Metadata", Dict[str, str])
|
13
|
-
Tags = NewType("Tags", List[str])
|
14
|
-
|
15
|
-
|
16
|
-
class ItemOrder(str, enum.Enum):
|
17
|
-
ASC = "asc"
|
18
|
-
DESC = "desc"
|
19
|
-
|
20
|
-
def __str__(self):
|
21
|
-
return str(self.value)
|
22
|
-
|
23
|
-
def __repr__(self):
|
24
|
-
return str(self.value)
|
25
|
-
|
26
|
-
|
27
|
-
class ArchiveFormat(str, enum.Enum):
|
28
|
-
TAR = "tar"
|
29
|
-
ZIP = "zip"
|
30
|
-
|
31
|
-
def __str__(self):
|
32
|
-
return str(self.value)
|
33
|
-
|
34
|
-
def __repr__(self):
|
35
|
-
return str(self.value)
|
36
|
-
|
37
|
-
|
38
|
-
class LinkType(str, enum.Enum):
|
39
|
-
UPLOAD = "upload"
|
40
|
-
DOWNLOAD = "download"
|
41
|
-
EDITOR = "editor"
|
42
|
-
|
43
|
-
def __str__(self):
|
44
|
-
return str(self.value)
|
45
|
-
|
46
|
-
def __repr__(self):
|
47
|
-
return str(self.value)
|
48
|
-
|
49
|
-
|
50
|
-
class AuthenticatorType(str, enum.Enum):
|
51
|
-
EMAIL_OTP = "email_otp"
|
52
|
-
PASSWORD = "password"
|
53
|
-
SMS_OTP = "sms_otp"
|
54
|
-
SOCIAL = "social"
|
55
|
-
|
56
|
-
def __str__(self):
|
57
|
-
return str(self.value)
|
58
|
-
|
59
|
-
def __repr__(self):
|
60
|
-
return str(self.value)
|
61
|
-
|
62
|
-
|
63
|
-
class ItemOrderBy(str, enum.Enum):
|
64
|
-
ID = "id"
|
65
|
-
CREATED_AT = "created_at"
|
66
|
-
NAME = "name"
|
67
|
-
PARENT_ID = "parent_id"
|
68
|
-
TYPE = "type"
|
69
|
-
UPDATED_AT = "updated_at"
|
70
|
-
|
71
|
-
def __str__(self):
|
72
|
-
return str(self.value)
|
73
|
-
|
74
|
-
def __repr__(self):
|
75
|
-
return str(self.value)
|
76
|
-
|
77
|
-
|
78
|
-
class ShareLinkOrderBy(str, enum.Enum):
|
79
|
-
ID = "id"
|
80
|
-
STORAGE_POOL_ID = "storage_pool_id"
|
81
|
-
TARGET = "target"
|
82
|
-
LINK_TYPE = "link_type"
|
83
|
-
ACCESS_COUNT = "access_count"
|
84
|
-
MAX_ACCESS_COUNT = "max_access_count"
|
85
|
-
CREATED_AT = "created_at"
|
86
|
-
EXPIRES_AT = "expires_at"
|
87
|
-
LAST_ACCESSED_AT = "last_accessed_at"
|
88
|
-
LINK = "link"
|
89
|
-
|
90
|
-
def __str__(self):
|
91
|
-
return str(self.value)
|
92
|
-
|
93
|
-
def __repr__(self):
|
94
|
-
return str(self.value)
|
95
|
-
|
96
|
-
|
97
|
-
class DeleteRequest(APIRequestModel):
|
98
|
-
id: Optional[str] = None
|
99
|
-
force: Optional[bool] = None
|
100
|
-
path: Optional[str] = None
|
101
|
-
|
102
|
-
|
103
|
-
class ItemData(PangeaResponseResult):
|
104
|
-
id: str
|
105
|
-
type: str
|
106
|
-
name: str
|
107
|
-
created_at: str
|
108
|
-
updated_at: str
|
109
|
-
size: Optional[int] = None
|
110
|
-
billable_size: Optional[int] = None
|
111
|
-
location: Optional[str] = None
|
112
|
-
tags: Optional[Tags] = None
|
113
|
-
metadata: Optional[Metadata] = None
|
114
|
-
md5: Optional[str] = None
|
115
|
-
sha256: Optional[str] = None
|
116
|
-
sha512: Optional[str] = None
|
117
|
-
parent_id: Optional[str] = None
|
118
|
-
|
119
|
-
|
120
|
-
class DeleteResult(PangeaResponseResult):
|
121
|
-
count: int
|
122
|
-
|
123
|
-
|
124
|
-
class FolderCreateRequest(APIRequestModel):
|
125
|
-
name: Optional[str] = None
|
126
|
-
metadata: Optional[Metadata] = None
|
127
|
-
parent_id: Optional[str] = None
|
128
|
-
path: Optional[str] = None
|
129
|
-
tags: Optional[Tags] = None
|
130
|
-
|
131
|
-
|
132
|
-
class FolderCreateResult(PangeaResponseResult):
|
133
|
-
object: ItemData
|
134
|
-
|
135
|
-
|
136
|
-
class GetRequest(APIRequestModel):
|
137
|
-
id: Optional[str] = None
|
138
|
-
path: Optional[str] = None
|
139
|
-
transfer_method: Optional[TransferMethod] = None
|
140
|
-
|
141
|
-
|
142
|
-
class GetResult(PangeaResponseResult):
|
143
|
-
object: ItemData
|
144
|
-
dest_url: Optional[str] = None
|
145
|
-
|
146
|
-
|
147
|
-
class PutRequest(APIRequestModel):
|
148
|
-
name: Optional[str] = None
|
149
|
-
format: Optional[FileFormat] = None
|
150
|
-
metadata: Optional[Metadata] = None
|
151
|
-
mimetype: Optional[str] = None
|
152
|
-
parent_id: Optional[str] = None
|
153
|
-
path: Optional[str] = None
|
154
|
-
crc32c: Optional[str] = None
|
155
|
-
md5: Optional[str] = None
|
156
|
-
sha1: Optional[str] = None
|
157
|
-
sha256: Optional[str] = None
|
158
|
-
sha512: Optional[str] = None
|
159
|
-
size: Optional[int] = None
|
160
|
-
tags: Optional[Tags] = None
|
161
|
-
transfer_method: Optional[TransferMethod] = None
|
162
|
-
|
163
|
-
|
164
|
-
class PutResult(PangeaResponseResult):
|
165
|
-
object: ItemData
|
166
|
-
|
167
|
-
|
168
|
-
class UpdateRequest(APIRequestModel):
|
169
|
-
id: Optional[str]
|
170
|
-
path: Optional[str] = None
|
171
|
-
add_metadata: Optional[Metadata] = None
|
172
|
-
remove_metadata: Optional[Metadata] = None
|
173
|
-
metadata: Optional[Metadata] = None
|
174
|
-
add_tags: Optional[Tags] = None
|
175
|
-
remove_tags: Optional[Tags] = None
|
176
|
-
tags: Optional[Tags] = None
|
177
|
-
parent_id: Optional[str] = None
|
178
|
-
updated_at: Optional[str] = None
|
179
|
-
|
180
|
-
|
181
|
-
class UpdateResult(PangeaResponseResult):
|
182
|
-
object: ItemData
|
183
|
-
|
184
|
-
|
185
|
-
class FilterList(APIRequestModel):
|
186
|
-
folder: str
|
187
|
-
|
188
|
-
|
189
|
-
class ListRequest(APIRequestModel):
|
190
|
-
filter: Optional[Union[Dict[str, str], FilterList]] = None
|
191
|
-
last: Optional[str] = None
|
192
|
-
order: Optional[ItemOrder] = None
|
193
|
-
order_by: Optional[ItemOrderBy] = None
|
194
|
-
size: Optional[int] = None
|
195
|
-
|
196
|
-
|
197
|
-
class ListResult(PangeaResponseResult):
|
198
|
-
count: int
|
199
|
-
last: Optional[str] = None
|
200
|
-
objects: List[ItemData]
|
201
|
-
|
202
|
-
|
203
|
-
class GetArchiveRequest(APIRequestModel):
|
204
|
-
ids: List[str] = []
|
205
|
-
format: Optional[ArchiveFormat] = None
|
206
|
-
transfer_method: Optional[TransferMethod] = None
|
207
|
-
|
208
|
-
|
209
|
-
class GetArchiveResult(PangeaResponseResult):
|
210
|
-
dest_url: Optional[str] = None
|
211
|
-
count: int
|
212
|
-
|
213
|
-
|
214
|
-
class Authenticator(PangeaResponseResult):
|
215
|
-
auth_type: AuthenticatorType
|
216
|
-
auth_context: str
|
217
|
-
|
218
|
-
|
219
|
-
class ShareLinkItemBase(PangeaResponseResult):
|
220
|
-
targets: List[str] = []
|
221
|
-
link_type: Optional[LinkType] = None
|
222
|
-
expires_at: Optional[str] = None
|
223
|
-
max_access_count: Optional[int] = None
|
224
|
-
authenticators: List[Authenticator]
|
225
|
-
message: Optional[str] = None
|
226
|
-
title: Optional[str] = None
|
227
|
-
notify_email: Optional[str] = None
|
228
|
-
tags: Optional[Tags] = None
|
229
|
-
|
230
|
-
|
231
|
-
class ShareLinkCreateItem(ShareLinkItemBase):
|
232
|
-
pass
|
233
|
-
|
234
|
-
|
235
|
-
class ShareLinkCreateRequest(APIRequestModel):
|
236
|
-
links: List[ShareLinkCreateItem] = []
|
237
|
-
|
238
|
-
|
239
|
-
class ShareLinkItem(ShareLinkItemBase):
|
240
|
-
id: str
|
241
|
-
storage_pool_id: str
|
242
|
-
access_count: int
|
243
|
-
created_at: str
|
244
|
-
last_accessed_at: Optional[str] = None
|
245
|
-
link: str
|
246
|
-
|
247
|
-
|
248
|
-
class ShareLinkCreateResult(PangeaResponseResult):
|
249
|
-
share_link_objects: List[ShareLinkItem] = []
|
250
|
-
|
251
|
-
|
252
|
-
class ShareLinkGetRequest(APIRequestModel):
|
253
|
-
id: str
|
254
|
-
|
255
|
-
|
256
|
-
class ShareLinkGetResult(PangeaResponseResult):
|
257
|
-
share_link_object: ShareLinkItem
|
258
|
-
|
259
|
-
|
260
|
-
class FilterShareLinkList(APIRequestModel):
|
261
|
-
id: Optional[str] = None
|
262
|
-
id__contains: Optional[List[str]] = None
|
263
|
-
id__in: Optional[List[str]] = None
|
264
|
-
storage_pool_id: Optional[str] = None
|
265
|
-
storage_pool_id__contains: Optional[List[str]] = None
|
266
|
-
storage_pool_id__in: Optional[List[str]] = None
|
267
|
-
target: Optional[str] = None
|
268
|
-
target__contains: Optional[List[str]] = None
|
269
|
-
target__in: Optional[List[str]] = None
|
270
|
-
link_type: Optional[str] = None
|
271
|
-
link_type__contains: Optional[List[str]] = None
|
272
|
-
link_type__in: Optional[List[str]] = None
|
273
|
-
access_count: Optional[int] = None
|
274
|
-
access_count__gt: Optional[int] = None
|
275
|
-
access_count__gte: Optional[int] = None
|
276
|
-
access_count__lt: Optional[int] = None
|
277
|
-
access_count__lte: Optional[int] = None
|
278
|
-
max_access_count: Optional[int] = None
|
279
|
-
max_access_count__gt: Optional[int] = None
|
280
|
-
max_access_count__gte: Optional[int] = None
|
281
|
-
max_access_count__lt: Optional[int] = None
|
282
|
-
max_access_count__lte: Optional[int] = None
|
283
|
-
created_at: Optional[str] = None
|
284
|
-
created_at__gt: Optional[str] = None
|
285
|
-
created_at__gte: Optional[str] = None
|
286
|
-
created_at__lt: Optional[str] = None
|
287
|
-
created_at__lte: Optional[str] = None
|
288
|
-
expires_at: Optional[str] = None
|
289
|
-
expires_at__gt: Optional[str] = None
|
290
|
-
expires_at__gte: Optional[str] = None
|
291
|
-
expires_at__lt: Optional[str] = None
|
292
|
-
expires_at__lte: Optional[str] = None
|
293
|
-
last_accessed_at: Optional[str] = None
|
294
|
-
last_accessed_at__gt: Optional[str] = None
|
295
|
-
last_accessed_at__gte: Optional[str] = None
|
296
|
-
last_accessed_at__lt: Optional[str] = None
|
297
|
-
last_accessed_at__lte: Optional[str] = None
|
298
|
-
link: Optional[str] = None
|
299
|
-
link__contains: Optional[List[str]] = None
|
300
|
-
link__in: Optional[List[str]] = None
|
301
|
-
|
302
|
-
|
303
|
-
class ShareLinkListRequest(APIRequestModel):
|
304
|
-
filter: Optional[Union[FilterShareLinkList, Dict[str, str]]] = None
|
305
|
-
last: Optional[str] = None
|
306
|
-
order: Optional[ItemOrder] = None
|
307
|
-
order_by: Optional[ShareLinkOrderBy] = None
|
308
|
-
size: Optional[int] = None
|
309
|
-
|
310
|
-
|
311
|
-
class ShareLinkListResult(PangeaResponseResult):
|
312
|
-
count: int
|
313
|
-
share_link_objects: List[ShareLinkItem] = []
|
314
|
-
|
315
|
-
|
316
|
-
class ShareLinkDeleteRequest(APIRequestModel):
|
317
|
-
ids: List[str]
|
318
|
-
|
319
|
-
|
320
|
-
class ShareLinkDeleteResult(PangeaResponseResult):
|
321
|
-
share_link_objects: List[ShareLinkItem] = []
|
322
|
-
|
323
|
-
|
324
|
-
class ShareLinkSendItem(APIRequestModel):
|
325
|
-
id: str
|
326
|
-
email: str
|
327
|
-
|
328
|
-
|
329
|
-
class ShareLinkSendRequest(APIRequestModel):
|
330
|
-
links: List[ShareLinkSendItem]
|
331
|
-
sender_email: str
|
332
|
-
sender_name: Optional[str]
|
333
|
-
|
334
|
-
|
335
|
-
class ShareLinkSendResult(PangeaResponseResult):
|
336
|
-
share_link_objects: List[ShareLinkItem]
|
337
|
-
|
338
|
-
|
339
|
-
class Share(ServiceBase):
|
340
|
-
"""Share service client."""
|
341
|
-
|
342
|
-
service_name = "share"
|
343
|
-
|
344
|
-
def delete(
|
345
|
-
self, id: Optional[str] = None, path: Optional[str] = None, force: Optional[bool] = None
|
346
|
-
) -> PangeaResponse[DeleteResult]:
|
347
|
-
"""
|
348
|
-
Delete (Beta)
|
349
|
-
|
350
|
-
Delete object by ID or path. If both are supplied, the path must match
|
351
|
-
that of the object represented by the ID.
|
352
|
-
How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
353
|
-
|
354
|
-
OperationId: share_post_v1beta_delete
|
355
|
-
|
356
|
-
Args:
|
357
|
-
id (str, optional): The ID of the object to delete.
|
358
|
-
path (str, optional): The path of the object to delete.
|
359
|
-
force (bool, optional): If true, delete a folder even if it's not empty.
|
360
|
-
|
361
|
-
Returns:
|
362
|
-
A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
|
363
|
-
|
364
|
-
Examples:
|
365
|
-
response = share.delete(id="pos_3djfmzg2db4c6donarecbyv5begtj2bm")
|
366
|
-
"""
|
367
|
-
input = DeleteRequest(id=id, path=path, force=force)
|
368
|
-
return self.request.post("v1beta/delete", DeleteResult, data=input.dict(exclude_none=True))
|
369
|
-
|
370
|
-
def folder_create(
|
371
|
-
self,
|
372
|
-
name: Optional[str] = None,
|
373
|
-
metadata: Optional[Metadata] = None,
|
374
|
-
parent_id: Optional[str] = None,
|
375
|
-
path: Optional[str] = None,
|
376
|
-
tags: Optional[Tags] = None,
|
377
|
-
) -> PangeaResponse[FolderCreateResult]:
|
378
|
-
"""
|
379
|
-
Create a folder (Beta)
|
380
|
-
|
381
|
-
Create a folder, either by name or path and parent_id.
|
382
|
-
How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
383
|
-
|
384
|
-
OperationId: share_post_v1beta_folder_create
|
385
|
-
|
386
|
-
Args:
|
387
|
-
name (str, optional): The name of an object.
|
388
|
-
metadata (Metadata, optional): A set of string-based key/value pairs used to provide additional data about an object.
|
389
|
-
parent_id (str, optional): The ID of a stored object.
|
390
|
-
path (str, optional): A case-sensitive path to an object. Contains a sequence of path segments delimited by the the / character. Any path ending in a / character refers to a folder.
|
391
|
-
tags (Tags, optional): A list of user-defined tags.
|
392
|
-
|
393
|
-
Returns:
|
394
|
-
A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
|
395
|
-
|
396
|
-
Examples:
|
397
|
-
response = share.folder_create(
|
398
|
-
metadata={
|
399
|
-
"created_by": "jim",
|
400
|
-
"priority": "medium",
|
401
|
-
},
|
402
|
-
parent_id="pos_3djfmzg2db4c6donarecbyv5begtj2bm",
|
403
|
-
path="/",
|
404
|
-
tags=["irs_2023", "personal"],
|
405
|
-
)
|
406
|
-
"""
|
407
|
-
input = FolderCreateRequest(name=name, metadata=metadata, parent_id=parent_id, path=path, tags=tags)
|
408
|
-
return self.request.post("v1beta/folder/create", FolderCreateResult, data=input.dict(exclude_none=True))
|
409
|
-
|
410
|
-
def get(
|
411
|
-
self, id: Optional[str] = None, path: Optional[str] = None, transfer_method: Optional[TransferMethod] = None
|
412
|
-
) -> PangeaResponse[GetResult]:
|
413
|
-
"""
|
414
|
-
Get an object (Beta)
|
415
|
-
|
416
|
-
Get object. If both ID and Path are supplied, the call will fail if the
|
417
|
-
target object doesn't match both properties.
|
418
|
-
How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
419
|
-
|
420
|
-
OperationId: share_post_v1beta_get
|
421
|
-
|
422
|
-
Args:
|
423
|
-
id (str, optional): The ID of the object to retrieve.
|
424
|
-
path (str, optional): The path of the object to retrieve.
|
425
|
-
transfer_method (TransferMethod, optional): The requested transfer method for the file data.
|
426
|
-
|
427
|
-
Returns:
|
428
|
-
A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
|
429
|
-
|
430
|
-
Examples:
|
431
|
-
response = share.get(
|
432
|
-
id="pos_3djfmzg2db4c6donarecbyv5begtj2bm",
|
433
|
-
path="/",
|
434
|
-
)
|
435
|
-
"""
|
436
|
-
input = GetRequest(
|
437
|
-
id=id,
|
438
|
-
path=path,
|
439
|
-
transfer_method=transfer_method,
|
440
|
-
)
|
441
|
-
return self.request.post("v1beta/get", GetResult, data=input.dict(exclude_none=True))
|
442
|
-
|
443
|
-
def get_archive(
|
444
|
-
self,
|
445
|
-
ids: List[str] = [],
|
446
|
-
format: Optional[ArchiveFormat] = None,
|
447
|
-
transfer_method: Optional[TransferMethod] = None,
|
448
|
-
) -> PangeaResponse[GetArchiveResult]:
|
449
|
-
"""
|
450
|
-
Get archive (Beta)
|
451
|
-
|
452
|
-
Get an archive file of multiple objects.
|
453
|
-
How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
454
|
-
|
455
|
-
OperationId: share_post_v1beta_get_archive
|
456
|
-
|
457
|
-
Args:
|
458
|
-
ids (List[str]): The IDs of the objects to include in the archive. Folders include all children.
|
459
|
-
format (ArchiveFormat, optional): The format to use for the built archive.
|
460
|
-
transfer_method (TransferMethod, optional): The requested transfer method for the file data.
|
461
|
-
|
462
|
-
Returns:
|
463
|
-
A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
|
464
|
-
|
465
|
-
Examples:
|
466
|
-
response = share.get_archive(
|
467
|
-
ids=["pos_3djfmzg2db4c6donarecbyv5begtj2bm"],
|
468
|
-
)
|
469
|
-
"""
|
470
|
-
if (
|
471
|
-
transfer_method is not None
|
472
|
-
and transfer_method != TransferMethod.DEST_URL
|
473
|
-
and transfer_method != TransferMethod.MULTIPART
|
474
|
-
):
|
475
|
-
raise ValueError(f"Only {TransferMethod.DEST_URL} and {TransferMethod.MULTIPART} are supported")
|
476
|
-
|
477
|
-
input = GetArchiveRequest(ids=ids, format=format, transfer_method=transfer_method)
|
478
|
-
return self.request.post("v1beta/get_archive", GetArchiveResult, data=input.dict(exclude_none=True))
|
479
|
-
|
480
|
-
def list(
|
481
|
-
self,
|
482
|
-
filter: Optional[Union[Dict[str, str], FilterList]] = None,
|
483
|
-
last: Optional[str] = None,
|
484
|
-
order: Optional[ItemOrder] = None,
|
485
|
-
order_by: Optional[ItemOrderBy] = None,
|
486
|
-
size: Optional[int] = None,
|
487
|
-
) -> PangeaResponse[ListResult]:
|
488
|
-
"""
|
489
|
-
List (Beta)
|
490
|
-
|
491
|
-
List or filter/search records.
|
492
|
-
How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
493
|
-
|
494
|
-
OperationId: share_post_v1beta_list
|
495
|
-
|
496
|
-
Args:
|
497
|
-
filter (Union[Dict[str, str], FilterList], optional):
|
498
|
-
last (str, optional): Reflected value from a previous response to obtain the next page of results.
|
499
|
-
order (ItemOrder, optional): Order results asc(ending) or desc(ending).
|
500
|
-
order_by (ItemOrderBy, optional): Which field to order results by.
|
501
|
-
size (int, optional): Maximum results to include in the response.
|
502
|
-
|
503
|
-
Returns:
|
504
|
-
A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
|
505
|
-
|
506
|
-
Examples:
|
507
|
-
response = share.list()
|
508
|
-
"""
|
509
|
-
input = ListRequest(filter=filter, last=last, order=order, order_by=order_by, size=size)
|
510
|
-
return self.request.post("v1beta/list", ListResult, data=input.dict(exclude_none=True))
|
511
|
-
|
512
|
-
def put(
|
513
|
-
self,
|
514
|
-
file: io.BufferedReader,
|
515
|
-
name: Optional[str] = None,
|
516
|
-
path: Optional[str] = None,
|
517
|
-
format: Optional[FileFormat] = None,
|
518
|
-
metadata: Optional[Metadata] = None,
|
519
|
-
mimetype: Optional[str] = None,
|
520
|
-
parent_id: Optional[str] = None,
|
521
|
-
tags: Optional[Tags] = None,
|
522
|
-
transfer_method: Optional[TransferMethod] = TransferMethod.POST_URL,
|
523
|
-
crc32c: Optional[str] = None,
|
524
|
-
md5: Optional[str] = None,
|
525
|
-
sha1: Optional[str] = None,
|
526
|
-
sha256: Optional[str] = None,
|
527
|
-
sha512: Optional[str] = None,
|
528
|
-
size: Optional[int] = None,
|
529
|
-
) -> PangeaResponse[PutResult]:
|
530
|
-
"""
|
531
|
-
Upload a file (Beta)
|
532
|
-
|
533
|
-
Upload a file.
|
534
|
-
How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
535
|
-
|
536
|
-
OperationId: share_post_v1beta_put
|
537
|
-
|
538
|
-
Args:
|
539
|
-
file (io.BufferedReader):
|
540
|
-
name (str, optional): The name of the object to store.
|
541
|
-
path (str, optional): An optional path where the file should be placed. Will auto-create directories if necessary.
|
542
|
-
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.
|
543
|
-
metadata (Metadata, optional): A set of string-based key/value pairs used to provide additional data about an object.
|
544
|
-
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.
|
545
|
-
parent_id (str, optional): The parent ID of the object (a folder). Leave blank to keep in the root folder.
|
546
|
-
tags (Tags, optional): A list of user-defined tags.
|
547
|
-
transfer_method (TransferMethod, optional): The transfer method used to upload the file data.
|
548
|
-
crc32c (str, optional): The hexadecimal-encoded CRC32C hash of the file data, which will be verified by the server if provided.
|
549
|
-
md5 (str, optional): The hexadecimal-encoded MD5 hash of the file data, which will be verified by the server if provided.
|
550
|
-
sha1 (str, optional): The hexadecimal-encoded SHA1 hash of the file data, which will be verified by the server if provided.
|
551
|
-
sha256 (str, optional): The SHA256 hash of the file data, which will be verified by the server if provided.
|
552
|
-
sha512 (str, optional): The hexadecimal-encoded SHA512 hash of the file data, which will be verified by the server if provided.
|
553
|
-
size (str, optional): The size (in bytes) of the file. If the upload doesn't match, the call will fail.
|
554
|
-
|
555
|
-
Returns:
|
556
|
-
A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
|
557
|
-
|
558
|
-
Examples:
|
559
|
-
try:
|
560
|
-
with open("./path/to/file.pdf", "rb") as f:
|
561
|
-
response = share.put(file=f)
|
562
|
-
print(f"Response: {response.result}")
|
563
|
-
except pe.PangeaAPIException as e:
|
564
|
-
print(f"Request Error: {e.response.summary}")
|
565
|
-
for err in e.errors:
|
566
|
-
print(f"\\t{err.detail} \\n")
|
567
|
-
"""
|
568
|
-
files: List[Tuple] = [("upload", ("file", file, "application/octet-stream"))]
|
569
|
-
|
570
|
-
if transfer_method == TransferMethod.POST_URL:
|
571
|
-
params = get_file_upload_params(file)
|
572
|
-
crc32c = params.crc_hex
|
573
|
-
sha256 = params.sha256_hex
|
574
|
-
size = params.size
|
575
|
-
elif size is None and get_file_size(file=file) == 0:
|
576
|
-
# Needed to upload zero byte files
|
577
|
-
size = 0
|
578
|
-
|
579
|
-
input = PutRequest(
|
580
|
-
name=name,
|
581
|
-
format=format,
|
582
|
-
metadata=metadata,
|
583
|
-
mimetype=mimetype,
|
584
|
-
parent_id=parent_id,
|
585
|
-
path=path,
|
586
|
-
tags=tags,
|
587
|
-
transfer_method=transfer_method,
|
588
|
-
crc32c=crc32c,
|
589
|
-
md5=md5,
|
590
|
-
sha1=sha1,
|
591
|
-
sha256=sha256,
|
592
|
-
sha512=sha512,
|
593
|
-
size=size,
|
594
|
-
)
|
595
|
-
data = input.dict(exclude_none=True)
|
596
|
-
return self.request.post("v1beta/put", PutResult, data=data, files=files)
|
597
|
-
|
598
|
-
def request_upload_url(
|
599
|
-
self,
|
600
|
-
name: Optional[str] = None,
|
601
|
-
path: Optional[str] = None,
|
602
|
-
format: Optional[FileFormat] = None,
|
603
|
-
metadata: Optional[Metadata] = None,
|
604
|
-
mimetype: Optional[str] = None,
|
605
|
-
parent_id: Optional[str] = None,
|
606
|
-
tags: Optional[Tags] = None,
|
607
|
-
transfer_method: Optional[TransferMethod] = TransferMethod.PUT_URL,
|
608
|
-
md5: Optional[str] = None,
|
609
|
-
sha1: Optional[str] = None,
|
610
|
-
sha512: Optional[str] = None,
|
611
|
-
crc32c: Optional[str] = None,
|
612
|
-
sha256: Optional[str] = None,
|
613
|
-
size: Optional[int] = None,
|
614
|
-
) -> PangeaResponse[PutResult]:
|
615
|
-
"""
|
616
|
-
Request upload URL (Beta)
|
617
|
-
|
618
|
-
Request an upload URL.
|
619
|
-
How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
620
|
-
|
621
|
-
OperationId: share_post_v1beta_put 2
|
622
|
-
|
623
|
-
Args:
|
624
|
-
name (str, optional): The name of the object to store.
|
625
|
-
path (str, optional): An optional path where the file should be placed. Will auto-create directories if necessary.
|
626
|
-
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.
|
627
|
-
metadata (Metadata, optional): A set of string-based key/value pairs used to provide additional data about an object.
|
628
|
-
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.
|
629
|
-
parent_id (str, optional): The parent ID of the object (a folder). Leave blank to keep in the root folder.
|
630
|
-
tags (Tags, optional): A list of user-defined tags.
|
631
|
-
transfer_method (TransferMethod, optional): The transfer method used to upload the file data.
|
632
|
-
md5 (str, optional): The hexadecimal-encoded MD5 hash of the file data, which will be verified by the server if provided.
|
633
|
-
sha1 (str, optional): The hexadecimal-encoded SHA1 hash of the file data, which will be verified by the server if provided.
|
634
|
-
sha512 (str, optional): The hexadecimal-encoded SHA512 hash of the file data, which will be verified by the server if provided.
|
635
|
-
crc32c (str, optional): The hexadecimal-encoded CRC32C hash of the file data, which will be verified by the server if provided.
|
636
|
-
sha256 (str, optional): The SHA256 hash of the file data, which will be verified by the server if provided.
|
637
|
-
size (str, optional): The size (in bytes) of the file. If the upload doesn't match, the call will fail.
|
638
|
-
|
639
|
-
Returns:
|
640
|
-
A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
|
641
|
-
|
642
|
-
Examples:
|
643
|
-
response = share.request_upload_url(
|
644
|
-
transfer_method=TransferMethod.POST_URL,
|
645
|
-
crc32c="515f7c32",
|
646
|
-
sha256="c0b56b1a154697f79d27d57a3a2aad4c93849aa2239cd23048fc6f45726271cc",
|
647
|
-
size=222089,
|
648
|
-
metadata={
|
649
|
-
"created_by": "jim",
|
650
|
-
"priority": "medium",
|
651
|
-
},
|
652
|
-
parent_id="pos_3djfmzg2db4c6donarecbyv5begtj2bm",
|
653
|
-
path="/",
|
654
|
-
tags=["irs_2023", "personal"],
|
655
|
-
)
|
656
|
-
"""
|
657
|
-
input = PutRequest(
|
658
|
-
name=name,
|
659
|
-
format=format,
|
660
|
-
metadata=metadata,
|
661
|
-
mimetype=mimetype,
|
662
|
-
parent_id=parent_id,
|
663
|
-
path=path,
|
664
|
-
tags=tags,
|
665
|
-
transfer_method=transfer_method,
|
666
|
-
crc32c=crc32c,
|
667
|
-
md5=md5,
|
668
|
-
sha1=sha1,
|
669
|
-
sha256=sha256,
|
670
|
-
sha512=sha512,
|
671
|
-
size=size,
|
672
|
-
)
|
673
|
-
|
674
|
-
data = input.dict(exclude_none=True)
|
675
|
-
return self.request.request_presigned_url("v1beta/put", PutResult, data=data)
|
676
|
-
|
677
|
-
def update(
|
678
|
-
self,
|
679
|
-
id: Optional[str] = None,
|
680
|
-
path: Optional[str] = None,
|
681
|
-
add_metadata: Optional[Metadata] = None,
|
682
|
-
remove_metadata: Optional[Metadata] = None,
|
683
|
-
metadata: Optional[Metadata] = None,
|
684
|
-
add_tags: Optional[Tags] = None,
|
685
|
-
remove_tags: Optional[Tags] = None,
|
686
|
-
tags: Optional[Tags] = None,
|
687
|
-
parent_id: Optional[str] = None,
|
688
|
-
updated_at: Optional[str] = None,
|
689
|
-
) -> PangeaResponse[UpdateResult]:
|
690
|
-
"""
|
691
|
-
Update a file (Beta)
|
692
|
-
|
693
|
-
Update a file.
|
694
|
-
How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
695
|
-
|
696
|
-
OperationId: share_post_v1beta_update
|
697
|
-
|
698
|
-
Args:
|
699
|
-
id (str, optional): An identifier for the file to update.
|
700
|
-
path (str, optional): An alternative to ID for providing the target file.
|
701
|
-
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.
|
702
|
-
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.
|
703
|
-
metadata (Metadata, optional): Set the object's Metadata.
|
704
|
-
add_tags (Tags, optional): A list of Tags to add. It is not an error to provide a tag which already exists.
|
705
|
-
remove_tags (Tags, optional): A list of Tags to remove. It is not an error to provide a tag which is not present.
|
706
|
-
tags (Tags, optional): Set the object's Tags.
|
707
|
-
parent_id (str, optional): Set the parent (folder) of the object.
|
708
|
-
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.
|
709
|
-
|
710
|
-
Returns:
|
711
|
-
A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
|
712
|
-
|
713
|
-
Examples:
|
714
|
-
response = share.update(
|
715
|
-
id="pos_3djfmzg2db4c6donarecbyv5begtj2bm",
|
716
|
-
remove_metadata={
|
717
|
-
"created_by": "jim",
|
718
|
-
"priority": "medium",
|
719
|
-
},
|
720
|
-
remove_tags=["irs_2023", "personal"],
|
721
|
-
)
|
722
|
-
"""
|
723
|
-
input = UpdateRequest(
|
724
|
-
id=id, # noqa: F401
|
725
|
-
path=path,
|
726
|
-
add_metadata=add_metadata,
|
727
|
-
remove_metadata=remove_metadata,
|
728
|
-
metadata=metadata,
|
729
|
-
add_tags=add_tags,
|
730
|
-
remove_tags=remove_tags,
|
731
|
-
tags=tags,
|
732
|
-
parent_id=parent_id,
|
733
|
-
updated_at=updated_at,
|
734
|
-
)
|
735
|
-
return self.request.post("v1beta/update", UpdateResult, data=input.dict(exclude_none=True))
|
736
|
-
|
737
|
-
def share_link_create(self, links: List[ShareLinkCreateItem]) -> PangeaResponse[ShareLinkCreateResult]:
|
738
|
-
"""
|
739
|
-
Create share links (Beta)
|
740
|
-
|
741
|
-
Create a share link.
|
742
|
-
How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
743
|
-
|
744
|
-
OperationId: share_post_v1beta_share_link_create
|
745
|
-
|
746
|
-
Args:
|
747
|
-
links (List[ShareLinkCreateItem]):
|
748
|
-
|
749
|
-
Returns:
|
750
|
-
A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
|
751
|
-
|
752
|
-
Examples:
|
753
|
-
response = share.share_link_create(
|
754
|
-
links=[
|
755
|
-
{
|
756
|
-
targets: ["pos_3djfmzg2db4c6donarecbyv5begtj2bm"],
|
757
|
-
link_type: LinkType.DOWNLOAD,
|
758
|
-
authenticators: [
|
759
|
-
{
|
760
|
-
"auth_type": AuthenticatorType.PASSWORD,
|
761
|
-
"auth_context": "my_fav_Pa55word",
|
762
|
-
}
|
763
|
-
],
|
764
|
-
}
|
765
|
-
],
|
766
|
-
)
|
767
|
-
"""
|
768
|
-
input = ShareLinkCreateRequest(links=links)
|
769
|
-
return self.request.post("v1beta/share/link/create", ShareLinkCreateResult, data=input.dict(exclude_none=True))
|
770
|
-
|
771
|
-
def share_link_get(self, id: str) -> PangeaResponse[ShareLinkGetResult]:
|
772
|
-
"""
|
773
|
-
Get share link (Beta)
|
774
|
-
|
775
|
-
Get a share link.
|
776
|
-
How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
777
|
-
|
778
|
-
OperationId: share_post_v1beta_share_link_get
|
779
|
-
|
780
|
-
Args:
|
781
|
-
id (str, optional): The ID of a share link.
|
782
|
-
|
783
|
-
Returns:
|
784
|
-
A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
|
785
|
-
|
786
|
-
Examples:
|
787
|
-
response = share.share_link_get(
|
788
|
-
id="psl_3djfmzg2db4c6donarecbyv5begtj2bm"
|
789
|
-
)
|
790
|
-
"""
|
791
|
-
input = ShareLinkGetRequest(id=id)
|
792
|
-
return self.request.post("v1beta/share/link/get", ShareLinkGetResult, data=input.dict(exclude_none=True))
|
793
|
-
|
794
|
-
def share_link_list(
|
795
|
-
self,
|
796
|
-
filter: Optional[Union[Dict[str, str], FilterShareLinkList]] = None,
|
797
|
-
last: Optional[str] = None,
|
798
|
-
order: Optional[ItemOrder] = None,
|
799
|
-
order_by: Optional[ShareLinkOrderBy] = None,
|
800
|
-
size: Optional[int] = None,
|
801
|
-
) -> PangeaResponse[ShareLinkListResult]:
|
802
|
-
"""
|
803
|
-
List share links (Beta)
|
804
|
-
|
805
|
-
Look up share links by filter options.
|
806
|
-
How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
807
|
-
|
808
|
-
OperationId: share_post_v1beta_share_link_list
|
809
|
-
|
810
|
-
Args:
|
811
|
-
filter (Union[Dict[str, str], ShareLinkListFilter], optional):
|
812
|
-
last (str, optional): Reflected value from a previous response to obtain the next page of results.
|
813
|
-
order (ItemOrder, optional): Order results asc(ending) or desc(ending).
|
814
|
-
order_by (ItemOrderBy, optional): Which field to order results by.
|
815
|
-
size (int, optional): Maximum results to include in the response.
|
816
|
-
|
817
|
-
Returns:
|
818
|
-
A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
|
819
|
-
|
820
|
-
Examples:
|
821
|
-
response = share.share_link_list()
|
822
|
-
"""
|
823
|
-
input = ShareLinkListRequest(filter=filter, last=last, order=order, order_by=order_by, size=size)
|
824
|
-
return self.request.post("v1beta/share/link/list", ShareLinkListResult, data=input.dict(exclude_none=True))
|
825
|
-
|
826
|
-
def share_link_delete(self, ids: List[str]) -> PangeaResponse[ShareLinkDeleteResult]:
|
827
|
-
"""
|
828
|
-
Delete share links (Beta)
|
829
|
-
|
830
|
-
Delete share links.
|
831
|
-
How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
832
|
-
|
833
|
-
OperationId: share_post_v1beta_share_link_delete
|
834
|
-
|
835
|
-
Args:
|
836
|
-
ids (List[str]): list of the share link's id to delete
|
837
|
-
|
838
|
-
Returns:
|
839
|
-
A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
|
840
|
-
|
841
|
-
Examples:
|
842
|
-
response = share.share_link_delete(
|
843
|
-
ids=["psl_3djfmzg2db4c6donarecbyv5begtj2bm"]
|
844
|
-
)
|
845
|
-
"""
|
846
|
-
input = ShareLinkDeleteRequest(ids=ids)
|
847
|
-
return self.request.post("v1beta/share/link/delete", ShareLinkDeleteResult, data=input.dict(exclude_none=True))
|
848
|
-
|
849
|
-
def share_link_send(
|
850
|
-
self, links: List[ShareLinkSendItem], sender_email: str, sender_name: Optional[str] = None
|
851
|
-
) -> PangeaResponse[ShareLinkSendResult]:
|
852
|
-
"""
|
853
|
-
Send share links (Beta)
|
854
|
-
|
855
|
-
Send a secure share-link notification to a set of email addresses. The
|
856
|
-
notification email will contain an Open button that the recipient can
|
857
|
-
use to follow the secured share-link to authenticate and then access the
|
858
|
-
shared content.
|
859
|
-
How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
860
|
-
|
861
|
-
OperationId: share_post_v1beta_share_link_send
|
862
|
-
|
863
|
-
Args:
|
864
|
-
sender_email: An email address.
|
865
|
-
|
866
|
-
Returns:
|
867
|
-
A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
|
868
|
-
|
869
|
-
Examples:
|
870
|
-
response = share.share_link_send(
|
871
|
-
links=[ShareLinkSendItem(id=link.id, email="foo@example.org")],
|
872
|
-
sender_email="sender@example.org",
|
873
|
-
)
|
874
|
-
"""
|
875
|
-
|
876
|
-
input = ShareLinkSendRequest(links=links, sender_email=sender_email, sender_name=sender_name)
|
877
|
-
return self.request.post("v1beta/share/link/send", ShareLinkSendResult, data=input.dict(exclude_none=True))
|