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/asyncio/services/share.py
DELETED
@@ -1,573 +0,0 @@
|
|
1
|
-
# Copyright 2022 Pangea Cyber Corporation
|
2
|
-
# Author: Pangea Cyber Corporation
|
3
|
-
import io
|
4
|
-
from typing import Dict, List, Optional, Tuple, Union
|
5
|
-
|
6
|
-
import pangea.services.share.share as m
|
7
|
-
from .base import ServiceBaseAsync
|
8
|
-
from pangea.response import PangeaResponse, TransferMethod
|
9
|
-
from pangea.services.share.file_format import FileFormat
|
10
|
-
from pangea.utils import get_file_size, get_file_upload_params
|
11
|
-
|
12
|
-
|
13
|
-
class ShareAsync(ServiceBaseAsync):
|
14
|
-
"""Share service client."""
|
15
|
-
|
16
|
-
service_name = "share"
|
17
|
-
|
18
|
-
async def delete(
|
19
|
-
self, id: Optional[str] = None, path: Optional[str] = None, force: Optional[bool] = None
|
20
|
-
) -> PangeaResponse[m.DeleteResult]:
|
21
|
-
"""
|
22
|
-
Delete (Beta)
|
23
|
-
|
24
|
-
Delete object by ID or path. If both are supplied, the path must match
|
25
|
-
that of the object represented by the ID.
|
26
|
-
How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
27
|
-
|
28
|
-
OperationId: share_post_v1beta_delete
|
29
|
-
|
30
|
-
Args:
|
31
|
-
id (str, optional): The ID of the object to delete.
|
32
|
-
path (str, optional): The path of the object to delete.
|
33
|
-
force (bool, optional): If true, delete a folder even if it's not empty.
|
34
|
-
|
35
|
-
Returns:
|
36
|
-
A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
|
37
|
-
|
38
|
-
Examples:
|
39
|
-
response = await share.delete(id="pos_3djfmzg2db4c6donarecbyv5begtj2bm")
|
40
|
-
"""
|
41
|
-
|
42
|
-
input = m.DeleteRequest(id=id, path=path, force=force)
|
43
|
-
return await self.request.post("v1beta/delete", m.DeleteResult, data=input.dict(exclude_none=True))
|
44
|
-
|
45
|
-
async def folder_create(
|
46
|
-
self,
|
47
|
-
name: Optional[str] = None,
|
48
|
-
metadata: Optional[m.Metadata] = None,
|
49
|
-
parent_id: Optional[str] = None,
|
50
|
-
path: Optional[str] = None,
|
51
|
-
tags: Optional[m.Tags] = None,
|
52
|
-
) -> PangeaResponse[m.FolderCreateResult]:
|
53
|
-
"""
|
54
|
-
Create a folder (Beta)
|
55
|
-
|
56
|
-
Create a folder, either by name or path and parent_id.
|
57
|
-
How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
58
|
-
|
59
|
-
OperationId: share_post_v1beta_folder_create
|
60
|
-
|
61
|
-
Args:
|
62
|
-
name (str, optional): The name of an object.
|
63
|
-
metadata (Metadata, optional): A set of string-based key/value pairs used to provide additional data about an object.
|
64
|
-
parent_id (str, optional): The ID of a stored object.
|
65
|
-
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.
|
66
|
-
tags (Tags, optional): A list of user-defined tags.
|
67
|
-
|
68
|
-
Returns:
|
69
|
-
A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
|
70
|
-
|
71
|
-
Examples:
|
72
|
-
response = await share.folder_create(
|
73
|
-
metadata={
|
74
|
-
"created_by": "jim",
|
75
|
-
"priority": "medium",
|
76
|
-
},
|
77
|
-
parent_id="pos_3djfmzg2db4c6donarecbyv5begtj2bm",
|
78
|
-
path="/",
|
79
|
-
tags=["irs_2023", "personal"],
|
80
|
-
)
|
81
|
-
"""
|
82
|
-
|
83
|
-
input = m.FolderCreateRequest(name=name, metadata=metadata, parent_id=parent_id, path=path, tags=tags)
|
84
|
-
return await self.request.post("v1beta/folder/create", m.FolderCreateResult, data=input.dict(exclude_none=True))
|
85
|
-
|
86
|
-
async def get(
|
87
|
-
self, id: Optional[str] = None, path: Optional[str] = None, transfer_method: Optional[TransferMethod] = None
|
88
|
-
) -> PangeaResponse[m.GetResult]:
|
89
|
-
"""
|
90
|
-
Get an object (Beta)
|
91
|
-
|
92
|
-
Get object. If both ID and Path are supplied, the call will fail if the
|
93
|
-
target object doesn't match both properties.
|
94
|
-
How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
95
|
-
|
96
|
-
OperationId: share_post_v1beta_get
|
97
|
-
|
98
|
-
Args:
|
99
|
-
id (str, optional): The ID of the object to retrieve.
|
100
|
-
path (str, optional): The path of the object to retrieve.
|
101
|
-
transfer_method (TransferMethod, optional): The requested transfer method for the file data.
|
102
|
-
|
103
|
-
Returns:
|
104
|
-
A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
|
105
|
-
|
106
|
-
Examples:
|
107
|
-
response = await share.get(
|
108
|
-
id="pos_3djfmzg2db4c6donarecbyv5begtj2bm",
|
109
|
-
path="/",
|
110
|
-
)
|
111
|
-
"""
|
112
|
-
|
113
|
-
input = m.GetRequest(
|
114
|
-
id=id,
|
115
|
-
path=path,
|
116
|
-
transfer_method=transfer_method,
|
117
|
-
)
|
118
|
-
return await self.request.post("v1beta/get", m.GetResult, data=input.dict(exclude_none=True))
|
119
|
-
|
120
|
-
async def get_archive(
|
121
|
-
self,
|
122
|
-
ids: List[str] = [],
|
123
|
-
format: Optional[m.ArchiveFormat] = None,
|
124
|
-
transfer_method: Optional[TransferMethod] = None,
|
125
|
-
) -> PangeaResponse[m.GetArchiveResult]:
|
126
|
-
"""
|
127
|
-
Get archive (Beta)
|
128
|
-
|
129
|
-
Get an archive file of multiple objects.
|
130
|
-
How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
131
|
-
|
132
|
-
OperationId: share_post_v1beta_get_archive
|
133
|
-
|
134
|
-
Args:
|
135
|
-
ids (List[str]): The IDs of the objects to include in the archive. Folders include all children.
|
136
|
-
format (ArchiveFormat, optional): The format to use for the built archive.
|
137
|
-
transfer_method (TransferMethod, optional): The requested transfer method for the file data.
|
138
|
-
|
139
|
-
Returns:
|
140
|
-
A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
|
141
|
-
|
142
|
-
Examples:
|
143
|
-
response = await share.get_archive(
|
144
|
-
ids=["pos_3djfmzg2db4c6donarecbyv5begtj2bm"],
|
145
|
-
)
|
146
|
-
"""
|
147
|
-
|
148
|
-
if (
|
149
|
-
transfer_method is not None
|
150
|
-
and transfer_method != TransferMethod.DEST_URL
|
151
|
-
and transfer_method != TransferMethod.MULTIPART
|
152
|
-
):
|
153
|
-
raise ValueError(f"Only {TransferMethod.DEST_URL} and {TransferMethod.MULTIPART} are supported")
|
154
|
-
|
155
|
-
input = m.GetArchiveRequest(ids=ids, format=format, transfer_method=transfer_method)
|
156
|
-
return await self.request.post("v1beta/get_archive", m.GetArchiveResult, data=input.dict(exclude_none=True))
|
157
|
-
|
158
|
-
async def list(
|
159
|
-
self,
|
160
|
-
filter: Optional[Union[Dict[str, str], m.FilterList]] = None,
|
161
|
-
last: Optional[str] = None,
|
162
|
-
order: Optional[m.ItemOrder] = None,
|
163
|
-
order_by: Optional[m.ItemOrderBy] = None,
|
164
|
-
size: Optional[int] = None,
|
165
|
-
) -> PangeaResponse[m.ListResult]:
|
166
|
-
"""
|
167
|
-
List (Beta)
|
168
|
-
|
169
|
-
List or filter/search records.
|
170
|
-
How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
171
|
-
|
172
|
-
OperationId: share_post_v1beta_list
|
173
|
-
|
174
|
-
Args:
|
175
|
-
filter (Union[Dict[str, str], FilterList], optional):
|
176
|
-
last (str, optional): Reflected value from a previous response to obtain the next page of results.
|
177
|
-
order (ItemOrder, optional): Order results asc(ending) or desc(ending).
|
178
|
-
order_by (ItemOrderBy, optional): Which field to order results by.
|
179
|
-
size (int, optional): Maximum results to include in the response.
|
180
|
-
|
181
|
-
Returns:
|
182
|
-
A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
|
183
|
-
|
184
|
-
Examples:
|
185
|
-
response = await share.list()
|
186
|
-
"""
|
187
|
-
|
188
|
-
input = m.ListRequest(filter=filter, last=last, order=order, order_by=order_by, size=size)
|
189
|
-
return await self.request.post("v1beta/list", m.ListResult, data=input.dict(exclude_none=True))
|
190
|
-
|
191
|
-
async def put(
|
192
|
-
self,
|
193
|
-
file: io.BufferedReader,
|
194
|
-
name: Optional[str] = None,
|
195
|
-
path: Optional[str] = None,
|
196
|
-
format: Optional[FileFormat] = None,
|
197
|
-
metadata: Optional[m.Metadata] = None,
|
198
|
-
mimetype: Optional[str] = None,
|
199
|
-
parent_id: Optional[str] = None,
|
200
|
-
tags: Optional[m.Tags] = None,
|
201
|
-
transfer_method: Optional[TransferMethod] = TransferMethod.POST_URL,
|
202
|
-
crc32c: Optional[str] = None,
|
203
|
-
md5: Optional[str] = None,
|
204
|
-
sha1: Optional[str] = None,
|
205
|
-
sha256: Optional[str] = None,
|
206
|
-
sha512: Optional[str] = None,
|
207
|
-
size: Optional[int] = None,
|
208
|
-
) -> PangeaResponse[m.PutResult]:
|
209
|
-
"""
|
210
|
-
Upload a file (Beta)
|
211
|
-
|
212
|
-
Upload a file.
|
213
|
-
How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
214
|
-
|
215
|
-
OperationId: share_post_v1beta_put
|
216
|
-
|
217
|
-
Args:
|
218
|
-
file (io.BufferedReader):
|
219
|
-
name (str, optional): The name of the object to store.
|
220
|
-
path (str, optional): An optional path where the file should be placed. Will auto-create directories if necessary.
|
221
|
-
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.
|
222
|
-
metadata (Metadata, optional): A set of string-based key/value pairs used to provide additional data about an object.
|
223
|
-
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.
|
224
|
-
parent_id (str, optional): The parent ID of the object (a folder). Leave blank to keep in the root folder.
|
225
|
-
tags (Tags, optional): A list of user-defined tags.
|
226
|
-
transfer_method (TransferMethod, optional): The transfer method used to upload the file data.
|
227
|
-
crc32c (str, optional): The hexadecimal-encoded CRC32C hash of the file data, which will be verified by the server if provided.
|
228
|
-
md5 (str, optional): The hexadecimal-encoded MD5 hash of the file data, which will be verified by the server if provided.
|
229
|
-
sha1 (str, optional): The hexadecimal-encoded SHA1 hash of the file data, which will be verified by the server if provided.
|
230
|
-
sha256 (str, optional): The SHA256 hash of the file data, which will be verified by the server if provided.
|
231
|
-
sha512 (str, optional): The hexadecimal-encoded SHA512 hash of the file data, which will be verified by the server if provided.
|
232
|
-
size (str, optional): The size (in bytes) of the file. If the upload doesn't match, the call will fail.
|
233
|
-
|
234
|
-
Returns:
|
235
|
-
A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
|
236
|
-
|
237
|
-
Examples:
|
238
|
-
try:
|
239
|
-
with open("./path/to/file.pdf", "rb") as f:
|
240
|
-
response = await share.put(file=f)
|
241
|
-
print(f"Response: {response.result}")
|
242
|
-
except pe.PangeaAPIException as e:
|
243
|
-
print(f"Request Error: {e.response.summary}")
|
244
|
-
for err in e.errors:
|
245
|
-
print(f"\\t{err.detail} \\n")
|
246
|
-
"""
|
247
|
-
|
248
|
-
files: List[Tuple] = [("upload", ("file", file, "application/octet-stream"))]
|
249
|
-
|
250
|
-
if transfer_method == TransferMethod.POST_URL:
|
251
|
-
params = get_file_upload_params(file)
|
252
|
-
crc32c = params.crc_hex
|
253
|
-
sha256 = params.sha256_hex
|
254
|
-
size = params.size
|
255
|
-
elif size is None and get_file_size(file=file) == 0:
|
256
|
-
# Needed to upload zero byte files
|
257
|
-
size = 0
|
258
|
-
|
259
|
-
input = m.PutRequest(
|
260
|
-
name=name,
|
261
|
-
format=format,
|
262
|
-
metadata=metadata,
|
263
|
-
mimetype=mimetype,
|
264
|
-
parent_id=parent_id,
|
265
|
-
path=path,
|
266
|
-
tags=tags,
|
267
|
-
transfer_method=transfer_method,
|
268
|
-
crc32c=crc32c,
|
269
|
-
md5=md5,
|
270
|
-
sha1=sha1,
|
271
|
-
sha256=sha256,
|
272
|
-
sha512=sha512,
|
273
|
-
size=size,
|
274
|
-
)
|
275
|
-
data = input.dict(exclude_none=True)
|
276
|
-
return await self.request.post("v1beta/put", m.PutResult, data=data, files=files)
|
277
|
-
|
278
|
-
async def request_upload_url(
|
279
|
-
self,
|
280
|
-
name: Optional[str] = None,
|
281
|
-
path: Optional[str] = None,
|
282
|
-
format: Optional[FileFormat] = None,
|
283
|
-
metadata: Optional[m.Metadata] = None,
|
284
|
-
mimetype: Optional[str] = None,
|
285
|
-
parent_id: Optional[str] = None,
|
286
|
-
tags: Optional[m.Tags] = None,
|
287
|
-
transfer_method: Optional[TransferMethod] = TransferMethod.PUT_URL,
|
288
|
-
md5: Optional[str] = None,
|
289
|
-
sha1: Optional[str] = None,
|
290
|
-
sha512: Optional[str] = None,
|
291
|
-
crc32c: Optional[str] = None,
|
292
|
-
sha256: Optional[str] = None,
|
293
|
-
size: Optional[int] = None,
|
294
|
-
) -> PangeaResponse[m.PutResult]:
|
295
|
-
"""
|
296
|
-
Request upload URL (Beta)
|
297
|
-
|
298
|
-
Request an upload URL.
|
299
|
-
How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
300
|
-
|
301
|
-
OperationId: share_post_v1beta_put 2
|
302
|
-
|
303
|
-
Args:
|
304
|
-
name (str, optional): The name of the object to store.
|
305
|
-
path (str, optional): An optional path where the file should be placed. Will auto-create directories if necessary.
|
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
|
-
md5 (str, optional): The hexadecimal-encoded MD5 hash of the file data, which will be verified by the server if provided.
|
313
|
-
sha1 (str, optional): The hexadecimal-encoded SHA1 hash of the file data, which will be verified by the server if provided.
|
314
|
-
sha512 (str, optional): The hexadecimal-encoded SHA512 hash of the file data, which will be verified by the server if provided.
|
315
|
-
crc32c (str, optional): The hexadecimal-encoded CRC32C hash of the file data, which will be verified by the server if provided.
|
316
|
-
sha256 (str, optional): The SHA256 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
|
-
|
319
|
-
Returns:
|
320
|
-
A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
|
321
|
-
|
322
|
-
Examples:
|
323
|
-
response = await share.request_upload_url(
|
324
|
-
transfer_method=TransferMethod.POST_URL,
|
325
|
-
crc32c="515f7c32",
|
326
|
-
sha256="c0b56b1a154697f79d27d57a3a2aad4c93849aa2239cd23048fc6f45726271cc",
|
327
|
-
size=222089,
|
328
|
-
metadata={
|
329
|
-
"created_by": "jim",
|
330
|
-
"priority": "medium",
|
331
|
-
},
|
332
|
-
parent_id="pos_3djfmzg2db4c6donarecbyv5begtj2bm",
|
333
|
-
path="/",
|
334
|
-
tags=["irs_2023", "personal"],
|
335
|
-
)
|
336
|
-
"""
|
337
|
-
|
338
|
-
input = m.PutRequest(
|
339
|
-
name=name,
|
340
|
-
format=format,
|
341
|
-
metadata=metadata,
|
342
|
-
mimetype=mimetype,
|
343
|
-
parent_id=parent_id,
|
344
|
-
path=path,
|
345
|
-
tags=tags,
|
346
|
-
transfer_method=transfer_method,
|
347
|
-
crc32c=crc32c,
|
348
|
-
md5=md5,
|
349
|
-
sha1=sha1,
|
350
|
-
sha256=sha256,
|
351
|
-
sha512=sha512,
|
352
|
-
size=size,
|
353
|
-
)
|
354
|
-
|
355
|
-
data = input.dict(exclude_none=True)
|
356
|
-
return await self.request.request_presigned_url("v1beta/put", m.PutResult, data=data)
|
357
|
-
|
358
|
-
async def update(
|
359
|
-
self,
|
360
|
-
id: Optional[str] = None,
|
361
|
-
path: Optional[str] = None,
|
362
|
-
add_metadata: Optional[m.Metadata] = None,
|
363
|
-
remove_metadata: Optional[m.Metadata] = None,
|
364
|
-
metadata: Optional[m.Metadata] = None,
|
365
|
-
add_tags: Optional[m.Tags] = None,
|
366
|
-
remove_tags: Optional[m.Tags] = None,
|
367
|
-
tags: Optional[m.Tags] = None,
|
368
|
-
parent_id: Optional[str] = None,
|
369
|
-
updated_at: Optional[str] = None,
|
370
|
-
) -> PangeaResponse[m.UpdateResult]:
|
371
|
-
"""
|
372
|
-
Update a file (Beta)
|
373
|
-
|
374
|
-
Update a file.
|
375
|
-
How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
376
|
-
|
377
|
-
OperationId: share_post_v1beta_update
|
378
|
-
|
379
|
-
Args:
|
380
|
-
id (str, optional): An identifier for the file to update.
|
381
|
-
path (str, optional): An alternative to ID for providing the target file.
|
382
|
-
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.
|
383
|
-
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.
|
384
|
-
metadata (Metadata, optional): Set the object's Metadata.
|
385
|
-
add_tags (Tags, optional): A list of Tags to add. It is not an error to provide a tag which already exists.
|
386
|
-
remove_tags (Tags, optional): A list of Tags to remove. It is not an error to provide a tag which is not present.
|
387
|
-
tags (Tags, optional): Set the object's Tags.
|
388
|
-
parent_id (str, optional): Set the parent (folder) of the object.
|
389
|
-
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.
|
390
|
-
|
391
|
-
Returns:
|
392
|
-
A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
|
393
|
-
|
394
|
-
Examples:
|
395
|
-
response = await share.update(
|
396
|
-
id="pos_3djfmzg2db4c6donarecbyv5begtj2bm",
|
397
|
-
remove_metadata={
|
398
|
-
"created_by": "jim",
|
399
|
-
"priority": "medium",
|
400
|
-
},
|
401
|
-
remove_tags=["irs_2023", "personal"],
|
402
|
-
)
|
403
|
-
"""
|
404
|
-
|
405
|
-
input = m.UpdateRequest(
|
406
|
-
id=id,
|
407
|
-
path=path,
|
408
|
-
add_metadata=add_metadata,
|
409
|
-
remove_metadata=remove_metadata,
|
410
|
-
metadata=metadata,
|
411
|
-
add_tags=add_tags,
|
412
|
-
remove_tags=remove_tags,
|
413
|
-
tags=tags,
|
414
|
-
parent_id=parent_id,
|
415
|
-
updated_at=updated_at,
|
416
|
-
)
|
417
|
-
return await self.request.post("v1beta/update", m.UpdateResult, data=input.dict(exclude_none=True))
|
418
|
-
|
419
|
-
async def share_link_create(self, links: List[m.ShareLinkCreateItem]) -> PangeaResponse[m.ShareLinkCreateResult]:
|
420
|
-
"""
|
421
|
-
Create share links (Beta)
|
422
|
-
|
423
|
-
Create a share link.
|
424
|
-
How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
425
|
-
|
426
|
-
OperationId: share_post_v1beta_share_link_create
|
427
|
-
|
428
|
-
Args:
|
429
|
-
links (List[ShareLinkCreateItem]):
|
430
|
-
|
431
|
-
Returns:
|
432
|
-
A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
|
433
|
-
|
434
|
-
Examples:
|
435
|
-
response = await share.share_link_create(
|
436
|
-
links=[
|
437
|
-
{
|
438
|
-
targets: ["pos_3djfmzg2db4c6donarecbyv5begtj2bm"],
|
439
|
-
link_type: LinkType.DOWNLOAD,
|
440
|
-
authenticators: [
|
441
|
-
{
|
442
|
-
"auth_type": AuthenticatorType.PASSWORD,
|
443
|
-
"auth_context": "my_fav_Pa55word",
|
444
|
-
}
|
445
|
-
],
|
446
|
-
}
|
447
|
-
],
|
448
|
-
)
|
449
|
-
"""
|
450
|
-
|
451
|
-
input = m.ShareLinkCreateRequest(links=links)
|
452
|
-
return await self.request.post(
|
453
|
-
"v1beta/share/link/create", m.ShareLinkCreateResult, data=input.dict(exclude_none=True)
|
454
|
-
)
|
455
|
-
|
456
|
-
async def share_link_get(self, id: str) -> PangeaResponse[m.ShareLinkGetResult]:
|
457
|
-
"""
|
458
|
-
Get share link (Beta)
|
459
|
-
|
460
|
-
Get a share link.
|
461
|
-
How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
462
|
-
|
463
|
-
OperationId: share_post_v1beta_share_link_get
|
464
|
-
|
465
|
-
Args:
|
466
|
-
id (str, optional): The ID of a share link.
|
467
|
-
|
468
|
-
Returns:
|
469
|
-
A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
|
470
|
-
|
471
|
-
Examples:
|
472
|
-
response = await share.share_link_get(
|
473
|
-
id="psl_3djfmzg2db4c6donarecbyv5begtj2bm"
|
474
|
-
)
|
475
|
-
"""
|
476
|
-
|
477
|
-
input = m.ShareLinkGetRequest(id=id)
|
478
|
-
return await self.request.post(
|
479
|
-
"v1beta/share/link/get", m.ShareLinkGetResult, data=input.dict(exclude_none=True)
|
480
|
-
)
|
481
|
-
|
482
|
-
async def share_link_list(
|
483
|
-
self,
|
484
|
-
filter: Optional[Union[Dict[str, str], m.FilterShareLinkList]] = None,
|
485
|
-
last: Optional[str] = None,
|
486
|
-
order: Optional[m.ItemOrder] = None,
|
487
|
-
order_by: Optional[m.ShareLinkOrderBy] = None,
|
488
|
-
size: Optional[int] = None,
|
489
|
-
) -> PangeaResponse[m.ShareLinkListResult]:
|
490
|
-
"""
|
491
|
-
List share links (Beta)
|
492
|
-
|
493
|
-
Look up share links by filter options.
|
494
|
-
How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
495
|
-
|
496
|
-
OperationId: share_post_v1beta_share_link_list
|
497
|
-
|
498
|
-
Args:
|
499
|
-
filter (Union[Dict[str, str], ShareLinkListFilter], optional):
|
500
|
-
last (str, optional): Reflected value from a previous response to obtain the next page of results.
|
501
|
-
order (ItemOrder, optional): Order results asc(ending) or desc(ending).
|
502
|
-
order_by (ItemOrderBy, optional): Which field to order results by.
|
503
|
-
size (int, optional): Maximum results to include in the response.
|
504
|
-
|
505
|
-
Returns:
|
506
|
-
A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
|
507
|
-
|
508
|
-
Examples:
|
509
|
-
response = await share.share_link_list()
|
510
|
-
"""
|
511
|
-
|
512
|
-
input = m.ShareLinkListRequest(filter=filter, last=last, order=order, order_by=order_by, size=size)
|
513
|
-
return await self.request.post(
|
514
|
-
"v1beta/share/link/list", m.ShareLinkListResult, data=input.dict(exclude_none=True)
|
515
|
-
)
|
516
|
-
|
517
|
-
async def share_link_delete(self, ids: List[str]) -> PangeaResponse[m.ShareLinkDeleteResult]:
|
518
|
-
"""
|
519
|
-
Delete share links (Beta)
|
520
|
-
|
521
|
-
Delete share links.
|
522
|
-
How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
523
|
-
|
524
|
-
OperationId: share_post_v1beta_share_link_delete
|
525
|
-
|
526
|
-
Args:
|
527
|
-
ids (List[str]): list of the share link's id to delete
|
528
|
-
|
529
|
-
Returns:
|
530
|
-
A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
|
531
|
-
|
532
|
-
Examples:
|
533
|
-
response = await share.share_link_delete(
|
534
|
-
ids=["psl_3djfmzg2db4c6donarecbyv5begtj2bm"]
|
535
|
-
)
|
536
|
-
"""
|
537
|
-
|
538
|
-
input = m.ShareLinkDeleteRequest(ids=ids)
|
539
|
-
return await self.request.post(
|
540
|
-
"v1beta/share/link/delete", m.ShareLinkDeleteResult, data=input.dict(exclude_none=True)
|
541
|
-
)
|
542
|
-
|
543
|
-
async def share_link_send(
|
544
|
-
self, links: List[m.ShareLinkSendItem], sender_email: str, sender_name: Optional[str] = None
|
545
|
-
) -> PangeaResponse[m.ShareLinkSendResult]:
|
546
|
-
"""
|
547
|
-
Send share links (Beta)
|
548
|
-
|
549
|
-
Send a secure share-link notification to a set of email addresses. The
|
550
|
-
notification email will contain an Open button that the recipient can
|
551
|
-
use to follow the secured share-link to authenticate and then access the
|
552
|
-
shared content.
|
553
|
-
How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
554
|
-
|
555
|
-
OperationId: share_post_v1beta_share_link_send
|
556
|
-
|
557
|
-
Args:
|
558
|
-
sender_email: An email address.
|
559
|
-
|
560
|
-
Returns:
|
561
|
-
A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
|
562
|
-
|
563
|
-
Examples:
|
564
|
-
response = await share.share_link_send(
|
565
|
-
links=[ShareLinkSendItem(id=link.id, email="foo@example.org")],
|
566
|
-
sender_email="sender@example.org",
|
567
|
-
)
|
568
|
-
"""
|
569
|
-
|
570
|
-
input = m.ShareLinkSendRequest(links=links, sender_email=sender_email, sender_name=sender_name)
|
571
|
-
return await self.request.post(
|
572
|
-
"v1beta/share/link/send", m.ShareLinkSendResult, data=input.dict(exclude_none=True)
|
573
|
-
)
|
pangea/file_uploader.py
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
# Copyright 2022 Pangea Cyber Corporation
|
2
|
-
# Author: Pangea Cyber Corporation
|
3
|
-
import io
|
4
|
-
import logging
|
5
|
-
from typing import Dict, Optional
|
6
|
-
|
7
|
-
from pangea.request import PangeaConfig, PangeaRequest
|
8
|
-
from pangea.response import TransferMethod
|
9
|
-
|
10
|
-
|
11
|
-
class FileUploader:
|
12
|
-
def __init__(self):
|
13
|
-
self.logger = logging.getLogger("pangea")
|
14
|
-
self._request = PangeaRequest(
|
15
|
-
config=PangeaConfig(),
|
16
|
-
token="",
|
17
|
-
service="FileUploader",
|
18
|
-
logger=self.logger,
|
19
|
-
)
|
20
|
-
|
21
|
-
def upload_file(
|
22
|
-
self,
|
23
|
-
url: str,
|
24
|
-
file: io.BufferedReader,
|
25
|
-
transfer_method: TransferMethod = TransferMethod.PUT_URL,
|
26
|
-
file_details: Optional[Dict] = None,
|
27
|
-
):
|
28
|
-
if transfer_method == TransferMethod.PUT_URL:
|
29
|
-
files = [("file", ("filename", file, "application/octet-stream"))]
|
30
|
-
self._request.put_presigned_url(url=url, files=files)
|
31
|
-
elif transfer_method == TransferMethod.POST_URL:
|
32
|
-
files = [("file", ("filename", file, "application/octet-stream"))]
|
33
|
-
self._request.post_presigned_url(url=url, data=file_details, files=files)
|
34
|
-
else:
|
35
|
-
raise ValueError(f"Transfer method not supported: {transfer_method}")
|