pangea-sdk 5.0.0__py3-none-any.whl → 5.2.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 -1
- pangea/asyncio/request.py +20 -4
- pangea/asyncio/services/__init__.py +1 -0
- pangea/asyncio/services/audit.py +6 -10
- pangea/asyncio/services/authz.py +23 -2
- pangea/asyncio/services/base.py +21 -2
- pangea/asyncio/services/intel.py +3 -0
- pangea/asyncio/services/sanitize.py +26 -2
- pangea/asyncio/services/share.py +643 -0
- pangea/deep_verify.py +7 -1
- pangea/dump_audit.py +8 -7
- pangea/request.py +20 -6
- pangea/response.py +12 -0
- pangea/services/__init__.py +1 -0
- pangea/services/audit/audit.py +5 -10
- pangea/services/authz.py +21 -1
- pangea/services/base.py +16 -2
- pangea/services/intel.py +18 -0
- pangea/services/redact.py +16 -0
- pangea/services/sanitize.py +22 -0
- pangea/services/share/file_format.py +170 -0
- pangea/services/share/share.py +1278 -0
- pangea/utils.py +88 -17
- {pangea_sdk-5.0.0.dist-info → pangea_sdk-5.2.0.dist-info}/METADATA +11 -10
- {pangea_sdk-5.0.0.dist-info → pangea_sdk-5.2.0.dist-info}/RECORD +26 -23
- {pangea_sdk-5.0.0.dist-info → pangea_sdk-5.2.0.dist-info}/WHEEL +0 -0
@@ -0,0 +1,643 @@
|
|
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
|
+
) -> PangeaResponse[m.FolderCreateResult]:
|
97
|
+
"""
|
98
|
+
Create a folder
|
99
|
+
|
100
|
+
Create a folder, either by name or path and parent_id.
|
101
|
+
|
102
|
+
OperationId: share_post_v1_folder_create
|
103
|
+
|
104
|
+
Args:
|
105
|
+
name (str, optional): The name of an object.
|
106
|
+
metadata (Metadata, optional): A set of string-based key/value pairs used to provide additional data about an object.
|
107
|
+
parent_id (str, optional): The ID of a stored object.
|
108
|
+
folder (str, optional): The folder to place the folder in. Must
|
109
|
+
match `parent_id` if also set.
|
110
|
+
tags (Tags, optional): A list of user-defined tags.
|
111
|
+
bucket_id (str, optional): The bucket to use, if not the default.
|
112
|
+
|
113
|
+
Returns:
|
114
|
+
A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
|
115
|
+
|
116
|
+
Examples:
|
117
|
+
response = await share.folder_create(
|
118
|
+
metadata={
|
119
|
+
"created_by": "jim",
|
120
|
+
"priority": "medium",
|
121
|
+
},
|
122
|
+
parent_id="pos_3djfmzg2db4c6donarecbyv5begtj2bm",
|
123
|
+
folder="/",
|
124
|
+
tags=["irs_2023", "personal"],
|
125
|
+
)
|
126
|
+
"""
|
127
|
+
|
128
|
+
input = m.FolderCreateRequest(
|
129
|
+
name=name, metadata=metadata, parent_id=parent_id, folder=folder, tags=tags, bucket_id=bucket_id
|
130
|
+
)
|
131
|
+
return await self.request.post(
|
132
|
+
"v1/folder/create", m.FolderCreateResult, data=input.model_dump(exclude_none=True)
|
133
|
+
)
|
134
|
+
|
135
|
+
async def get(
|
136
|
+
self,
|
137
|
+
id: Optional[str] = None,
|
138
|
+
transfer_method: Optional[TransferMethod] = None,
|
139
|
+
bucket_id: Optional[str] = None,
|
140
|
+
password: Optional[str] = None,
|
141
|
+
) -> PangeaResponse[m.GetResult]:
|
142
|
+
"""
|
143
|
+
Get an object
|
144
|
+
|
145
|
+
Get object. If both ID and Path are supplied, the call will fail if the
|
146
|
+
target object doesn't match both properties.
|
147
|
+
|
148
|
+
OperationId: share_post_v1_get
|
149
|
+
|
150
|
+
Args:
|
151
|
+
id (str, optional): The ID of the object to retrieve.
|
152
|
+
transfer_method (TransferMethod, optional): The requested transfer method for the file data.
|
153
|
+
bucket_id (str, optional): The bucket to use, if not the default.
|
154
|
+
password (str, optional): If the file was protected with a password, the password to decrypt with.
|
155
|
+
|
156
|
+
Returns:
|
157
|
+
A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
|
158
|
+
|
159
|
+
Examples:
|
160
|
+
response = await share.get(
|
161
|
+
id="pos_3djfmzg2db4c6donarecbyv5begtj2bm",
|
162
|
+
folder="/",
|
163
|
+
)
|
164
|
+
"""
|
165
|
+
|
166
|
+
input = m.GetRequest(id=id, transfer_method=transfer_method, bucket_id=bucket_id, password=password)
|
167
|
+
return await self.request.post("v1/get", m.GetResult, data=input.model_dump(exclude_none=True))
|
168
|
+
|
169
|
+
async def get_archive(
|
170
|
+
self,
|
171
|
+
ids: List[str] = [],
|
172
|
+
format: Optional[m.ArchiveFormat] = None,
|
173
|
+
transfer_method: Optional[TransferMethod] = None,
|
174
|
+
bucket_id: Optional[str] = None,
|
175
|
+
) -> PangeaResponse[m.GetArchiveResult]:
|
176
|
+
"""
|
177
|
+
Get archive
|
178
|
+
|
179
|
+
Get an archive file of multiple objects.
|
180
|
+
|
181
|
+
OperationId: share_post_v1_get_archive
|
182
|
+
|
183
|
+
Args:
|
184
|
+
ids (List[str]): The IDs of the objects to include in the archive. Folders include all children.
|
185
|
+
format (ArchiveFormat, optional): The format to use for the built archive.
|
186
|
+
transfer_method (TransferMethod, optional): The requested transfer method for the file data.
|
187
|
+
bucket_id (str, optional): The bucket to use, if not the default.
|
188
|
+
|
189
|
+
Returns:
|
190
|
+
A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
|
191
|
+
|
192
|
+
Examples:
|
193
|
+
response = await share.get_archive(
|
194
|
+
ids=["pos_3djfmzg2db4c6donarecbyv5begtj2bm"],
|
195
|
+
)
|
196
|
+
"""
|
197
|
+
|
198
|
+
if (
|
199
|
+
transfer_method is not None
|
200
|
+
and transfer_method != TransferMethod.DEST_URL
|
201
|
+
and transfer_method != TransferMethod.MULTIPART
|
202
|
+
):
|
203
|
+
raise ValueError(f"Only {TransferMethod.DEST_URL} and {TransferMethod.MULTIPART} are supported")
|
204
|
+
|
205
|
+
input = m.GetArchiveRequest(ids=ids, format=format, transfer_method=transfer_method, bucket_id=bucket_id)
|
206
|
+
return await self.request.post("v1/get_archive", m.GetArchiveResult, data=input.model_dump(exclude_none=True))
|
207
|
+
|
208
|
+
async def list(
|
209
|
+
self,
|
210
|
+
filter: Optional[Union[Dict[str, str], m.FilterList]] = None,
|
211
|
+
last: Optional[str] = None,
|
212
|
+
order: Optional[m.ItemOrder] = None,
|
213
|
+
order_by: Optional[m.ItemOrderBy] = None,
|
214
|
+
size: Optional[int] = None,
|
215
|
+
bucket_id: Optional[str] = None,
|
216
|
+
) -> PangeaResponse[m.ListResult]:
|
217
|
+
"""
|
218
|
+
List
|
219
|
+
|
220
|
+
List or filter/search records.
|
221
|
+
|
222
|
+
OperationId: share_post_v1_list
|
223
|
+
|
224
|
+
Args:
|
225
|
+
filter (Union[Dict[str, str], FilterList], optional):
|
226
|
+
last (str, optional): Reflected value from a previous response to obtain the next page of results.
|
227
|
+
order (ItemOrder, optional): Order results asc(ending) or desc(ending).
|
228
|
+
order_by (ItemOrderBy, optional): Which field to order results by.
|
229
|
+
size (int, optional): Maximum results to include in the response.
|
230
|
+
bucket_id (str, optional): The bucket to use, if not the default.
|
231
|
+
|
232
|
+
Returns:
|
233
|
+
A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
|
234
|
+
|
235
|
+
Examples:
|
236
|
+
response = await share.list()
|
237
|
+
"""
|
238
|
+
|
239
|
+
input = m.ListRequest(filter=filter, last=last, order=order, order_by=order_by, size=size, bucket_id=bucket_id)
|
240
|
+
return await self.request.post("v1/list", m.ListResult, data=input.model_dump(exclude_none=True))
|
241
|
+
|
242
|
+
async def put(
|
243
|
+
self,
|
244
|
+
file: io.BufferedReader,
|
245
|
+
name: Optional[str] = None,
|
246
|
+
folder: Optional[str] = None,
|
247
|
+
format: Optional[FileFormat] = None,
|
248
|
+
metadata: Optional[m.Metadata] = None,
|
249
|
+
mimetype: Optional[str] = None,
|
250
|
+
parent_id: Optional[str] = None,
|
251
|
+
tags: Optional[m.Tags] = None,
|
252
|
+
transfer_method: Optional[TransferMethod] = TransferMethod.POST_URL,
|
253
|
+
crc32c: Optional[str] = None,
|
254
|
+
md5: Optional[str] = None,
|
255
|
+
sha1: Optional[str] = None,
|
256
|
+
sha256: Optional[str] = None,
|
257
|
+
sha512: Optional[str] = None,
|
258
|
+
size: Optional[int] = None,
|
259
|
+
bucket_id: Optional[str] = None,
|
260
|
+
password: Optional[str] = None,
|
261
|
+
password_algorithm: Optional[str] = None,
|
262
|
+
) -> PangeaResponse[m.PutResult]:
|
263
|
+
"""
|
264
|
+
Upload a file
|
265
|
+
|
266
|
+
Upload a file.
|
267
|
+
|
268
|
+
OperationId: share_post_v1_put
|
269
|
+
|
270
|
+
Args:
|
271
|
+
file (io.BufferedReader):
|
272
|
+
name (str, optional): The name of the object to store.
|
273
|
+
folder (str, optional): The path to the parent folder. Leave blank
|
274
|
+
for the root folder. Path must resolve to `parent_id` if also set.
|
275
|
+
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.
|
276
|
+
metadata (Metadata, optional): A set of string-based key/value pairs used to provide additional data about an object.
|
277
|
+
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.
|
278
|
+
parent_id (str, optional): The parent ID of the object (a folder). Leave blank to keep in the root folder.
|
279
|
+
tags (Tags, optional): A list of user-defined tags.
|
280
|
+
transfer_method (TransferMethod, optional): The transfer method used to upload the file data.
|
281
|
+
crc32c (str, optional): The hexadecimal-encoded CRC32C hash of the file data, which will be verified by the server if provided.
|
282
|
+
md5 (str, optional): The hexadecimal-encoded MD5 hash of the file data, which will be verified by the server if provided.
|
283
|
+
sha1 (str, optional): The hexadecimal-encoded SHA1 hash of the file data, which will be verified by the server if provided.
|
284
|
+
sha256 (str, optional): The SHA256 hash of the file data, which will be verified by the server if provided.
|
285
|
+
sha512 (str, optional): The hexadecimal-encoded SHA512 hash of the file data, which will be verified by the server if provided.
|
286
|
+
size (str, optional): The size (in bytes) of the file. If the upload doesn't match, the call will fail.
|
287
|
+
bucket_id (str, optional): The bucket to use, if not the default.
|
288
|
+
password (str, optional): An optional password to protect the file with. Downloading the file will require this password.
|
289
|
+
password_algorithm (str, optional): An optional password algorithm to protect the file with. See symmetric vault password_algorithm.
|
290
|
+
Returns:
|
291
|
+
A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
|
292
|
+
|
293
|
+
Examples:
|
294
|
+
try:
|
295
|
+
with open("./path/to/file.pdf", "rb") as f:
|
296
|
+
response = await share.put(file=f)
|
297
|
+
print(f"Response: {response.result}")
|
298
|
+
except pe.PangeaAPIException as e:
|
299
|
+
print(f"Request Error: {e.response.summary}")
|
300
|
+
for err in e.errors:
|
301
|
+
print(f"\\t{err.detail} \\n")
|
302
|
+
"""
|
303
|
+
|
304
|
+
files: List[Tuple] = [("upload", (name, file, "application/octet-stream"))]
|
305
|
+
|
306
|
+
if transfer_method == TransferMethod.POST_URL:
|
307
|
+
params = get_file_upload_params(file)
|
308
|
+
crc32c = params.crc_hex
|
309
|
+
sha256 = params.sha256_hex
|
310
|
+
size = params.size
|
311
|
+
elif size is None and get_file_size(file=file) == 0:
|
312
|
+
# Needed to upload zero byte files
|
313
|
+
size = 0
|
314
|
+
|
315
|
+
input = m.PutRequest(
|
316
|
+
name=name,
|
317
|
+
format=format,
|
318
|
+
metadata=metadata,
|
319
|
+
mimetype=mimetype,
|
320
|
+
parent_id=parent_id,
|
321
|
+
folder=folder,
|
322
|
+
tags=tags,
|
323
|
+
transfer_method=transfer_method,
|
324
|
+
crc32c=crc32c,
|
325
|
+
md5=md5,
|
326
|
+
sha1=sha1,
|
327
|
+
sha256=sha256,
|
328
|
+
sha512=sha512,
|
329
|
+
size=size,
|
330
|
+
bucket_id=bucket_id,
|
331
|
+
password=password,
|
332
|
+
password_algorithm=password_algorithm,
|
333
|
+
)
|
334
|
+
data = input.model_dump(exclude_none=True)
|
335
|
+
return await self.request.post("v1/put", m.PutResult, data=data, files=files)
|
336
|
+
|
337
|
+
async def request_upload_url(
|
338
|
+
self,
|
339
|
+
name: Optional[str] = None,
|
340
|
+
folder: Optional[str] = None,
|
341
|
+
format: Optional[FileFormat] = None,
|
342
|
+
metadata: Optional[m.Metadata] = None,
|
343
|
+
mimetype: Optional[str] = None,
|
344
|
+
parent_id: Optional[str] = None,
|
345
|
+
tags: Optional[m.Tags] = None,
|
346
|
+
transfer_method: Optional[TransferMethod] = TransferMethod.PUT_URL,
|
347
|
+
md5: Optional[str] = None,
|
348
|
+
sha1: Optional[str] = None,
|
349
|
+
sha512: Optional[str] = None,
|
350
|
+
crc32c: Optional[str] = None,
|
351
|
+
sha256: Optional[str] = None,
|
352
|
+
size: Optional[int] = None,
|
353
|
+
bucket_id: Optional[str] = None,
|
354
|
+
) -> PangeaResponse[m.PutResult]:
|
355
|
+
"""
|
356
|
+
Request upload URL
|
357
|
+
|
358
|
+
Request an upload URL.
|
359
|
+
|
360
|
+
OperationId: share_post_v1_put 2
|
361
|
+
|
362
|
+
Args:
|
363
|
+
name (str, optional): The name of the object to store.
|
364
|
+
folder (str, optional): The path to the parent folder. Leave blank
|
365
|
+
for the root folder. Path must resolve to `parent_id` if also set.
|
366
|
+
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.
|
367
|
+
metadata (Metadata, optional): A set of string-based key/value pairs used to provide additional data about an object.
|
368
|
+
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.
|
369
|
+
parent_id (str, optional): The parent ID of the object (a folder). Leave blank to keep in the root folder.
|
370
|
+
tags (Tags, optional): A list of user-defined tags.
|
371
|
+
transfer_method (TransferMethod, optional): The transfer method used to upload the file data.
|
372
|
+
md5 (str, optional): The hexadecimal-encoded MD5 hash of the file data, which will be verified by the server if provided.
|
373
|
+
sha1 (str, optional): The hexadecimal-encoded SHA1 hash of the file data, which will be verified by the server if provided.
|
374
|
+
sha512 (str, optional): The hexadecimal-encoded SHA512 hash of the file data, which will be verified by the server if provided.
|
375
|
+
crc32c (str, optional): The hexadecimal-encoded CRC32C hash of the file data, which will be verified by the server if provided.
|
376
|
+
sha256 (str, optional): The SHA256 hash of the file data, which will be verified by the server if provided.
|
377
|
+
size (str, optional): The size (in bytes) of the file. If the upload doesn't match, the call will fail.
|
378
|
+
bucket_id (str, optional): The bucket to use, if not the default.
|
379
|
+
|
380
|
+
Returns:
|
381
|
+
A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
|
382
|
+
|
383
|
+
Examples:
|
384
|
+
response = await share.request_upload_url(
|
385
|
+
transfer_method=TransferMethod.POST_URL,
|
386
|
+
crc32c="515f7c32",
|
387
|
+
sha256="c0b56b1a154697f79d27d57a3a2aad4c93849aa2239cd23048fc6f45726271cc",
|
388
|
+
size=222089,
|
389
|
+
metadata={
|
390
|
+
"created_by": "jim",
|
391
|
+
"priority": "medium",
|
392
|
+
},
|
393
|
+
parent_id="pos_3djfmzg2db4c6donarecbyv5begtj2bm",
|
394
|
+
folder="/",
|
395
|
+
tags=["irs_2023", "personal"],
|
396
|
+
)
|
397
|
+
"""
|
398
|
+
|
399
|
+
input = m.PutRequest(
|
400
|
+
name=name,
|
401
|
+
format=format,
|
402
|
+
metadata=metadata,
|
403
|
+
mimetype=mimetype,
|
404
|
+
parent_id=parent_id,
|
405
|
+
folder=folder,
|
406
|
+
tags=tags,
|
407
|
+
transfer_method=transfer_method,
|
408
|
+
crc32c=crc32c,
|
409
|
+
md5=md5,
|
410
|
+
sha1=sha1,
|
411
|
+
sha256=sha256,
|
412
|
+
sha512=sha512,
|
413
|
+
size=size,
|
414
|
+
bucket_id=bucket_id,
|
415
|
+
)
|
416
|
+
|
417
|
+
data = input.model_dump(exclude_none=True)
|
418
|
+
return await self.request.request_presigned_url("v1/put", m.PutResult, data=data)
|
419
|
+
|
420
|
+
async def update(
|
421
|
+
self,
|
422
|
+
id: Optional[str] = None,
|
423
|
+
folder: Optional[str] = None,
|
424
|
+
add_metadata: Optional[m.Metadata] = None,
|
425
|
+
remove_metadata: Optional[m.Metadata] = None,
|
426
|
+
metadata: Optional[m.Metadata] = None,
|
427
|
+
add_tags: Optional[m.Tags] = None,
|
428
|
+
remove_tags: Optional[m.Tags] = None,
|
429
|
+
tags: Optional[m.Tags] = None,
|
430
|
+
parent_id: Optional[str] = None,
|
431
|
+
updated_at: Optional[str] = None,
|
432
|
+
bucket_id: Optional[str] = None,
|
433
|
+
) -> PangeaResponse[m.UpdateResult]:
|
434
|
+
"""
|
435
|
+
Update a file
|
436
|
+
|
437
|
+
Update a file.
|
438
|
+
|
439
|
+
OperationId: share_post_v1_update
|
440
|
+
|
441
|
+
Args:
|
442
|
+
id (str, optional): An identifier for the file to update.
|
443
|
+
folder (str, optional): Set the parent (folder). Leave blank for the
|
444
|
+
root folder. Path must resolve to `parent_id` if also set.
|
445
|
+
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.
|
446
|
+
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.
|
447
|
+
metadata (Metadata, optional): Set the object's Metadata.
|
448
|
+
add_tags (Tags, optional): A list of Tags to add. It is not an error to provide a tag which already exists.
|
449
|
+
remove_tags (Tags, optional): A list of Tags to remove. It is not an error to provide a tag which is not present.
|
450
|
+
tags (Tags, optional): Set the object's Tags.
|
451
|
+
parent_id (str, optional): Set the parent (folder) of the object.
|
452
|
+
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.
|
453
|
+
bucket_id (str, optional): The bucket to use, if not the default.
|
454
|
+
|
455
|
+
Returns:
|
456
|
+
A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
|
457
|
+
|
458
|
+
Examples:
|
459
|
+
response = await share.update(
|
460
|
+
id="pos_3djfmzg2db4c6donarecbyv5begtj2bm",
|
461
|
+
remove_metadata={
|
462
|
+
"created_by": "jim",
|
463
|
+
"priority": "medium",
|
464
|
+
},
|
465
|
+
remove_tags=["irs_2023", "personal"],
|
466
|
+
)
|
467
|
+
"""
|
468
|
+
|
469
|
+
input = m.UpdateRequest(
|
470
|
+
id=id,
|
471
|
+
folder=folder,
|
472
|
+
add_metadata=add_metadata,
|
473
|
+
remove_metadata=remove_metadata,
|
474
|
+
metadata=metadata,
|
475
|
+
add_tags=add_tags,
|
476
|
+
remove_tags=remove_tags,
|
477
|
+
tags=tags,
|
478
|
+
parent_id=parent_id,
|
479
|
+
updated_at=updated_at,
|
480
|
+
bucket_id=bucket_id,
|
481
|
+
)
|
482
|
+
return await self.request.post("v1/update", m.UpdateResult, data=input.model_dump(exclude_none=True))
|
483
|
+
|
484
|
+
async def share_link_create(
|
485
|
+
self, links: List[m.ShareLinkCreateItem], bucket_id: Optional[str] = None
|
486
|
+
) -> PangeaResponse[m.ShareLinkCreateResult]:
|
487
|
+
"""
|
488
|
+
Create share links
|
489
|
+
|
490
|
+
Create a share link.
|
491
|
+
|
492
|
+
OperationId: share_post_v1_share_link_create
|
493
|
+
|
494
|
+
Args:
|
495
|
+
links (List[ShareLinkCreateItem]):
|
496
|
+
bucket_id (str, optional): The bucket to use, if not the default.
|
497
|
+
|
498
|
+
Returns:
|
499
|
+
A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
|
500
|
+
|
501
|
+
Examples:
|
502
|
+
response = await share.share_link_create(
|
503
|
+
links=[
|
504
|
+
{
|
505
|
+
targets: ["pos_3djfmzg2db4c6donarecbyv5begtj2bm"],
|
506
|
+
link_type: LinkType.DOWNLOAD,
|
507
|
+
authenticators: [
|
508
|
+
{
|
509
|
+
"auth_type": AuthenticatorType.PASSWORD,
|
510
|
+
"auth_context": "my_fav_Pa55word",
|
511
|
+
}
|
512
|
+
],
|
513
|
+
}
|
514
|
+
],
|
515
|
+
)
|
516
|
+
"""
|
517
|
+
|
518
|
+
input = m.ShareLinkCreateRequest(links=links, bucket_id=bucket_id)
|
519
|
+
return await self.request.post(
|
520
|
+
"v1/share/link/create", m.ShareLinkCreateResult, data=input.model_dump(exclude_none=True)
|
521
|
+
)
|
522
|
+
|
523
|
+
async def share_link_get(self, id: str) -> PangeaResponse[m.ShareLinkGetResult]:
|
524
|
+
"""
|
525
|
+
Get share link
|
526
|
+
|
527
|
+
Get a share link.
|
528
|
+
|
529
|
+
OperationId: share_post_v1_share_link_get
|
530
|
+
|
531
|
+
Args:
|
532
|
+
id (str, optional): The ID of a share link.
|
533
|
+
|
534
|
+
Returns:
|
535
|
+
A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
|
536
|
+
|
537
|
+
Examples:
|
538
|
+
response = await share.share_link_get(
|
539
|
+
id="psl_3djfmzg2db4c6donarecbyv5begtj2bm"
|
540
|
+
)
|
541
|
+
"""
|
542
|
+
|
543
|
+
input = m.ShareLinkGetRequest(id=id)
|
544
|
+
return await self.request.post(
|
545
|
+
"v1/share/link/get", m.ShareLinkGetResult, data=input.model_dump(exclude_none=True)
|
546
|
+
)
|
547
|
+
|
548
|
+
async def share_link_list(
|
549
|
+
self,
|
550
|
+
filter: Optional[Union[Dict[str, str], m.FilterShareLinkList]] = None,
|
551
|
+
last: Optional[str] = None,
|
552
|
+
order: Optional[m.ItemOrder] = None,
|
553
|
+
order_by: Optional[m.ShareLinkOrderBy] = None,
|
554
|
+
size: Optional[int] = None,
|
555
|
+
bucket_id: Optional[str] = None,
|
556
|
+
) -> PangeaResponse[m.ShareLinkListResult]:
|
557
|
+
"""
|
558
|
+
List share links
|
559
|
+
|
560
|
+
Look up share links by filter options.
|
561
|
+
|
562
|
+
OperationId: share_post_v1_share_link_list
|
563
|
+
|
564
|
+
Args:
|
565
|
+
filter (Union[Dict[str, str], ShareLinkListFilter], optional):
|
566
|
+
last (str, optional): Reflected value from a previous response to obtain the next page of results.
|
567
|
+
order (ItemOrder, optional): Order results asc(ending) or desc(ending).
|
568
|
+
order_by (ItemOrderBy, optional): Which field to order results by.
|
569
|
+
size (int, optional): Maximum results to include in the response.
|
570
|
+
bucket_id (str, optional): The bucket to use, if not the default.
|
571
|
+
|
572
|
+
Returns:
|
573
|
+
A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
|
574
|
+
|
575
|
+
Examples:
|
576
|
+
response = await share.share_link_list()
|
577
|
+
"""
|
578
|
+
|
579
|
+
input = m.ShareLinkListRequest(
|
580
|
+
filter=filter, last=last, order=order, order_by=order_by, size=size, bucket_id=bucket_id
|
581
|
+
)
|
582
|
+
return await self.request.post(
|
583
|
+
"v1/share/link/list", m.ShareLinkListResult, data=input.model_dump(exclude_none=True)
|
584
|
+
)
|
585
|
+
|
586
|
+
async def share_link_delete(
|
587
|
+
self, ids: List[str], bucket_id: Optional[str] = None
|
588
|
+
) -> PangeaResponse[m.ShareLinkDeleteResult]:
|
589
|
+
"""
|
590
|
+
Delete share links
|
591
|
+
|
592
|
+
Delete share links.
|
593
|
+
|
594
|
+
OperationId: share_post_v1_share_link_delete
|
595
|
+
|
596
|
+
Args:
|
597
|
+
ids (List[str]): list of the share link's id to delete
|
598
|
+
bucket_id (str, optional): The bucket to use, if not the default.
|
599
|
+
|
600
|
+
Returns:
|
601
|
+
A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
|
602
|
+
|
603
|
+
Examples:
|
604
|
+
response = await share.share_link_delete(
|
605
|
+
ids=["psl_3djfmzg2db4c6donarecbyv5begtj2bm"]
|
606
|
+
)
|
607
|
+
"""
|
608
|
+
|
609
|
+
input = m.ShareLinkDeleteRequest(ids=ids, bucket_id=bucket_id)
|
610
|
+
return await self.request.post(
|
611
|
+
"v1/share/link/delete", m.ShareLinkDeleteResult, data=input.model_dump(exclude_none=True)
|
612
|
+
)
|
613
|
+
|
614
|
+
async def share_link_send(
|
615
|
+
self, links: List[m.ShareLinkSendItem], sender_email: str, sender_name: Optional[str] = None
|
616
|
+
) -> PangeaResponse[m.ShareLinkSendResult]:
|
617
|
+
"""
|
618
|
+
Send share links
|
619
|
+
|
620
|
+
Send a secure share-link notification to a set of email addresses. The
|
621
|
+
notification email will contain an Open button that the recipient can
|
622
|
+
use to follow the secured share-link to authenticate and then access the
|
623
|
+
shared content.
|
624
|
+
|
625
|
+
OperationId: share_post_v1_share_link_send
|
626
|
+
|
627
|
+
Args:
|
628
|
+
sender_email: An email address.
|
629
|
+
|
630
|
+
Returns:
|
631
|
+
A PangeaResponse. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/share).
|
632
|
+
|
633
|
+
Examples:
|
634
|
+
response = await share.share_link_send(
|
635
|
+
links=[ShareLinkSendItem(id=link.id, email="foo@example.org")],
|
636
|
+
sender_email="sender@example.org",
|
637
|
+
)
|
638
|
+
"""
|
639
|
+
|
640
|
+
input = m.ShareLinkSendRequest(links=links, sender_email=sender_email, sender_name=sender_name)
|
641
|
+
return await self.request.post(
|
642
|
+
"v1/share/link/send", m.ShareLinkSendResult, data=input.model_dump(exclude_none=True)
|
643
|
+
)
|
pangea/deep_verify.py
CHANGED
@@ -263,8 +263,14 @@ def main():
|
|
263
263
|
audit = init_audit(args.token, args.domain)
|
264
264
|
errors = deep_verify(audit, args.file)
|
265
265
|
|
266
|
-
print("\n\
|
266
|
+
print("\n\nWarnings:")
|
267
|
+
val = errors["not_persisted"]
|
268
|
+
print(f"\tnot_persisted: {val}")
|
269
|
+
|
270
|
+
print("\nTotal errors:")
|
267
271
|
for key, val in errors.items():
|
272
|
+
if key == "not_persisted":
|
273
|
+
continue
|
268
274
|
print(f"\t{key.title()}: {val}")
|
269
275
|
print()
|
270
276
|
|
pangea/dump_audit.py
CHANGED
@@ -63,11 +63,12 @@ def dump_before(audit: Audit, output: io.TextIOWrapper, start: datetime) -> int:
|
|
63
63
|
cnt = 0
|
64
64
|
if search_res.result and search_res.result.count > 0:
|
65
65
|
leaf_index = search_res.result.events[0].leaf_index
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
66
|
+
if leaf_index is not None:
|
67
|
+
for row in reversed(search_res.result.events):
|
68
|
+
if row.leaf_index != leaf_index:
|
69
|
+
break
|
70
|
+
dump_event(output, row, search_res)
|
71
|
+
cnt += 1
|
71
72
|
print(f"Dumping before... {cnt} events")
|
72
73
|
return cnt
|
73
74
|
|
@@ -89,7 +90,7 @@ def dump_after(audit: Audit, output: io.TextIOWrapper, start: datetime, last_eve
|
|
89
90
|
cnt = 0
|
90
91
|
if search_res.result and search_res.result.count > 0:
|
91
92
|
leaf_index = search_res.result.events[0].leaf_index
|
92
|
-
if leaf_index == last_leaf_index:
|
93
|
+
if leaf_index is not None and leaf_index == last_leaf_index:
|
93
94
|
start_idx: int = 1 if last_event_hash == search_res.result.events[0].hash else 0
|
94
95
|
for row in search_res.result.events[start_idx:]:
|
95
96
|
if row.leaf_index != leaf_index:
|
@@ -124,7 +125,7 @@ def dump_page(
|
|
124
125
|
msg = f"Dumping... {search_res.result.count} events"
|
125
126
|
|
126
127
|
if search_res.result.count <= 1:
|
127
|
-
return end, 0
|
128
|
+
return end, 0, True, "", 0
|
128
129
|
|
129
130
|
offset = 0
|
130
131
|
result_id = search_res.result.id
|