pangea-sdk 3.8.0__py3-none-any.whl → 3.8.0b2__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/services/authz.py DELETED
@@ -1,377 +0,0 @@
1
- # Copyright 2022 Pangea Cyber Corporation
2
- # Author: Pangea Cyber Corporation
3
-
4
- import enum
5
- from typing import Any, Dict, List, Optional, Union
6
-
7
- from pangea.response import APIRequestModel, APIResponseModel, PangeaResponse, PangeaResponseResult
8
- from pangea.services.base import ServiceBase
9
-
10
-
11
- class ItemOrder(str, enum.Enum):
12
- ASC = "asc"
13
- DESC = "desc"
14
-
15
- def __str__(self):
16
- return str(self.value)
17
-
18
- def __repr__(self):
19
- return str(self.value)
20
-
21
-
22
- class TupleOrderBy(str, enum.Enum):
23
- RESOURCE_TYPE = "resource_type"
24
- RESOURCE_ID = "resource_id"
25
- RELATION = "relation"
26
- SUBJECT_TYPE = "subject_type"
27
- SUBJECT_ID = "subject_id"
28
- SUBJECT_ACTION = "subject_action"
29
-
30
- def __str__(self):
31
- return str(self.value)
32
-
33
- def __repr__(self):
34
- return str(self.value)
35
-
36
-
37
- class Resource(PangeaResponseResult):
38
- type: str
39
- id: Optional[str] = None
40
-
41
-
42
- class Subject(PangeaResponseResult):
43
- type: str
44
- id: Optional[str] = None
45
- action: Optional[str] = None
46
-
47
-
48
- class Tuple(PangeaResponseResult):
49
- resource: Resource
50
- relation: str
51
- subject: Subject
52
-
53
-
54
- class TupleCreateRequest(APIRequestModel):
55
- tuples: List[Tuple]
56
-
57
-
58
- class TupleCreateResult(PangeaResponseResult):
59
- pass
60
-
61
-
62
- class TupleListFilter(APIRequestModel):
63
- resource_type: Optional[str] = None
64
- resource_type__contains: Optional[List[str]] = None
65
- resource_type__in: Optional[List[str]] = None
66
- resource_id: Optional[str] = None
67
- resource_id__contains: Optional[List[str]] = None
68
- resource_id__in: Optional[List[str]] = None
69
- relation: Optional[str] = None
70
- relation__contains: Optional[List[str]] = None
71
- relation__in: Optional[List[str]] = None
72
- subject_type: Optional[str] = None
73
- subject_type__contains: Optional[List[str]] = None
74
- subject_type__in: Optional[List[str]] = None
75
- subject_id: Optional[str] = None
76
- subject_id__contains: Optional[List[str]] = None
77
- subject_id__in: Optional[List[str]] = None
78
- subject_action: Optional[str] = None
79
- subject_action__contains: Optional[List[str]] = None
80
- subject_action__in: Optional[List[str]] = None
81
-
82
-
83
- class TupleListRequest(APIRequestModel):
84
- filter: Optional[Union[Dict, TupleListFilter]] = None
85
- size: Optional[int] = None
86
- last: Optional[str] = None
87
- order: Optional[ItemOrder] = None
88
- order_by: Optional[TupleOrderBy] = None
89
-
90
-
91
- class TupleListResult(PangeaResponseResult):
92
- tuples: List[Tuple]
93
- last: str
94
- count: int
95
-
96
-
97
- class TupleDeleteRequest(APIRequestModel):
98
- tuples: List[Tuple]
99
-
100
-
101
- class TupleDeleteResult(PangeaResponseResult):
102
- pass
103
-
104
-
105
- class CheckRequest(APIRequestModel):
106
- resource: Resource
107
- action: str
108
- subject: Subject
109
- debug: Optional[bool] = None
110
- attributes: Optional[Dict[str, Any]] = None
111
-
112
-
113
- class DebugPath(APIResponseModel):
114
- type: str
115
- id: str
116
- action: Optional[str]
117
-
118
-
119
- class Debug(APIResponseModel):
120
- path: List[DebugPath]
121
-
122
-
123
- class CheckResult(PangeaResponseResult):
124
- schema_id: str
125
- schema_version: int
126
- depth: int
127
- allowed: bool
128
- debug: Optional[Debug] = None
129
-
130
-
131
- class ListResourcesRequest(APIRequestModel):
132
- type: str
133
- action: str
134
- subject: Subject
135
-
136
-
137
- class ListResourcesResult(PangeaResponseResult):
138
- ids: List[str]
139
-
140
-
141
- class ListSubjectsRequest(APIRequestModel):
142
- resource: Resource
143
- action: str
144
-
145
-
146
- class ListSubjectsResult(PangeaResponseResult):
147
- subjects: List[Subject]
148
-
149
-
150
- class AuthZ(ServiceBase):
151
- """AuthZ service client. (Beta)
152
-
153
- Provides methods to interact with the Pangea AuthZ Service.
154
- Documentation for the AuthZ Service API can be found at
155
- <https://pangea.cloud/docs/api/authz>. Note that this service is in Beta and
156
- is subject to change.
157
-
158
- Examples:
159
- import os
160
- from pangea.config import PangeaConfig
161
- from pangea.services import AuthZ
162
-
163
- PANGEA_TOKEN = os.getenv("PANGEA_AUTHZ_TOKEN")
164
-
165
- authz_config = PangeaConfig(domain="aws.us.pangea.cloud")
166
-
167
- # Setup Pangea AuthZ service client
168
- authz = AuthZ(token=PANGEA_TOKEN, config=authz_config)
169
- """
170
-
171
- service_name = "authz"
172
-
173
- def __init__(self, token: str, config=None, logger_name="pangea", config_id: Optional[str] = None):
174
- super().__init__(token, config, logger_name, config_id=config_id)
175
-
176
- def tuple_create(self, tuples: List[Tuple]) -> PangeaResponse[TupleCreateResult]:
177
- """Create tuples. (Beta)
178
-
179
- Create tuples in the AuthZ Service. The request will fail if there is no schema
180
- or the tuples do not validate against the schema.
181
- How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
182
-
183
- Args:
184
- tuples (List[Tuple]): List of tuples to be created.
185
-
186
- Raises:
187
- PangeaAPIException: If an API Error happens.
188
-
189
- Returns:
190
- Pangea Response with empty result.
191
- Available response fields can be found in our
192
- [API Documentation](https://pangea.cloud/docs/api/authz#/v1/tuple/create).
193
-
194
- Examples:
195
- response = authz.tuple_create(
196
- tuples=[
197
- Tuple(
198
- resource=Resource(type="file", id="file_1"),
199
- relation="owner",
200
- subject=Subject(type="user", id="user_1"),
201
- )
202
- ]
203
- )
204
- """
205
-
206
- input_data = TupleCreateRequest(tuples=tuples)
207
- return self.request.post("v1/tuple/create", TupleCreateResult, data=input_data.dict(exclude_none=True))
208
-
209
- def tuple_list(
210
- self,
211
- filter: TupleListFilter,
212
- size: Optional[int] = None,
213
- last: Optional[str] = None,
214
- order: Optional[ItemOrder] = None,
215
- order_by: Optional[TupleOrderBy] = None,
216
- ) -> PangeaResponse[TupleListResult]:
217
- """List tuples. (Beta)
218
-
219
- Return a paginated list of filtered tuples. The filter is given in terms
220
- of a tuple. Fill out the fields that you want to filter. If the filter
221
- is empty it will return all the tuples.
222
- How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
223
-
224
- Args:
225
- filter (TupleListFilter): The filter for listing tuples.
226
- size (Optional[int]): The size of the result set. Default is None.
227
- last (Optional[str]): The last token from a previous response. Default is None.
228
- order (Optional[ItemOrder]): Order results asc(ending) or desc(ending).
229
- order_by (Optional[TupleOrderBy]): Which field to order results by.
230
-
231
- Raises:
232
- PangeaAPIException: If an API Error happens.
233
-
234
- Returns:
235
- Pangea Response with a list of tuples and the last token.
236
- Available response fields can be found in our
237
- [API Documentation](https://pangea.cloud/docs/api/authz#/v1/tuple/list).
238
-
239
- Examples:
240
- authz.tuple_list(TupleListFilter(subject_type="user", subject_id="user_1"))
241
- """
242
- input_data = TupleListRequest(
243
- filter=filter.dict(exclude_none=True), size=size, last=last, order=order, order_by=order_by
244
- )
245
- return self.request.post("v1/tuple/list", TupleListResult, data=input_data.dict(exclude_none=True))
246
-
247
- def tuple_delete(self, tuples: List[Tuple]) -> PangeaResponse[TupleDeleteResult]:
248
- """Delete tuples. (Beta)
249
-
250
- Delete tuples in the AuthZ Service.
251
- How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
252
-
253
- Args:
254
- tuples (List[Tuple]): List of tuples to be deleted.
255
-
256
- Raises:
257
- PangeaAPIException: If an API Error happens.
258
-
259
- Returns:
260
- Pangea Response with empty result.
261
- Available response fields can be found in our
262
- [API Documentation](https://pangea.cloud/docs/api/authz#/v1/tuple/delete).
263
-
264
- Examples:
265
- response = authz.tuple_delete(
266
- tuples=[
267
- Tuple(
268
- resource=Resource(type="file", id="file_1"),
269
- relation="owner",
270
- subject=Subject(type="user", id="user_1"),
271
- )
272
- ]
273
- )
274
- """
275
-
276
- input_data = TupleDeleteRequest(tuples=tuples)
277
- return self.request.post("v1/tuple/delete", TupleDeleteResult, data=input_data.dict(exclude_none=True))
278
-
279
- def check(
280
- self,
281
- resource: Resource,
282
- action: str,
283
- subject: Subject,
284
- debug: Optional[bool] = None,
285
- attributes: Optional[Dict[str, Union[int, str]]] = None,
286
- ) -> PangeaResponse[CheckResult]:
287
- """Perform a check request. (Beta)
288
-
289
- Check if a subject has permission to perform an action on the resource.
290
- How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
291
-
292
- Args:
293
- resource (Resource): The resource to check.
294
- action (str): The action to check.
295
- subject (Subject): The subject to check.
296
- debug (Optional[bool]): Setting this value to True will provide a detailed analysis of the check.
297
- attributes (Optional[Dict[str, Union[int, str]]]): Additional attributes for the check.
298
-
299
- Raises:
300
- PangeaAPIException: If an API Error happens.
301
-
302
- Returns:
303
- Pangea Response with the result of the check.
304
- Available response fields can be found in our
305
- [API Documentation](https://pangea.cloud/docs/api/authz#/v1/check).
306
-
307
- Examples:
308
- response = authz.check(
309
- resource=Resource(type="file", id="file_1"),
310
- action="update",
311
- subject=Subject(type="user", id="user_1"),
312
- debug=True,
313
- )
314
- """
315
-
316
- input_data = CheckRequest(resource=resource, action=action, subject=subject, debug=debug, attributes=attributes)
317
- return self.request.post("v1/check", CheckResult, data=input_data.dict(exclude_none=True))
318
-
319
- def list_resources(self, type: str, action: str, subject: Subject) -> PangeaResponse[ListResourcesResult]:
320
- """List resources. (Beta)
321
-
322
- Given a type, action, and subject, list all the resources in the
323
- type that the subject has access to the action with.
324
- How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
325
-
326
- Args:
327
- type (str): The type to filter resources.
328
- action (str): The action to filter resources.
329
- subject (Subject): The subject to filter resources.
330
-
331
- Raises:
332
- PangeaAPIException: If an API Error happens.
333
-
334
- Returns:
335
- Pangea Response with a list of resource IDs.
336
- Available response fields can be found in our
337
- [API Documentation](https://pangea.cloud/docs/api/authz#/v1/list-resources).
338
-
339
- Examples:
340
- authz.list_resources(
341
- type="file",
342
- action="update",
343
- subject=Subject(type="user", id="user_1"),
344
- )
345
- """
346
-
347
- input_data = ListResourcesRequest(type=type, action=action, subject=subject)
348
- return self.request.post("v1/list-resources", ListResourcesResult, data=input_data.dict(exclude_none=True))
349
-
350
- def list_subjects(self, resource: Resource, action: str) -> PangeaResponse[ListSubjectsResult]:
351
- """List subjects. (Beta)
352
-
353
- Given a resource and an action, return the list of subjects who have
354
- access to the action for the given resource.
355
- How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
356
-
357
- Args:
358
- resource (Resource): The resource to filter subjects.
359
- action (str): The action to filter subjects.
360
-
361
- Raises:
362
- PangeaAPIException: If an API Error happens.
363
-
364
- Returns:
365
- Pangea Response with a list of subjects.
366
- Available response fields can be found in our
367
- [API Documentation](https://pangea.cloud/docs/api/authz#/v1/list-subjects).
368
-
369
- Examples:
370
- response = authz.list_subjects(
371
- resource=Resource(type="file", id="file_1"),
372
- action="update",
373
- )
374
- """
375
-
376
- input_data = ListSubjectsRequest(resource=resource, action=action)
377
- return self.request.post("v1/list-subjects", ListSubjectsResult, data=input_data.dict(exclude_none=True))
@@ -1,46 +0,0 @@
1
- pangea/__init__.py,sha256=Nq9RV-L96OLvLWJH-nk0U5j6zZHQQSfqGSn6nkvmzWM,200
2
- pangea/asyncio/request.py,sha256=uvx9d1hmYhGKvbI4ecj6kIagGhPn_4bKmHN062Zz35c,17089
3
- pangea/asyncio/services/__init__.py,sha256=hmySN2LoXYpHzSKLVSdVjMbpGXi5Z5iNx-fJ2Fc8W6I,320
4
- pangea/asyncio/services/audit.py,sha256=laWnkT9WHBmwiaoGhNxJcdDBuqZ6Ce3wz8ujdavZgfM,24866
5
- pangea/asyncio/services/authn.py,sha256=ubxpxCwv6ON9JWYVPCX3FYp-YzHqIuLvE9IsYPQS3-8,44760
6
- pangea/asyncio/services/authz.py,sha256=z4HrcxjPGZ1X5akXo-nUQ3MWge6reirwdi7d8HHAMyQ,9745
7
- pangea/asyncio/services/base.py,sha256=4FtKtlq74NmE9myrgIt9HMA6JDnP4mPZ6krafWr286o,2663
8
- pangea/asyncio/services/embargo.py,sha256=8WguyWZUaGVwGpNzic5h8QzLueirA9WpBBik4mpCTeA,3056
9
- pangea/asyncio/services/file_scan.py,sha256=WIKYjUNCIx6jF0vQ-KnsKYBcZh53Q5rmccTlsTPP_rY,6301
10
- pangea/asyncio/services/intel.py,sha256=-0xAfnlAgNH774XRHX1-zIv2nr1Xra7X8tLhuCArQhE,37647
11
- pangea/asyncio/services/redact.py,sha256=3yuLD-TBiaqDa3OA0PRjvG3kXAifLyrENw8j2Na64-c,5665
12
- pangea/asyncio/services/vault.py,sha256=m851lZLN9DHp3_r_-1onmecZoFxNHCRCi4N_j288HUY,47836
13
- pangea/audit_logger.py,sha256=gRkCfUUT5LDNaycwxkhZUySgY47jDfn1ZeKOul4XCQI,3842
14
- pangea/config.py,sha256=mQUu8GX_6weIuv3vjNdG5plppXskXYASmxMWtFQh-hc,1662
15
- pangea/deep_verify.py,sha256=mocaGbC6XLbMTVWxTpMv4oJtXGPWpT-SbFqT3obpiZs,8443
16
- pangea/deprecated.py,sha256=IjFYEVvY1E0ld0SMkEYC1o62MAleX3nnT1If2dFVbHo,608
17
- pangea/dump_audit.py,sha256=8KrTOP64D28RFv1mvOOxe0fxlRZi8PtwnEZfvabglNA,7019
18
- pangea/exceptions.py,sha256=OBtzUECpNa6vNp8ySkHC-tm4QjFRCOAHBkMHqzAlOu8,5656
19
- pangea/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
- pangea/request.py,sha256=ZcK49SgCPvGwPGrY63UmiTo-xELu2ryPvALmPxPXkGI,24298
21
- pangea/response.py,sha256=egyLcl0FxEDmTrbRjHuB_DvxipfTXG0ExUS1yLBss-M,6828
22
- pangea/services/__init__.py,sha256=iAIa1kk_C0EHBsSn2XP3QT-bOZNGwMBPUcO2JoI-9cE,278
23
- pangea/services/audit/audit.py,sha256=TLGs4ALMEFpQSxC49SMVwRGRxUCslstHMBmSiDpC6mY,38006
24
- pangea/services/audit/exceptions.py,sha256=bhVuYe4ammacOVxwg98CChxvwZf5FKgR2DcgqILOcwc,471
25
- pangea/services/audit/models.py,sha256=IViO_WsDz_N8YjPD8pcAcPHWpf2aatd0-VJVl_o_8G4,13953
26
- pangea/services/audit/signing.py,sha256=pOjw60BIYDcg3_5YKDCMWZUaapsEZpCHaFhyFu7TEgc,5567
27
- pangea/services/audit/util.py,sha256=C6KAdu6qhValmNrIMUPLdAW0SCiLwcDd5euXti_63Og,7596
28
- pangea/services/authn/authn.py,sha256=C_u34ASbi3Ul3C6D6f4fqdajcGNPX2CfxKmcLjE016w,43750
29
- pangea/services/authn/models.py,sha256=FZ5kRBZQ-Pr2YD3jFZ4HvJI22ObbXaBb6HStjcN7-D0,18104
30
- pangea/services/authz.py,sha256=7bhTJFI4A2mnogLgBPETRabywPolgk1vI0qZJuIxoTw,12424
31
- pangea/services/base.py,sha256=lwhHoe5Juy28Ir3Mfj2lHdM58gxZRaxa2SRFi4_DBRw,3453
32
- pangea/services/embargo.py,sha256=WFqBreGU1FPgOSabIIkWCrXBvquYN958Un7h9P1aHSI,3885
33
- pangea/services/file_scan.py,sha256=tWR4D672Lxk_btSA1NcuUFkajbEhiCGMoTMm2bGtCj4,6942
34
- pangea/services/intel.py,sha256=t8SksNsh-r1JjLN3if4yNmx711hNjQ_1YzCX-96_xv0,51645
35
- pangea/services/redact.py,sha256=y_jZxUY4wmEQL2AbCOZLiV14GIweSJ1TUBnyHust80M,8298
36
- pangea/services/vault/models/asymmetric.py,sha256=ac2Exc66elXxO-HxBqtvLPQWNI7y_00kb6SVqBPKecA,1450
37
- pangea/services/vault/models/common.py,sha256=Ks6reIlWx3PU1lD0UlorcAlZV8U9T3j711iOsb6qp3o,11120
38
- pangea/services/vault/models/secret.py,sha256=cLgEj-_BeGkB4-pmSeTkWVyasFbaJwcEltIEcOyf1U8,481
39
- pangea/services/vault/models/symmetric.py,sha256=5N2n6FDStB1CLPfpd4p-6Ig__Nt-EyurhjCWfEyws2k,1330
40
- pangea/services/vault/vault.py,sha256=s_qGLDlk-LOSsODpnvo_VPtH_4HGgwCOprSCKCNaCfY,47619
41
- pangea/tools.py,sha256=sa2pSz-L8tB6GcZg6lghsmm8w0qMQAIkzqcv7dilU6Q,6429
42
- pangea/utils.py,sha256=nTrw0lcw4s0R2m_LFIoypFU4ilsBfjV1eCf_bTjJ-Lo,3489
43
- pangea/verify_audit.py,sha256=QthhKzFlIQwoEyjBLojcX4uHGaN3EEGomx-IC5e3L0E,10756
44
- pangea_sdk-3.8.0.dist-info/METADATA,sha256=Lc1OJgV2dQvDx9HmppMIjctCA4b2aKmFzFQ2r-pPPKQ,7464
45
- pangea_sdk-3.8.0.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
46
- pangea_sdk-3.8.0.dist-info/RECORD,,