pangea-sdk 3.8.0b4__py3-none-any.whl → 3.9.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 +14 -19
- pangea/asyncio/services/__init__.py +0 -2
- pangea/asyncio/services/audit.py +160 -14
- pangea/asyncio/services/authn.py +118 -79
- pangea/asyncio/services/authz.py +35 -50
- pangea/asyncio/services/intel.py +4 -4
- pangea/asyncio/services/redact.py +56 -2
- pangea/asyncio/services/vault.py +115 -4
- pangea/request.py +24 -21
- pangea/response.py +27 -28
- pangea/services/__init__.py +0 -2
- pangea/services/audit/audit.py +161 -16
- pangea/services/audit/models.py +53 -5
- pangea/services/authn/authn.py +77 -36
- pangea/services/authn/models.py +79 -0
- pangea/services/authz.py +47 -54
- pangea/services/base.py +23 -6
- pangea/services/file_scan.py +1 -0
- pangea/services/intel.py +2 -2
- pangea/services/redact.py +122 -2
- pangea/services/vault/models/common.py +115 -0
- pangea/services/vault/vault.py +117 -6
- pangea/utils.py +19 -91
- {pangea_sdk-3.8.0b4.dist-info → pangea_sdk-3.9.0.dist-info}/METADATA +6 -15
- pangea_sdk-3.9.0.dist-info/RECORD +46 -0
- 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_sdk-3.8.0b4.dist-info → pangea_sdk-3.9.0.dist-info}/WHEEL +0 -0
pangea/asyncio/services/authn.py
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
# Copyright 2022 Pangea Cyber Corporation
|
2
2
|
# Author: Pangea Cyber Corporation
|
3
|
+
from __future__ import annotations
|
3
4
|
|
4
5
|
from typing import Dict, List, Optional, Union
|
5
6
|
|
6
7
|
import pangea.services.authn.models as m
|
7
8
|
from pangea.asyncio.services.base import ServiceBaseAsync
|
9
|
+
from pangea.config import PangeaConfig
|
8
10
|
from pangea.response import PangeaResponse
|
9
11
|
|
10
12
|
SERVICE_NAME = "authn"
|
@@ -23,24 +25,38 @@ class AuthNAsync(ServiceBaseAsync):
|
|
23
25
|
import os
|
24
26
|
|
25
27
|
# Pangea SDK
|
28
|
+
from pangea.asyncio.services import AuthNAsync
|
26
29
|
from pangea.config import PangeaConfig
|
27
|
-
from pangea.services import AuthN
|
28
30
|
|
29
31
|
PANGEA_TOKEN = os.getenv("PANGEA_AUTHN_TOKEN")
|
30
32
|
authn_config = PangeaConfig(domain="pangea.cloud")
|
31
33
|
|
32
34
|
# Setup Pangea AuthN service
|
33
|
-
authn =
|
35
|
+
authn = AuthNAsync(token=PANGEA_TOKEN, config=authn_config)
|
34
36
|
"""
|
35
37
|
|
36
38
|
service_name = SERVICE_NAME
|
37
39
|
|
38
40
|
def __init__(
|
39
41
|
self,
|
40
|
-
token,
|
41
|
-
config=None,
|
42
|
-
logger_name="pangea",
|
43
|
-
):
|
42
|
+
token: str,
|
43
|
+
config: PangeaConfig | None = None,
|
44
|
+
logger_name: str = "pangea",
|
45
|
+
) -> None:
|
46
|
+
"""
|
47
|
+
AuthN client
|
48
|
+
|
49
|
+
Initializes a new AuthN client.
|
50
|
+
|
51
|
+
Args:
|
52
|
+
token: Pangea API token.
|
53
|
+
config: Configuration.
|
54
|
+
logger_name: Logger name.
|
55
|
+
|
56
|
+
Examples:
|
57
|
+
config = PangeaConfig(domain="pangea_domain")
|
58
|
+
authn = AuthNAsync(token="pangea_token", config=config)
|
59
|
+
"""
|
44
60
|
super().__init__(token, config, logger_name=logger_name)
|
45
61
|
self.user = AuthNAsync.UserAsync(token, config, logger_name=logger_name)
|
46
62
|
self.flow = AuthNAsync.FlowAsync(token, config, logger_name=logger_name)
|
@@ -53,10 +69,10 @@ class AuthNAsync(ServiceBaseAsync):
|
|
53
69
|
|
54
70
|
def __init__(
|
55
71
|
self,
|
56
|
-
token,
|
57
|
-
config=None,
|
58
|
-
logger_name="pangea",
|
59
|
-
):
|
72
|
+
token: str,
|
73
|
+
config: PangeaConfig | None = None,
|
74
|
+
logger_name: str = "pangea",
|
75
|
+
) -> None:
|
60
76
|
super().__init__(token, config, logger_name=logger_name)
|
61
77
|
|
62
78
|
async def invalidate(self, session_id: str) -> PangeaResponse[m.SessionInvalidateResult]:
|
@@ -148,10 +164,10 @@ class AuthNAsync(ServiceBaseAsync):
|
|
148
164
|
|
149
165
|
def __init__(
|
150
166
|
self,
|
151
|
-
token,
|
152
|
-
config=None,
|
153
|
-
logger_name="pangea",
|
154
|
-
):
|
167
|
+
token: str,
|
168
|
+
config: PangeaConfig | None = None,
|
169
|
+
logger_name: str = "pangea",
|
170
|
+
) -> None:
|
155
171
|
super().__init__(token, config, logger_name=logger_name)
|
156
172
|
self.session = AuthNAsync.ClientAsync.SessionAsync(token, config, logger_name=logger_name)
|
157
173
|
self.password = AuthNAsync.ClientAsync.PasswordAsync(token, config, logger_name=logger_name)
|
@@ -208,10 +224,10 @@ class AuthNAsync(ServiceBaseAsync):
|
|
208
224
|
|
209
225
|
def __init__(
|
210
226
|
self,
|
211
|
-
token,
|
212
|
-
config=None,
|
213
|
-
logger_name="pangea",
|
214
|
-
):
|
227
|
+
token: str,
|
228
|
+
config: PangeaConfig | None = None,
|
229
|
+
logger_name: str = "pangea",
|
230
|
+
) -> None:
|
215
231
|
super().__init__(token, config, logger_name=logger_name)
|
216
232
|
|
217
233
|
async def invalidate(self, token: str, session_id: str) -> PangeaResponse[m.ClientSessionInvalidateResult]:
|
@@ -343,10 +359,10 @@ class AuthNAsync(ServiceBaseAsync):
|
|
343
359
|
|
344
360
|
def __init__(
|
345
361
|
self,
|
346
|
-
token,
|
347
|
-
config=None,
|
348
|
-
logger_name="pangea",
|
349
|
-
):
|
362
|
+
token: str,
|
363
|
+
config: PangeaConfig | None = None,
|
364
|
+
logger_name: str = "pangea",
|
365
|
+
) -> None:
|
350
366
|
super().__init__(token, config, logger_name=logger_name)
|
351
367
|
|
352
368
|
async def change(
|
@@ -384,10 +400,10 @@ class AuthNAsync(ServiceBaseAsync):
|
|
384
400
|
|
385
401
|
def __init__(
|
386
402
|
self,
|
387
|
-
token,
|
388
|
-
config=None,
|
389
|
-
logger_name="pangea",
|
390
|
-
):
|
403
|
+
token: str,
|
404
|
+
config: PangeaConfig | None = None,
|
405
|
+
logger_name: str = "pangea",
|
406
|
+
) -> None:
|
391
407
|
super().__init__(token, config, logger_name=logger_name)
|
392
408
|
|
393
409
|
async def check(self, token: str) -> PangeaResponse[m.ClientTokenCheckResult]:
|
@@ -421,10 +437,10 @@ class AuthNAsync(ServiceBaseAsync):
|
|
421
437
|
|
422
438
|
def __init__(
|
423
439
|
self,
|
424
|
-
token,
|
425
|
-
config=None,
|
426
|
-
logger_name="pangea",
|
427
|
-
):
|
440
|
+
token: str,
|
441
|
+
config: PangeaConfig | None = None,
|
442
|
+
logger_name: str = "pangea",
|
443
|
+
) -> None:
|
428
444
|
super().__init__(token, config, logger_name=logger_name)
|
429
445
|
self.profile = AuthNAsync.UserAsync.ProfileAsync(token, config, logger_name=logger_name)
|
430
446
|
self.authenticators = AuthNAsync.UserAsync.AuthenticatorsAsync(token, config, logger_name=logger_name)
|
@@ -434,6 +450,8 @@ class AuthNAsync(ServiceBaseAsync):
|
|
434
450
|
self,
|
435
451
|
email: str,
|
436
452
|
profile: m.Profile,
|
453
|
+
*,
|
454
|
+
username: str | None = None,
|
437
455
|
) -> PangeaResponse[m.UserCreateResult]:
|
438
456
|
"""
|
439
457
|
Create User
|
@@ -443,8 +461,9 @@ class AuthNAsync(ServiceBaseAsync):
|
|
443
461
|
OperationId: authn_post_v2_user_create
|
444
462
|
|
445
463
|
Args:
|
446
|
-
email
|
447
|
-
profile
|
464
|
+
email: An email address.
|
465
|
+
profile: A user profile as a collection of string properties.
|
466
|
+
username: A username.
|
448
467
|
|
449
468
|
Returns:
|
450
469
|
A PangeaResponse with a user and its information in the response.result field.
|
@@ -463,11 +482,12 @@ class AuthNAsync(ServiceBaseAsync):
|
|
463
482
|
input = m.UserCreateRequest(
|
464
483
|
email=email,
|
465
484
|
profile=profile,
|
485
|
+
username=username,
|
466
486
|
)
|
467
487
|
return await self.request.post("v2/user/create", m.UserCreateResult, data=input.dict(exclude_none=True))
|
468
488
|
|
469
489
|
async def delete(
|
470
|
-
self, email:
|
490
|
+
self, email: str | None = None, id: str | None = None, *, username: str | None = None
|
471
491
|
) -> PangeaResponse[m.UserDeleteResult]:
|
472
492
|
"""
|
473
493
|
Delete User
|
@@ -477,8 +497,9 @@ class AuthNAsync(ServiceBaseAsync):
|
|
477
497
|
OperationId: authn_post_v2_user_delete
|
478
498
|
|
479
499
|
Args:
|
480
|
-
email
|
481
|
-
id
|
500
|
+
email: An email address.
|
501
|
+
id: The id of a user or a service.
|
502
|
+
username: A username.
|
482
503
|
|
483
504
|
Returns:
|
484
505
|
A PangeaResponse with an empty object in the response.result field.
|
@@ -486,7 +507,7 @@ class AuthNAsync(ServiceBaseAsync):
|
|
486
507
|
Examples:
|
487
508
|
authn.user.delete(email="example@example.com")
|
488
509
|
"""
|
489
|
-
input = m.UserDeleteRequest(email=email, id=id)
|
510
|
+
input = m.UserDeleteRequest(email=email, id=id, username=username)
|
490
511
|
return await self.request.post("v2/user/delete", m.UserDeleteResult, data=input.dict(exclude_none=True))
|
491
512
|
|
492
513
|
async def invite(
|
@@ -533,8 +554,10 @@ class AuthNAsync(ServiceBaseAsync):
|
|
533
554
|
async def update(
|
534
555
|
self,
|
535
556
|
disabled: bool,
|
536
|
-
id:
|
537
|
-
email:
|
557
|
+
id: str | None = None,
|
558
|
+
email: str | None = None,
|
559
|
+
*,
|
560
|
+
username: str | None = None,
|
538
561
|
) -> PangeaResponse[m.UserUpdateResult]:
|
539
562
|
"""
|
540
563
|
Update user's settings
|
@@ -544,10 +567,11 @@ class AuthNAsync(ServiceBaseAsync):
|
|
544
567
|
OperationId: authn_post_v2_user_update
|
545
568
|
|
546
569
|
Args:
|
547
|
-
disabled
|
570
|
+
disabled: New disabled value.
|
548
571
|
Disabling a user account will prevent them from logging in.
|
549
|
-
id
|
550
|
-
email
|
572
|
+
id: The identity of a user or a service.
|
573
|
+
email: An email address.
|
574
|
+
username: A username.
|
551
575
|
|
552
576
|
Returns:
|
553
577
|
A PangeaResponse with a user and its information in the response.result field.
|
@@ -564,6 +588,7 @@ class AuthNAsync(ServiceBaseAsync):
|
|
564
588
|
id=id,
|
565
589
|
email=email,
|
566
590
|
disabled=disabled,
|
591
|
+
username=username,
|
567
592
|
)
|
568
593
|
|
569
594
|
return await self.request.post("v2/user/update", m.UserUpdateResult, data=input.dict(exclude_none=True))
|
@@ -615,10 +640,10 @@ class AuthNAsync(ServiceBaseAsync):
|
|
615
640
|
|
616
641
|
def __init__(
|
617
642
|
self,
|
618
|
-
token,
|
619
|
-
config=None,
|
620
|
-
logger_name="pangea",
|
621
|
-
):
|
643
|
+
token: str,
|
644
|
+
config: PangeaConfig | None = None,
|
645
|
+
logger_name: str = "pangea",
|
646
|
+
) -> None:
|
622
647
|
super().__init__(token, config, logger_name=logger_name)
|
623
648
|
|
624
649
|
async def list(
|
@@ -687,14 +712,19 @@ class AuthNAsync(ServiceBaseAsync):
|
|
687
712
|
|
688
713
|
def __init__(
|
689
714
|
self,
|
690
|
-
token,
|
691
|
-
config=None,
|
692
|
-
logger_name="pangea",
|
693
|
-
):
|
715
|
+
token: str,
|
716
|
+
config: PangeaConfig | None = None,
|
717
|
+
logger_name: str = "pangea",
|
718
|
+
) -> None:
|
694
719
|
super().__init__(token, config, logger_name=logger_name)
|
695
720
|
|
696
721
|
async def delete(
|
697
|
-
self,
|
722
|
+
self,
|
723
|
+
authenticator_id: str,
|
724
|
+
id: str | None = None,
|
725
|
+
email: str | None = None,
|
726
|
+
*,
|
727
|
+
username: str | None = None,
|
698
728
|
) -> PangeaResponse[m.UserAuthenticatorsDeleteResult]:
|
699
729
|
"""
|
700
730
|
Delete user authenticator
|
@@ -704,9 +734,10 @@ class AuthNAsync(ServiceBaseAsync):
|
|
704
734
|
OperationId: authn_post_v2_user_authenticators_delete
|
705
735
|
|
706
736
|
Args:
|
707
|
-
authenticator_id
|
708
|
-
id
|
709
|
-
email
|
737
|
+
authenticator_id: An ID for an authenticator.
|
738
|
+
id: The identity of a user or a service.
|
739
|
+
email: An email address.
|
740
|
+
username: A username.
|
710
741
|
|
711
742
|
Returns:
|
712
743
|
A PangeaResponse with an empty object in the response.result field.
|
@@ -717,7 +748,9 @@ class AuthNAsync(ServiceBaseAsync):
|
|
717
748
|
id="pui_xpkhwpnz2cmegsws737xbsqnmnuwtbm5",
|
718
749
|
)
|
719
750
|
"""
|
720
|
-
input = m.UserAuthenticatorsDeleteRequest(
|
751
|
+
input = m.UserAuthenticatorsDeleteRequest(
|
752
|
+
authenticator_id=authenticator_id, email=email, id=id, username=username
|
753
|
+
)
|
721
754
|
return await self.request.post(
|
722
755
|
"v2/user/authenticators/delete",
|
723
756
|
m.UserAuthenticatorsDeleteResult,
|
@@ -725,7 +758,7 @@ class AuthNAsync(ServiceBaseAsync):
|
|
725
758
|
)
|
726
759
|
|
727
760
|
async def list(
|
728
|
-
self, email:
|
761
|
+
self, email: str | None = None, id: str | None = None, *, username: str | None = None
|
729
762
|
) -> PangeaResponse[m.UserAuthenticatorsListResult]:
|
730
763
|
"""
|
731
764
|
Get user authenticators
|
@@ -735,8 +768,9 @@ class AuthNAsync(ServiceBaseAsync):
|
|
735
768
|
OperationId: authn_post_v2_user_authenticators_list
|
736
769
|
|
737
770
|
Args:
|
738
|
-
email
|
739
|
-
id
|
771
|
+
email: An email address.
|
772
|
+
id: The identity of a user or a service.
|
773
|
+
username: A username.
|
740
774
|
|
741
775
|
Returns:
|
742
776
|
A PangeaResponse with a list of authenticators in the response.result field.
|
@@ -748,7 +782,7 @@ class AuthNAsync(ServiceBaseAsync):
|
|
748
782
|
id="pui_xpkhwpnz2cmegsws737xbsqnmnuwtbm5",
|
749
783
|
)
|
750
784
|
"""
|
751
|
-
input = m.UserAuthenticatorsListRequest(email=email, id=id)
|
785
|
+
input = m.UserAuthenticatorsListRequest(email=email, id=id, username=username)
|
752
786
|
return await self.request.post(
|
753
787
|
"v2/user/authenticators/list", m.UserAuthenticatorsListResult, data=input.dict(exclude_none=True)
|
754
788
|
)
|
@@ -758,14 +792,14 @@ class AuthNAsync(ServiceBaseAsync):
|
|
758
792
|
|
759
793
|
def __init__(
|
760
794
|
self,
|
761
|
-
token,
|
762
|
-
config=None,
|
763
|
-
logger_name="pangea",
|
764
|
-
):
|
795
|
+
token: str,
|
796
|
+
config: PangeaConfig | None = None,
|
797
|
+
logger_name: str = "pangea",
|
798
|
+
) -> None:
|
765
799
|
super().__init__(token, config, logger_name=logger_name)
|
766
800
|
|
767
801
|
async def get(
|
768
|
-
self, id:
|
802
|
+
self, id: str | None = None, email: str | None = None, *, username: str | None = None
|
769
803
|
) -> PangeaResponse[m.UserProfileGetResult]:
|
770
804
|
"""
|
771
805
|
Get user
|
@@ -775,8 +809,9 @@ class AuthNAsync(ServiceBaseAsync):
|
|
775
809
|
OperationId: authn_post_v2_user_profile_get
|
776
810
|
|
777
811
|
Args:
|
778
|
-
id
|
779
|
-
email
|
812
|
+
id: The identity of a user or a service.
|
813
|
+
email: An email address.
|
814
|
+
username: A username.
|
780
815
|
|
781
816
|
Returns:
|
782
817
|
A PangeaResponse with a user and its information in the response.result field.
|
@@ -788,7 +823,7 @@ class AuthNAsync(ServiceBaseAsync):
|
|
788
823
|
email="joe.user@email.com",
|
789
824
|
)
|
790
825
|
"""
|
791
|
-
input = m.UserProfileGetRequest(id=id, email=email)
|
826
|
+
input = m.UserProfileGetRequest(id=id, email=email, username=username)
|
792
827
|
return await self.request.post(
|
793
828
|
"v2/user/profile/get", m.UserProfileGetResult, data=input.dict(exclude_none=True)
|
794
829
|
)
|
@@ -796,8 +831,10 @@ class AuthNAsync(ServiceBaseAsync):
|
|
796
831
|
async def update(
|
797
832
|
self,
|
798
833
|
profile: m.Profile,
|
799
|
-
id:
|
800
|
-
email:
|
834
|
+
id: str | None = None,
|
835
|
+
email: str | None = None,
|
836
|
+
*,
|
837
|
+
username: str | None = None,
|
801
838
|
) -> PangeaResponse[m.UserProfileUpdateResult]:
|
802
839
|
"""
|
803
840
|
Update user
|
@@ -807,9 +844,10 @@ class AuthNAsync(ServiceBaseAsync):
|
|
807
844
|
OperationId: authn_post_v2_user_profile_update
|
808
845
|
|
809
846
|
Args:
|
810
|
-
profile
|
811
|
-
id
|
812
|
-
email
|
847
|
+
profile: Updates to a user profile.
|
848
|
+
id: The identity of a user or a service.
|
849
|
+
email: An email address.
|
850
|
+
username: A username.
|
813
851
|
|
814
852
|
Returns:
|
815
853
|
A PangeaResponse with a user and its information in the response.result field.
|
@@ -828,6 +866,7 @@ class AuthNAsync(ServiceBaseAsync):
|
|
828
866
|
id=id,
|
829
867
|
email=email,
|
830
868
|
profile=profile,
|
869
|
+
username=username,
|
831
870
|
)
|
832
871
|
return await self.request.post(
|
833
872
|
"v2/user/profile/update", m.UserProfileUpdateResult, data=input.dict(exclude_none=True)
|
@@ -838,10 +877,10 @@ class AuthNAsync(ServiceBaseAsync):
|
|
838
877
|
|
839
878
|
def __init__(
|
840
879
|
self,
|
841
|
-
token,
|
842
|
-
config=None,
|
843
|
-
logger_name="pangea",
|
844
|
-
):
|
880
|
+
token: str,
|
881
|
+
config: PangeaConfig | None = None,
|
882
|
+
logger_name: str = "pangea",
|
883
|
+
) -> None:
|
845
884
|
super().__init__(token, config, logger_name=logger_name)
|
846
885
|
|
847
886
|
async def complete(self, flow_id: str) -> PangeaResponse[m.FlowCompleteResult]:
|
@@ -978,10 +1017,10 @@ class AuthNAsync(ServiceBaseAsync):
|
|
978
1017
|
|
979
1018
|
def __init__(
|
980
1019
|
self,
|
981
|
-
token,
|
982
|
-
config=None,
|
983
|
-
logger_name="pangea",
|
984
|
-
):
|
1020
|
+
token: str,
|
1021
|
+
config: PangeaConfig | None = None,
|
1022
|
+
logger_name: str = "pangea",
|
1023
|
+
) -> None:
|
985
1024
|
super().__init__(token, config, logger_name=logger_name)
|
986
1025
|
|
987
1026
|
async def create(
|
pangea/asyncio/services/authz.py
CHANGED
@@ -28,12 +28,11 @@ from pangea.services.authz import (
|
|
28
28
|
|
29
29
|
|
30
30
|
class AuthZAsync(ServiceBaseAsync):
|
31
|
-
"""AuthZ service client.
|
31
|
+
"""AuthZ service client.
|
32
32
|
|
33
33
|
Provides methods to interact with the Pangea AuthZ Service.
|
34
34
|
Documentation for the AuthZ Service API can be found at
|
35
|
-
<https://pangea.cloud/docs/api/authz>.
|
36
|
-
is subject to change.
|
35
|
+
<https://pangea.cloud/docs/api/authz>.
|
37
36
|
|
38
37
|
Examples:
|
39
38
|
import os
|
@@ -54,11 +53,10 @@ class AuthZAsync(ServiceBaseAsync):
|
|
54
53
|
super().__init__(token, config, logger_name, config_id=config_id)
|
55
54
|
|
56
55
|
async def tuple_create(self, tuples: List[Tuple]) -> PangeaResponse[TupleCreateResult]:
|
57
|
-
"""Create tuples.
|
56
|
+
"""Create tuples.
|
58
57
|
|
59
58
|
Create tuples in the AuthZ Service. The request will fail if there is no schema
|
60
59
|
or the tuples do not validate against the schema.
|
61
|
-
How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
62
60
|
|
63
61
|
Args:
|
64
62
|
tuples (List[Tuple]): List of tuples to be created.
|
@@ -69,24 +67,22 @@ class AuthZAsync(ServiceBaseAsync):
|
|
69
67
|
Returns:
|
70
68
|
Pangea Response with empty result.
|
71
69
|
Available response fields can be found in our
|
72
|
-
[API Documentation](https://pangea.cloud/docs/api/authz#/
|
70
|
+
[API Documentation](https://pangea.cloud/docs/api/authz#/v1/tuple/create).
|
73
71
|
|
74
72
|
Examples:
|
75
73
|
await authz.tuple_create(
|
76
74
|
tuples=[
|
77
75
|
Tuple(
|
78
|
-
resource=Resource(
|
76
|
+
resource=Resource(type="file", id="file_1"),
|
79
77
|
relation="owner",
|
80
|
-
subject=Subject(
|
78
|
+
subject=Subject(type="user", id="user_1"),
|
81
79
|
)
|
82
80
|
]
|
83
81
|
)
|
84
82
|
"""
|
85
83
|
|
86
84
|
input_data = TupleCreateRequest(tuples=tuples)
|
87
|
-
return await self.request.post(
|
88
|
-
"v1beta/tuple/create", TupleCreateResult, data=input_data.dict(exclude_none=True)
|
89
|
-
)
|
85
|
+
return await self.request.post("v1/tuple/create", TupleCreateResult, data=input_data.dict(exclude_none=True))
|
90
86
|
|
91
87
|
async def tuple_list(
|
92
88
|
self,
|
@@ -96,12 +92,11 @@ class AuthZAsync(ServiceBaseAsync):
|
|
96
92
|
order: Optional[ItemOrder] = None,
|
97
93
|
order_by: Optional[TupleOrderBy] = None,
|
98
94
|
) -> PangeaResponse[TupleListResult]:
|
99
|
-
"""List tuples.
|
95
|
+
"""List tuples.
|
100
96
|
|
101
97
|
Return a paginated list of filtered tuples. The filter is given in terms
|
102
98
|
of a tuple. Fill out the fields that you want to filter. If the filter
|
103
99
|
is empty it will return all the tuples.
|
104
|
-
How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
105
100
|
|
106
101
|
Args:
|
107
102
|
filter (TupleListFilter): The filter for listing tuples.
|
@@ -116,21 +111,20 @@ class AuthZAsync(ServiceBaseAsync):
|
|
116
111
|
Returns:
|
117
112
|
Pangea Response with a list of tuples and the last token.
|
118
113
|
Available response fields can be found in our
|
119
|
-
[API Documentation](https://pangea.cloud/docs/api/authz#/
|
114
|
+
[API Documentation](https://pangea.cloud/docs/api/authz#/v1/tuple/list).
|
120
115
|
|
121
116
|
Examples:
|
122
|
-
await authz.tuple_list(TupleListFilter(
|
117
|
+
await authz.tuple_list(TupleListFilter(subject_type="user", subject_id="user_1"))
|
123
118
|
"""
|
124
119
|
input_data = TupleListRequest(
|
125
120
|
filter=filter.dict(exclude_none=True), size=size, last=last, order=order, order_by=order_by
|
126
121
|
)
|
127
|
-
return await self.request.post("
|
122
|
+
return await self.request.post("v1/tuple/list", TupleListResult, data=input_data.dict(exclude_none=True))
|
128
123
|
|
129
124
|
async def tuple_delete(self, tuples: List[Tuple]) -> PangeaResponse[TupleDeleteResult]:
|
130
|
-
"""Delete tuples.
|
125
|
+
"""Delete tuples.
|
131
126
|
|
132
127
|
Delete tuples in the AuthZ Service.
|
133
|
-
How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
134
128
|
|
135
129
|
Args:
|
136
130
|
tuples (List[Tuple]): List of tuples to be deleted.
|
@@ -141,24 +135,22 @@ class AuthZAsync(ServiceBaseAsync):
|
|
141
135
|
Returns:
|
142
136
|
Pangea Response with empty result.
|
143
137
|
Available response fields can be found in our
|
144
|
-
[API Documentation](https://pangea.cloud/docs/api/authz#/
|
138
|
+
[API Documentation](https://pangea.cloud/docs/api/authz#/v1/tuple/delete).
|
145
139
|
|
146
140
|
Examples:
|
147
141
|
await authz.tuple_delete(
|
148
142
|
tuples=[
|
149
143
|
Tuple(
|
150
|
-
resource=Resource(
|
144
|
+
resource=Resource(type="file", id="file_1"),
|
151
145
|
relation="owner",
|
152
|
-
subject=Subject(
|
146
|
+
subject=Subject(type="user", id="user_1"),
|
153
147
|
)
|
154
148
|
]
|
155
149
|
)
|
156
150
|
"""
|
157
151
|
|
158
152
|
input_data = TupleDeleteRequest(tuples=tuples)
|
159
|
-
return await self.request.post(
|
160
|
-
"v1beta/tuple/delete", TupleDeleteResult, data=input_data.dict(exclude_none=True)
|
161
|
-
)
|
153
|
+
return await self.request.post("v1/tuple/delete", TupleDeleteResult, data=input_data.dict(exclude_none=True))
|
162
154
|
|
163
155
|
async def check(
|
164
156
|
self,
|
@@ -168,10 +160,9 @@ class AuthZAsync(ServiceBaseAsync):
|
|
168
160
|
debug: Optional[bool] = None,
|
169
161
|
attributes: Optional[Dict[str, Union[int, str]]] = None,
|
170
162
|
) -> PangeaResponse[CheckResult]:
|
171
|
-
"""Perform a check request.
|
163
|
+
"""Perform a check request.
|
172
164
|
|
173
165
|
Check if a subject has permission to perform an action on the resource.
|
174
|
-
How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
175
166
|
|
176
167
|
Args:
|
177
168
|
resource (Resource): The resource to check.
|
@@ -186,31 +177,28 @@ class AuthZAsync(ServiceBaseAsync):
|
|
186
177
|
Returns:
|
187
178
|
Pangea Response with the result of the check.
|
188
179
|
Available response fields can be found in our
|
189
|
-
[API Documentation](https://pangea.cloud/docs/api/authz#/
|
180
|
+
[API Documentation](https://pangea.cloud/docs/api/authz#/v1/check).
|
190
181
|
|
191
182
|
Examples:
|
192
183
|
await authz.check(
|
193
|
-
resource=Resource(
|
184
|
+
resource=Resource(type="file", id="file_1"),
|
194
185
|
action="update",
|
195
|
-
subject=Subject(
|
186
|
+
subject=Subject(type="user", id="user_1"),
|
196
187
|
debug=True,
|
197
188
|
)
|
198
189
|
"""
|
199
190
|
|
200
191
|
input_data = CheckRequest(resource=resource, action=action, subject=subject, debug=debug, attributes=attributes)
|
201
|
-
return await self.request.post("
|
192
|
+
return await self.request.post("v1/check", CheckResult, data=input_data.dict(exclude_none=True))
|
202
193
|
|
203
|
-
async def list_resources(
|
204
|
-
|
205
|
-
) -> PangeaResponse[ListResourcesResult]:
|
206
|
-
"""List resources. (Beta)
|
194
|
+
async def list_resources(self, type: str, action: str, subject: Subject) -> PangeaResponse[ListResourcesResult]:
|
195
|
+
"""List resources.
|
207
196
|
|
208
|
-
Given a
|
209
|
-
|
210
|
-
How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
197
|
+
Given a type, action, and subject, list all the resources in the
|
198
|
+
type that the subject has access to the action with.
|
211
199
|
|
212
200
|
Args:
|
213
|
-
|
201
|
+
type (str): The type to filter resources.
|
214
202
|
action (str): The action to filter resources.
|
215
203
|
subject (Subject): The subject to filter resources.
|
216
204
|
|
@@ -220,27 +208,26 @@ class AuthZAsync(ServiceBaseAsync):
|
|
220
208
|
Returns:
|
221
209
|
Pangea Response with a list of resource IDs.
|
222
210
|
Available response fields can be found in our
|
223
|
-
[API Documentation](https://pangea.cloud/docs/api/authz#/
|
211
|
+
[API Documentation](https://pangea.cloud/docs/api/authz#/v1/list-resources).
|
224
212
|
|
225
213
|
Examples:
|
226
214
|
await authz.list_resources(
|
227
|
-
|
215
|
+
type="file",
|
228
216
|
action="update",
|
229
|
-
subject=Subject(
|
217
|
+
subject=Subject(type="user", id="user_1"),
|
230
218
|
)
|
231
219
|
"""
|
232
220
|
|
233
|
-
input_data = ListResourcesRequest(
|
221
|
+
input_data = ListResourcesRequest(type=type, action=action, subject=subject)
|
234
222
|
return await self.request.post(
|
235
|
-
"
|
223
|
+
"v1/list-resources", ListResourcesResult, data=input_data.dict(exclude_none=True)
|
236
224
|
)
|
237
225
|
|
238
226
|
async def list_subjects(self, resource: Resource, action: str) -> PangeaResponse[ListSubjectsResult]:
|
239
|
-
"""List subjects.
|
227
|
+
"""List subjects.
|
240
228
|
|
241
229
|
Given a resource and an action, return the list of subjects who have
|
242
230
|
access to the action for the given resource.
|
243
|
-
How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
244
231
|
|
245
232
|
Args:
|
246
233
|
resource (Resource): The resource to filter subjects.
|
@@ -252,16 +239,14 @@ class AuthZAsync(ServiceBaseAsync):
|
|
252
239
|
Returns:
|
253
240
|
Pangea Response with a list of subjects.
|
254
241
|
Available response fields can be found in our
|
255
|
-
[API Documentation](https://pangea.cloud/docs/api/authz#/
|
242
|
+
[API Documentation](https://pangea.cloud/docs/api/authz#/v1/list-subjects).
|
256
243
|
|
257
244
|
Examples:
|
258
245
|
await authz.list_subjects(
|
259
|
-
resource=Resource(
|
246
|
+
resource=Resource(type="file", id="file_1"),
|
260
247
|
action="update",
|
261
248
|
)
|
262
249
|
"""
|
263
250
|
|
264
251
|
input_data = ListSubjectsRequest(resource=resource, action=action)
|
265
|
-
return await self.request.post(
|
266
|
-
"v1beta/list-subjects", ListSubjectsResult, data=input_data.dict(exclude_none=True)
|
267
|
-
)
|
252
|
+
return await self.request.post("v1/list-subjects", ListSubjectsResult, data=input_data.dict(exclude_none=True))
|