dfns-sdk 0.0.0.dev0__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.
- dfns_sdk/__init__.py +24 -0
- dfns_sdk/_internal/__init__.py +5 -0
- dfns_sdk/_internal/http_client.py +395 -0
- dfns_sdk/auth.py +137 -0
- dfns_sdk/base_auth_api.py +129 -0
- dfns_sdk/client.py +81 -0
- dfns_sdk/delegated_client.py +97 -0
- dfns_sdk/generated/__init__.py +47 -0
- dfns_sdk/generated/agreements/__init__.py +7 -0
- dfns_sdk/generated/agreements/client.py +55 -0
- dfns_sdk/generated/agreements/delegated_client.py +95 -0
- dfns_sdk/generated/agreements/types.py +20 -0
- dfns_sdk/generated/allocations/__init__.py +7 -0
- dfns_sdk/generated/allocations/client.py +118 -0
- dfns_sdk/generated/allocations/delegated_client.py +187 -0
- dfns_sdk/generated/allocations/types.py +69 -0
- dfns_sdk/generated/auth/__init__.py +7 -0
- dfns_sdk/generated/auth/client.py +1215 -0
- dfns_sdk/generated/auth/delegated_client.py +1825 -0
- dfns_sdk/generated/auth/types.py +702 -0
- dfns_sdk/generated/exchanges/__init__.py +7 -0
- dfns_sdk/generated/exchanges/client.py +209 -0
- dfns_sdk/generated/exchanges/delegated_client.py +341 -0
- dfns_sdk/generated/exchanges/types.py +96 -0
- dfns_sdk/generated/fee_sponsors/__init__.py +7 -0
- dfns_sdk/generated/fee_sponsors/client.py +161 -0
- dfns_sdk/generated/fee_sponsors/delegated_client.py +287 -0
- dfns_sdk/generated/fee_sponsors/types.py +89 -0
- dfns_sdk/generated/keys/__init__.py +7 -0
- dfns_sdk/generated/keys/client.py +310 -0
- dfns_sdk/generated/keys/delegated_client.py +518 -0
- dfns_sdk/generated/keys/types.py +229 -0
- dfns_sdk/generated/networks/__init__.py +7 -0
- dfns_sdk/generated/networks/client.py +176 -0
- dfns_sdk/generated/networks/delegated_client.py +274 -0
- dfns_sdk/generated/networks/types.py +77 -0
- dfns_sdk/generated/permissions/__init__.py +7 -0
- dfns_sdk/generated/permissions/client.py +185 -0
- dfns_sdk/generated/permissions/delegated_client.py +344 -0
- dfns_sdk/generated/permissions/types.py +107 -0
- dfns_sdk/generated/policies/__init__.py +7 -0
- dfns_sdk/generated/policies/client.py +187 -0
- dfns_sdk/generated/policies/delegated_client.py +311 -0
- dfns_sdk/generated/policies/types.py +70 -0
- dfns_sdk/generated/signers/__init__.py +7 -0
- dfns_sdk/generated/signers/client.py +45 -0
- dfns_sdk/generated/signers/delegated_client.py +56 -0
- dfns_sdk/generated/signers/types.py +13 -0
- dfns_sdk/generated/staking/__init__.py +7 -0
- dfns_sdk/generated/staking/client.py +142 -0
- dfns_sdk/generated/staking/delegated_client.py +211 -0
- dfns_sdk/generated/staking/types.py +64 -0
- dfns_sdk/generated/swaps/__init__.py +7 -0
- dfns_sdk/generated/swaps/client.py +118 -0
- dfns_sdk/generated/swaps/delegated_client.py +157 -0
- dfns_sdk/generated/swaps/types.py +99 -0
- dfns_sdk/generated/wallets/__init__.py +7 -0
- dfns_sdk/generated/wallets/client.py +805 -0
- dfns_sdk/generated/wallets/delegated_client.py +1231 -0
- dfns_sdk/generated/wallets/types.py +534 -0
- dfns_sdk/generated/webhooks/__init__.py +7 -0
- dfns_sdk/generated/webhooks/client.py +193 -0
- dfns_sdk/generated/webhooks/delegated_client.py +320 -0
- dfns_sdk/generated/webhooks/types.py +101 -0
- dfns_sdk/types.py +72 -0
- dfns_sdk-0.0.0.dev0.dist-info/METADATA +191 -0
- dfns_sdk-0.0.0.dev0.dist-info/RECORD +69 -0
- dfns_sdk-0.0.0.dev0.dist-info/WHEEL +4 -0
- dfns_sdk-0.0.0.dev0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"""Types for the permissions domain."""
|
|
2
|
+
|
|
3
|
+
from typing import Any, Literal, NotRequired, Optional, TypedDict, Union
|
|
4
|
+
|
|
5
|
+
class ListPermissionAssignmentsResponse(TypedDict, total=False):
|
|
6
|
+
"""listPermissionAssignments response."""
|
|
7
|
+
|
|
8
|
+
items: list[TypedDict]
|
|
9
|
+
next_page_token: NotRequired[str]
|
|
10
|
+
|
|
11
|
+
class AssignPermissionRequest(TypedDict, total=False):
|
|
12
|
+
"""assignPermission request body."""
|
|
13
|
+
|
|
14
|
+
identity_id: str
|
|
15
|
+
|
|
16
|
+
class AssignPermissionResponse(TypedDict, total=False):
|
|
17
|
+
"""assignPermission response."""
|
|
18
|
+
|
|
19
|
+
id: str
|
|
20
|
+
permission_id: str
|
|
21
|
+
identity_id: str
|
|
22
|
+
is_immutable: bool
|
|
23
|
+
date_created: str
|
|
24
|
+
date_updated: str
|
|
25
|
+
|
|
26
|
+
class RevokePermissionQuery(TypedDict, total=False):
|
|
27
|
+
"""revokePermission query parameters."""
|
|
28
|
+
|
|
29
|
+
force: NotRequired[bool]
|
|
30
|
+
|
|
31
|
+
class DeletePermissionRequest(TypedDict, total=False):
|
|
32
|
+
"""deletePermission request body."""
|
|
33
|
+
|
|
34
|
+
is_archived: bool
|
|
35
|
+
|
|
36
|
+
class DeletePermissionResponse(TypedDict, total=False):
|
|
37
|
+
"""deletePermission response."""
|
|
38
|
+
|
|
39
|
+
id: str
|
|
40
|
+
name: str
|
|
41
|
+
operations: list[str]
|
|
42
|
+
status: Literal["Active"]
|
|
43
|
+
is_immutable: bool
|
|
44
|
+
is_archived: bool
|
|
45
|
+
date_created: str
|
|
46
|
+
date_updated: str
|
|
47
|
+
|
|
48
|
+
class ListPermissionsResponse(TypedDict, total=False):
|
|
49
|
+
"""listPermissions response."""
|
|
50
|
+
|
|
51
|
+
items: list[TypedDict]
|
|
52
|
+
next_page_token: NotRequired[str]
|
|
53
|
+
|
|
54
|
+
class ListPermissionsQuery(TypedDict, total=False):
|
|
55
|
+
"""listPermissions query parameters."""
|
|
56
|
+
|
|
57
|
+
limit: NotRequired[str]
|
|
58
|
+
pagination_token: NotRequired[str]
|
|
59
|
+
|
|
60
|
+
class CreatePermissionRequest(TypedDict, total=False):
|
|
61
|
+
"""createPermission request body."""
|
|
62
|
+
|
|
63
|
+
name: str
|
|
64
|
+
operations: list[Union[Literal["Registry:Addresses:Create", "Registry:Addresses:Delete", "Registry:Addresses:Read", "Registry:Addresses:Update", "Registry:ContractSchemas:Create", "Registry:ContractSchemas:Delete", "Registry:ContractSchemas:Read", "Auth:Logs:Read", "Auth:Users:Create", "Auth:Users:Read", "Auth:Users:Update", "Auth:Users:Activate", "Auth:Users:Deactivate", "Auth:Users:Delete", "Auth:ServiceAccounts:Create", "Auth:ServiceAccounts:Read", "Auth:ServiceAccounts:Update", "Auth:ServiceAccounts:Deactivate", "Auth:ServiceAccounts:Activate", "Auth:ServiceAccounts:Delete", "Auth:Pats:Create", "Auth:Register:Delegated", "Auth:Login:Delegated", "Auth:Recover:Delegated", "Agreements:Acceptance:Create", "Agreements:Acceptance:Read", "Events:Read", "Exchanges:Create", "Exchanges:Read", "Exchanges:Delete", "Exchanges:Deposits:Create", "Exchanges:Withdrawals:Create", "FeeSponsors:Create", "FeeSponsors:Read", "FeeSponsors:Update", "FeeSponsors:Delete", "FeeSponsors:Use", "Orgs:Read", "Orgs:Update", "Orgs:Settings:Read", "Orgs:Settings:Update", "Permissions:Archive", "Permissions:Create", "Permissions:Read", "Permissions:Update", "Permissions:Assign", "Permissions:Revoke", "Permissions:Assignments:Read", "Policies:Archive", "Policies:Create", "Policies:Read", "Policies:Update", "Policies:Approvals:Read", "Policies:Approvals:Approve", "Signers:ListSigners", "Stakes:Create", "Stakes:Read", "Stakes:Update", "Swaps:Create", "Swaps:Read", "Allocations:Create", "Allocations:Update", "Allocations:Read", "Keys:Create", "Keys:Delete", "Keys:Read", "Keys:Update", "Keys:Reuse", "Keys:Delegate", "Keys:Import", "Keys:Export", "Keys:Derive", "Keys:ChildKeys:Create", "Keys:Signatures:Create", "Keys:Signatures:Read", "KeyStores:Read", "Networks:CantonValidators:Create", "Networks:CantonValidators:Read", "Networks:CantonValidators:Update", "Networks:CantonValidators:Delete", "Wallets:Create", "Wallets:Read", "Wallets:Update", "Wallets:Tags:Add", "Wallets:Tags:Delete", "Wallets:Transactions:Create", "Wallets:Transactions:Read", "Wallets:Transfers:Create", "Wallets:Transfers:Read", "Wallets:Offers:Read", "Wallets:Offers:Settle", "Webhooks:Create", "Webhooks:Read", "Webhooks:Update", "Webhooks:Delete", "Webhooks:Ping", "Webhooks:Events:Read", "Billing:Read", "Billing:Write", "Analytics:Read"], Literal["Alias:Create", "Alias:Delete", "Alias:Read", "Alias:Update", "Wallets:GenerateSignature", "Wallets:BroadcastTransaction", "Auth:Action:Sign", "Auth:Apps:Read", "Auth:Apps:Create", "Auth:Apps:Update", "Auth:Creds:Create", "Auth:Creds:Read", "Auth:Creds:Update", "Auth:Creds:Code:Create", "Auth:Types:Application", "Auth:Types:Employee", "Auth:Types:EndUser", "Auth:Types:Pat", "Auth:Types:ServiceAccount", "Internal:Auth:Types:Staff", "Auth:Users:Delegate", "PermissionAssignments:Create", "PermissionAssignments:Read", "PermissionAssignments:Revoke"]]]
|
|
65
|
+
|
|
66
|
+
class CreatePermissionResponse(TypedDict, total=False):
|
|
67
|
+
"""createPermission response."""
|
|
68
|
+
|
|
69
|
+
id: str
|
|
70
|
+
name: str
|
|
71
|
+
operations: list[str]
|
|
72
|
+
status: Literal["Active"]
|
|
73
|
+
is_immutable: bool
|
|
74
|
+
is_archived: bool
|
|
75
|
+
date_created: str
|
|
76
|
+
date_updated: str
|
|
77
|
+
|
|
78
|
+
class GetPermissionResponse(TypedDict, total=False):
|
|
79
|
+
"""getPermission response."""
|
|
80
|
+
|
|
81
|
+
id: str
|
|
82
|
+
name: str
|
|
83
|
+
operations: list[str]
|
|
84
|
+
status: Literal["Active"]
|
|
85
|
+
is_immutable: bool
|
|
86
|
+
is_archived: bool
|
|
87
|
+
date_created: str
|
|
88
|
+
date_updated: str
|
|
89
|
+
pending_change_request: NotRequired[TypedDict]
|
|
90
|
+
|
|
91
|
+
class UpdatePermissionRequest(TypedDict, total=False):
|
|
92
|
+
"""updatePermission request body."""
|
|
93
|
+
|
|
94
|
+
name: NotRequired[str]
|
|
95
|
+
operations: NotRequired[list[Union[Literal["Registry:Addresses:Create", "Registry:Addresses:Delete", "Registry:Addresses:Read", "Registry:Addresses:Update", "Registry:ContractSchemas:Create", "Registry:ContractSchemas:Delete", "Registry:ContractSchemas:Read", "Auth:Logs:Read", "Auth:Users:Create", "Auth:Users:Read", "Auth:Users:Update", "Auth:Users:Activate", "Auth:Users:Deactivate", "Auth:Users:Delete", "Auth:ServiceAccounts:Create", "Auth:ServiceAccounts:Read", "Auth:ServiceAccounts:Update", "Auth:ServiceAccounts:Deactivate", "Auth:ServiceAccounts:Activate", "Auth:ServiceAccounts:Delete", "Auth:Pats:Create", "Auth:Register:Delegated", "Auth:Login:Delegated", "Auth:Recover:Delegated", "Agreements:Acceptance:Create", "Agreements:Acceptance:Read", "Events:Read", "Exchanges:Create", "Exchanges:Read", "Exchanges:Delete", "Exchanges:Deposits:Create", "Exchanges:Withdrawals:Create", "FeeSponsors:Create", "FeeSponsors:Read", "FeeSponsors:Update", "FeeSponsors:Delete", "FeeSponsors:Use", "Orgs:Read", "Orgs:Update", "Orgs:Settings:Read", "Orgs:Settings:Update", "Permissions:Archive", "Permissions:Create", "Permissions:Read", "Permissions:Update", "Permissions:Assign", "Permissions:Revoke", "Permissions:Assignments:Read", "Policies:Archive", "Policies:Create", "Policies:Read", "Policies:Update", "Policies:Approvals:Read", "Policies:Approvals:Approve", "Signers:ListSigners", "Stakes:Create", "Stakes:Read", "Stakes:Update", "Swaps:Create", "Swaps:Read", "Allocations:Create", "Allocations:Update", "Allocations:Read", "Keys:Create", "Keys:Delete", "Keys:Read", "Keys:Update", "Keys:Reuse", "Keys:Delegate", "Keys:Import", "Keys:Export", "Keys:Derive", "Keys:ChildKeys:Create", "Keys:Signatures:Create", "Keys:Signatures:Read", "KeyStores:Read", "Networks:CantonValidators:Create", "Networks:CantonValidators:Read", "Networks:CantonValidators:Update", "Networks:CantonValidators:Delete", "Wallets:Create", "Wallets:Read", "Wallets:Update", "Wallets:Tags:Add", "Wallets:Tags:Delete", "Wallets:Transactions:Create", "Wallets:Transactions:Read", "Wallets:Transfers:Create", "Wallets:Transfers:Read", "Wallets:Offers:Read", "Wallets:Offers:Settle", "Webhooks:Create", "Webhooks:Read", "Webhooks:Update", "Webhooks:Delete", "Webhooks:Ping", "Webhooks:Events:Read", "Billing:Read", "Billing:Write", "Analytics:Read"], Literal["Alias:Create", "Alias:Delete", "Alias:Read", "Alias:Update", "Wallets:GenerateSignature", "Wallets:BroadcastTransaction", "Auth:Action:Sign", "Auth:Apps:Read", "Auth:Apps:Create", "Auth:Apps:Update", "Auth:Creds:Create", "Auth:Creds:Read", "Auth:Creds:Update", "Auth:Creds:Code:Create", "Auth:Types:Application", "Auth:Types:Employee", "Auth:Types:EndUser", "Auth:Types:Pat", "Auth:Types:ServiceAccount", "Internal:Auth:Types:Staff", "Auth:Users:Delegate", "PermissionAssignments:Create", "PermissionAssignments:Read", "PermissionAssignments:Revoke"]]]]
|
|
96
|
+
|
|
97
|
+
class UpdatePermissionResponse(TypedDict, total=False):
|
|
98
|
+
"""updatePermission response."""
|
|
99
|
+
|
|
100
|
+
id: str
|
|
101
|
+
name: str
|
|
102
|
+
operations: list[str]
|
|
103
|
+
status: Literal["Active"]
|
|
104
|
+
is_immutable: bool
|
|
105
|
+
is_archived: bool
|
|
106
|
+
date_created: str
|
|
107
|
+
date_updated: str
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"""Client for the policies domain."""
|
|
2
|
+
|
|
3
|
+
from typing import Any, Literal, Optional, TypedDict, Union
|
|
4
|
+
|
|
5
|
+
from ..._internal import HttpClient
|
|
6
|
+
from . import types as T
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class PoliciesClient:
|
|
10
|
+
"""Client for policies operations."""
|
|
11
|
+
|
|
12
|
+
def __init__(self, http_client: HttpClient):
|
|
13
|
+
self._http = http_client
|
|
14
|
+
|
|
15
|
+
def get_policy(self, policy_id: str) -> T.GetPolicyResponse:
|
|
16
|
+
"""
|
|
17
|
+
Get Policy.
|
|
18
|
+
|
|
19
|
+
Retrieve information about a specific policy.
|
|
20
|
+
|
|
21
|
+
Args:
|
|
22
|
+
policy_id: Path parameter.
|
|
23
|
+
|
|
24
|
+
Returns:
|
|
25
|
+
T.GetPolicyResponse: The API response.
|
|
26
|
+
"""
|
|
27
|
+
return self._http.request(
|
|
28
|
+
method="GET",
|
|
29
|
+
path="/v2/policies/{policyId}",
|
|
30
|
+
path_params={"policyId": policy_id},
|
|
31
|
+
query_params=None,
|
|
32
|
+
body=None,
|
|
33
|
+
requires_signature=False,
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
def update_policy(self, policy_id: str, body: dict[str, Any]) -> TypedDict:
|
|
37
|
+
"""
|
|
38
|
+
Update Policy.
|
|
39
|
+
|
|
40
|
+
Update an existing policy.
|
|
41
|
+
|
|
42
|
+
Args:
|
|
43
|
+
policy_id: Path parameter.
|
|
44
|
+
body: Request body.
|
|
45
|
+
|
|
46
|
+
Returns:
|
|
47
|
+
TypedDict: The API response.
|
|
48
|
+
"""
|
|
49
|
+
return self._http.request(
|
|
50
|
+
method="PUT",
|
|
51
|
+
path="/v2/policies/{policyId}",
|
|
52
|
+
path_params={"policyId": policy_id},
|
|
53
|
+
query_params=None,
|
|
54
|
+
body=body,
|
|
55
|
+
requires_signature=True,
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
def delete_policy(self, policy_id: str) -> TypedDict:
|
|
59
|
+
"""
|
|
60
|
+
Delete Policy.
|
|
61
|
+
|
|
62
|
+
Delete an existing policy.
|
|
63
|
+
|
|
64
|
+
Args:
|
|
65
|
+
policy_id: Path parameter.
|
|
66
|
+
|
|
67
|
+
Returns:
|
|
68
|
+
TypedDict: The API response.
|
|
69
|
+
"""
|
|
70
|
+
return self._http.request(
|
|
71
|
+
method="DELETE",
|
|
72
|
+
path="/v2/policies/{policyId}",
|
|
73
|
+
path_params={"policyId": policy_id},
|
|
74
|
+
query_params=None,
|
|
75
|
+
body=None,
|
|
76
|
+
requires_signature=True,
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
def create_approval_decision(self, approval_id: str, body: T.CreateApprovalDecisionRequest) -> T.CreateApprovalDecisionResponse:
|
|
80
|
+
"""
|
|
81
|
+
Create Approval Decision.
|
|
82
|
+
|
|
83
|
+
Approve or Reject an Approval request.
|
|
84
|
+
|
|
85
|
+
Args:
|
|
86
|
+
approval_id: Path parameter.
|
|
87
|
+
body: Request body.
|
|
88
|
+
|
|
89
|
+
Returns:
|
|
90
|
+
T.CreateApprovalDecisionResponse: The API response.
|
|
91
|
+
"""
|
|
92
|
+
return self._http.request(
|
|
93
|
+
method="POST",
|
|
94
|
+
path="/v2/policy-approvals/{approvalId}/decisions",
|
|
95
|
+
path_params={"approvalId": approval_id},
|
|
96
|
+
query_params=None,
|
|
97
|
+
body=body,
|
|
98
|
+
requires_signature=True,
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
def list_policies(self, query: Optional[T.ListPoliciesQuery] = None) -> T.ListPoliciesResponse:
|
|
102
|
+
"""
|
|
103
|
+
List Policies.
|
|
104
|
+
|
|
105
|
+
Retrieve the list of policies on your organization.
|
|
106
|
+
|
|
107
|
+
Args:
|
|
108
|
+
query: Query parameters.
|
|
109
|
+
|
|
110
|
+
Returns:
|
|
111
|
+
T.ListPoliciesResponse: The API response.
|
|
112
|
+
"""
|
|
113
|
+
return self._http.request(
|
|
114
|
+
method="GET",
|
|
115
|
+
path="/v2/policies",
|
|
116
|
+
path_params={},
|
|
117
|
+
query_params=query,
|
|
118
|
+
body=None,
|
|
119
|
+
requires_signature=False,
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
def create_policy(self, body: dict[str, Any]) -> TypedDict:
|
|
123
|
+
"""
|
|
124
|
+
Create Policy.
|
|
125
|
+
|
|
126
|
+
Setup a new Policy for your organization.
|
|
127
|
+
|
|
128
|
+
Every policy requires a rule to be specified. Upon policy evaluation, the configuration specified in the rule will be used to determine whether the policy should trigger or not for a given activity.
|
|
129
|
+
|
|
130
|
+
By exposing controls on permissions and policies, Dfns enables the specification of an admin quorum to approve sensitive actions which could change system governance. Note Dfns does not expose a separate "admin quorum" concept like some of our competitors - we simply enable this use case as another configuration of the policy engine itself. This was chosen to promote flexibility as not every customer will have the same requirements around creating and managing admin quorums.
|
|
131
|
+
|
|
132
|
+
Args:
|
|
133
|
+
body: Request body.
|
|
134
|
+
|
|
135
|
+
Returns:
|
|
136
|
+
TypedDict: The API response.
|
|
137
|
+
"""
|
|
138
|
+
return self._http.request(
|
|
139
|
+
method="POST",
|
|
140
|
+
path="/v2/policies",
|
|
141
|
+
path_params={},
|
|
142
|
+
query_params=None,
|
|
143
|
+
body=body,
|
|
144
|
+
requires_signature=True,
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
def get_approval(self, approval_id: str) -> T.GetApprovalResponse:
|
|
148
|
+
"""
|
|
149
|
+
Get Approval.
|
|
150
|
+
|
|
151
|
+
Retrieve information about a specific approval request.
|
|
152
|
+
|
|
153
|
+
Args:
|
|
154
|
+
approval_id: Path parameter.
|
|
155
|
+
|
|
156
|
+
Returns:
|
|
157
|
+
T.GetApprovalResponse: The API response.
|
|
158
|
+
"""
|
|
159
|
+
return self._http.request(
|
|
160
|
+
method="GET",
|
|
161
|
+
path="/v2/policy-approvals/{approvalId}",
|
|
162
|
+
path_params={"approvalId": approval_id},
|
|
163
|
+
query_params=None,
|
|
164
|
+
body=None,
|
|
165
|
+
requires_signature=False,
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
def list_approvals(self, query: Optional[T.ListApprovalsQuery] = None) -> T.ListApprovalsResponse:
|
|
169
|
+
"""
|
|
170
|
+
List Approvals.
|
|
171
|
+
|
|
172
|
+
Retrieve the list of pending approval requests.
|
|
173
|
+
|
|
174
|
+
Args:
|
|
175
|
+
query: Query parameters.
|
|
176
|
+
|
|
177
|
+
Returns:
|
|
178
|
+
T.ListApprovalsResponse: The API response.
|
|
179
|
+
"""
|
|
180
|
+
return self._http.request(
|
|
181
|
+
method="GET",
|
|
182
|
+
path="/v2/policy-approvals",
|
|
183
|
+
path_params={},
|
|
184
|
+
query_params=query,
|
|
185
|
+
body=None,
|
|
186
|
+
requires_signature=False,
|
|
187
|
+
)
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
"""Delegated client for the policies domain."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
from typing import Any, Literal, Optional, TypedDict, Union
|
|
5
|
+
|
|
6
|
+
from ..._internal import HttpClient
|
|
7
|
+
from ...base_auth_api import (
|
|
8
|
+
BaseAuthApi,
|
|
9
|
+
SignUserActionChallengeRequest,
|
|
10
|
+
UserActionChallengeResponse,
|
|
11
|
+
)
|
|
12
|
+
from . import types as T
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class DelegatedPoliciesClient:
|
|
16
|
+
"""
|
|
17
|
+
Delegated client for policies operations.
|
|
18
|
+
|
|
19
|
+
This client separates user action signing into _init() and _complete() method pairs,
|
|
20
|
+
allowing external systems to handle the signing process.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
def __init__(self, http_client: HttpClient):
|
|
24
|
+
self._http = http_client
|
|
25
|
+
|
|
26
|
+
def get_policy(self, policy_id: str) -> T.GetPolicyResponse:
|
|
27
|
+
"""
|
|
28
|
+
Get Policy.
|
|
29
|
+
|
|
30
|
+
Retrieve information about a specific policy.
|
|
31
|
+
|
|
32
|
+
Args:
|
|
33
|
+
policy_id: Path parameter.
|
|
34
|
+
|
|
35
|
+
Returns:
|
|
36
|
+
T.GetPolicyResponse: The API response.
|
|
37
|
+
"""
|
|
38
|
+
return self._http.request(
|
|
39
|
+
method="GET",
|
|
40
|
+
path="/v2/policies/{policyId}",
|
|
41
|
+
path_params={"policyId": policy_id},
|
|
42
|
+
query_params=None,
|
|
43
|
+
body=None,
|
|
44
|
+
requires_signature=False,
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
def update_policy_init(self, policy_id: str, body: dict[str, Any]) -> UserActionChallengeResponse:
|
|
48
|
+
"""
|
|
49
|
+
Initialize Update Policy.
|
|
50
|
+
|
|
51
|
+
Creates a user action challenge for external signing.
|
|
52
|
+
|
|
53
|
+
Args:
|
|
54
|
+
policy_id: Path parameter.
|
|
55
|
+
body: Request body.
|
|
56
|
+
|
|
57
|
+
Returns:
|
|
58
|
+
UserActionChallengeResponse: The challenge to sign externally.
|
|
59
|
+
"""
|
|
60
|
+
path = "/v2/policies/{policyId}"
|
|
61
|
+
path = path.replace("{policyId}", str(policy_id))
|
|
62
|
+
payload = json.dumps(body, separators=(",", ":")) if body else ""
|
|
63
|
+
|
|
64
|
+
return BaseAuthApi.create_user_action_challenge(
|
|
65
|
+
self._http,
|
|
66
|
+
user_action_http_method="PUT",
|
|
67
|
+
user_action_http_path=path,
|
|
68
|
+
user_action_payload=payload,
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
def update_policy_complete(self, policy_id: str, body: dict[str, Any], signed_challenge: SignUserActionChallengeRequest) -> TypedDict:
|
|
72
|
+
"""
|
|
73
|
+
Complete Update Policy.
|
|
74
|
+
|
|
75
|
+
Submits the signed challenge and makes the API request.
|
|
76
|
+
|
|
77
|
+
Args:
|
|
78
|
+
policy_id: Path parameter.
|
|
79
|
+
body: Request body.
|
|
80
|
+
signed_challenge: The signed challenge from external signing.
|
|
81
|
+
|
|
82
|
+
Returns:
|
|
83
|
+
TypedDict: The API response.
|
|
84
|
+
"""
|
|
85
|
+
user_action_result = BaseAuthApi.sign_user_action_challenge(
|
|
86
|
+
self._http, signed_challenge
|
|
87
|
+
)
|
|
88
|
+
user_action_token = user_action_result["userAction"]
|
|
89
|
+
|
|
90
|
+
return self._http.request_with_user_action(
|
|
91
|
+
method="PUT",
|
|
92
|
+
path="/v2/policies/{policyId}",
|
|
93
|
+
path_params={"policyId": policy_id},
|
|
94
|
+
query_params=None,
|
|
95
|
+
body=body,
|
|
96
|
+
user_action=user_action_token,
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
def delete_policy_init(self, policy_id: str) -> UserActionChallengeResponse:
|
|
100
|
+
"""
|
|
101
|
+
Initialize Delete Policy.
|
|
102
|
+
|
|
103
|
+
Creates a user action challenge for external signing.
|
|
104
|
+
|
|
105
|
+
Args:
|
|
106
|
+
policy_id: Path parameter.
|
|
107
|
+
|
|
108
|
+
Returns:
|
|
109
|
+
UserActionChallengeResponse: The challenge to sign externally.
|
|
110
|
+
"""
|
|
111
|
+
path = "/v2/policies/{policyId}"
|
|
112
|
+
path = path.replace("{policyId}", str(policy_id))
|
|
113
|
+
payload = ""
|
|
114
|
+
|
|
115
|
+
return BaseAuthApi.create_user_action_challenge(
|
|
116
|
+
self._http,
|
|
117
|
+
user_action_http_method="DELETE",
|
|
118
|
+
user_action_http_path=path,
|
|
119
|
+
user_action_payload=payload,
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
def delete_policy_complete(self, policy_id: str, signed_challenge: SignUserActionChallengeRequest) -> TypedDict:
|
|
123
|
+
"""
|
|
124
|
+
Complete Delete Policy.
|
|
125
|
+
|
|
126
|
+
Submits the signed challenge and makes the API request.
|
|
127
|
+
|
|
128
|
+
Args:
|
|
129
|
+
policy_id: Path parameter.
|
|
130
|
+
signed_challenge: The signed challenge from external signing.
|
|
131
|
+
|
|
132
|
+
Returns:
|
|
133
|
+
TypedDict: The API response.
|
|
134
|
+
"""
|
|
135
|
+
user_action_result = BaseAuthApi.sign_user_action_challenge(
|
|
136
|
+
self._http, signed_challenge
|
|
137
|
+
)
|
|
138
|
+
user_action_token = user_action_result["userAction"]
|
|
139
|
+
|
|
140
|
+
return self._http.request_with_user_action(
|
|
141
|
+
method="DELETE",
|
|
142
|
+
path="/v2/policies/{policyId}",
|
|
143
|
+
path_params={"policyId": policy_id},
|
|
144
|
+
query_params=None,
|
|
145
|
+
body=None,
|
|
146
|
+
user_action=user_action_token,
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
def create_approval_decision_init(self, approval_id: str, body: T.CreateApprovalDecisionRequest) -> UserActionChallengeResponse:
|
|
150
|
+
"""
|
|
151
|
+
Initialize Create Approval Decision.
|
|
152
|
+
|
|
153
|
+
Creates a user action challenge for external signing.
|
|
154
|
+
|
|
155
|
+
Args:
|
|
156
|
+
approval_id: Path parameter.
|
|
157
|
+
body: Request body.
|
|
158
|
+
|
|
159
|
+
Returns:
|
|
160
|
+
UserActionChallengeResponse: The challenge to sign externally.
|
|
161
|
+
"""
|
|
162
|
+
path = "/v2/policy-approvals/{approvalId}/decisions"
|
|
163
|
+
path = path.replace("{approvalId}", str(approval_id))
|
|
164
|
+
payload = json.dumps(body, separators=(",", ":")) if body else ""
|
|
165
|
+
|
|
166
|
+
return BaseAuthApi.create_user_action_challenge(
|
|
167
|
+
self._http,
|
|
168
|
+
user_action_http_method="POST",
|
|
169
|
+
user_action_http_path=path,
|
|
170
|
+
user_action_payload=payload,
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
def create_approval_decision_complete(self, approval_id: str, body: T.CreateApprovalDecisionRequest, signed_challenge: SignUserActionChallengeRequest) -> T.CreateApprovalDecisionResponse:
|
|
174
|
+
"""
|
|
175
|
+
Complete Create Approval Decision.
|
|
176
|
+
|
|
177
|
+
Submits the signed challenge and makes the API request.
|
|
178
|
+
|
|
179
|
+
Args:
|
|
180
|
+
approval_id: Path parameter.
|
|
181
|
+
body: Request body.
|
|
182
|
+
signed_challenge: The signed challenge from external signing.
|
|
183
|
+
|
|
184
|
+
Returns:
|
|
185
|
+
T.CreateApprovalDecisionResponse: The API response.
|
|
186
|
+
"""
|
|
187
|
+
user_action_result = BaseAuthApi.sign_user_action_challenge(
|
|
188
|
+
self._http, signed_challenge
|
|
189
|
+
)
|
|
190
|
+
user_action_token = user_action_result["userAction"]
|
|
191
|
+
|
|
192
|
+
return self._http.request_with_user_action(
|
|
193
|
+
method="POST",
|
|
194
|
+
path="/v2/policy-approvals/{approvalId}/decisions",
|
|
195
|
+
path_params={"approvalId": approval_id},
|
|
196
|
+
query_params=None,
|
|
197
|
+
body=body,
|
|
198
|
+
user_action=user_action_token,
|
|
199
|
+
)
|
|
200
|
+
|
|
201
|
+
def list_policies(self, query: Optional[T.ListPoliciesQuery] = None) -> T.ListPoliciesResponse:
|
|
202
|
+
"""
|
|
203
|
+
List Policies.
|
|
204
|
+
|
|
205
|
+
Retrieve the list of policies on your organization.
|
|
206
|
+
|
|
207
|
+
Args:
|
|
208
|
+
query: Query parameters.
|
|
209
|
+
|
|
210
|
+
Returns:
|
|
211
|
+
T.ListPoliciesResponse: The API response.
|
|
212
|
+
"""
|
|
213
|
+
return self._http.request(
|
|
214
|
+
method="GET",
|
|
215
|
+
path="/v2/policies",
|
|
216
|
+
path_params={},
|
|
217
|
+
query_params=query,
|
|
218
|
+
body=None,
|
|
219
|
+
requires_signature=False,
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
def create_policy_init(self, body: dict[str, Any]) -> UserActionChallengeResponse:
|
|
223
|
+
"""
|
|
224
|
+
Initialize Create Policy.
|
|
225
|
+
|
|
226
|
+
Creates a user action challenge for external signing.
|
|
227
|
+
|
|
228
|
+
Args:
|
|
229
|
+
body: Request body.
|
|
230
|
+
|
|
231
|
+
Returns:
|
|
232
|
+
UserActionChallengeResponse: The challenge to sign externally.
|
|
233
|
+
"""
|
|
234
|
+
path = "/v2/policies"
|
|
235
|
+
payload = json.dumps(body, separators=(",", ":")) if body else ""
|
|
236
|
+
|
|
237
|
+
return BaseAuthApi.create_user_action_challenge(
|
|
238
|
+
self._http,
|
|
239
|
+
user_action_http_method="POST",
|
|
240
|
+
user_action_http_path=path,
|
|
241
|
+
user_action_payload=payload,
|
|
242
|
+
)
|
|
243
|
+
|
|
244
|
+
def create_policy_complete(self, body: dict[str, Any], signed_challenge: SignUserActionChallengeRequest) -> TypedDict:
|
|
245
|
+
"""
|
|
246
|
+
Complete Create Policy.
|
|
247
|
+
|
|
248
|
+
Submits the signed challenge and makes the API request.
|
|
249
|
+
|
|
250
|
+
Args:
|
|
251
|
+
body: Request body.
|
|
252
|
+
signed_challenge: The signed challenge from external signing.
|
|
253
|
+
|
|
254
|
+
Returns:
|
|
255
|
+
TypedDict: The API response.
|
|
256
|
+
"""
|
|
257
|
+
user_action_result = BaseAuthApi.sign_user_action_challenge(
|
|
258
|
+
self._http, signed_challenge
|
|
259
|
+
)
|
|
260
|
+
user_action_token = user_action_result["userAction"]
|
|
261
|
+
|
|
262
|
+
return self._http.request_with_user_action(
|
|
263
|
+
method="POST",
|
|
264
|
+
path="/v2/policies",
|
|
265
|
+
path_params={},
|
|
266
|
+
query_params=None,
|
|
267
|
+
body=body,
|
|
268
|
+
user_action=user_action_token,
|
|
269
|
+
)
|
|
270
|
+
|
|
271
|
+
def get_approval(self, approval_id: str) -> T.GetApprovalResponse:
|
|
272
|
+
"""
|
|
273
|
+
Get Approval.
|
|
274
|
+
|
|
275
|
+
Retrieve information about a specific approval request.
|
|
276
|
+
|
|
277
|
+
Args:
|
|
278
|
+
approval_id: Path parameter.
|
|
279
|
+
|
|
280
|
+
Returns:
|
|
281
|
+
T.GetApprovalResponse: The API response.
|
|
282
|
+
"""
|
|
283
|
+
return self._http.request(
|
|
284
|
+
method="GET",
|
|
285
|
+
path="/v2/policy-approvals/{approvalId}",
|
|
286
|
+
path_params={"approvalId": approval_id},
|
|
287
|
+
query_params=None,
|
|
288
|
+
body=None,
|
|
289
|
+
requires_signature=False,
|
|
290
|
+
)
|
|
291
|
+
|
|
292
|
+
def list_approvals(self, query: Optional[T.ListApprovalsQuery] = None) -> T.ListApprovalsResponse:
|
|
293
|
+
"""
|
|
294
|
+
List Approvals.
|
|
295
|
+
|
|
296
|
+
Retrieve the list of pending approval requests.
|
|
297
|
+
|
|
298
|
+
Args:
|
|
299
|
+
query: Query parameters.
|
|
300
|
+
|
|
301
|
+
Returns:
|
|
302
|
+
T.ListApprovalsResponse: The API response.
|
|
303
|
+
"""
|
|
304
|
+
return self._http.request(
|
|
305
|
+
method="GET",
|
|
306
|
+
path="/v2/policy-approvals",
|
|
307
|
+
path_params={},
|
|
308
|
+
query_params=query,
|
|
309
|
+
body=None,
|
|
310
|
+
requires_signature=False,
|
|
311
|
+
)
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"""Types for the policies domain."""
|
|
2
|
+
|
|
3
|
+
from typing import Any, Literal, NotRequired, Optional, TypedDict, Union
|
|
4
|
+
|
|
5
|
+
class GetPolicyResponse(TypedDict, total=False):
|
|
6
|
+
"""getPolicy response."""
|
|
7
|
+
|
|
8
|
+
pending_change_request: NotRequired[TypedDict]
|
|
9
|
+
|
|
10
|
+
class CreateApprovalDecisionRequest(TypedDict, total=False):
|
|
11
|
+
"""createApprovalDecision request body."""
|
|
12
|
+
|
|
13
|
+
value: Literal["Approved", "Denied"]
|
|
14
|
+
reason: NotRequired[str]
|
|
15
|
+
|
|
16
|
+
class CreateApprovalDecisionResponse(TypedDict, total=False):
|
|
17
|
+
"""createApprovalDecision response."""
|
|
18
|
+
|
|
19
|
+
id: str
|
|
20
|
+
initiator_id: str
|
|
21
|
+
activity: TypedDict
|
|
22
|
+
status: Literal["Pending", "Approved", "Denied", "Expired"]
|
|
23
|
+
expiration_date: NotRequired[str]
|
|
24
|
+
date_created: NotRequired[str]
|
|
25
|
+
date_updated: str
|
|
26
|
+
date_resolved: NotRequired[str]
|
|
27
|
+
policy_evaluations: list[TypedDict]
|
|
28
|
+
decisions: list[TypedDict]
|
|
29
|
+
|
|
30
|
+
class ListPoliciesResponse(TypedDict, total=False):
|
|
31
|
+
"""listPolicies response."""
|
|
32
|
+
|
|
33
|
+
items: list[TypedDict]
|
|
34
|
+
next_page_token: NotRequired[str]
|
|
35
|
+
|
|
36
|
+
class ListPoliciesQuery(TypedDict, total=False):
|
|
37
|
+
"""listPolicies query parameters."""
|
|
38
|
+
|
|
39
|
+
limit: NotRequired[str]
|
|
40
|
+
pagination_token: NotRequired[str]
|
|
41
|
+
status: NotRequired[Literal["Active", "Archived"]]
|
|
42
|
+
|
|
43
|
+
class GetApprovalResponse(TypedDict, total=False):
|
|
44
|
+
"""getApproval response."""
|
|
45
|
+
|
|
46
|
+
id: str
|
|
47
|
+
initiator_id: str
|
|
48
|
+
activity: TypedDict
|
|
49
|
+
status: Literal["Pending", "Approved", "Denied", "Expired"]
|
|
50
|
+
expiration_date: NotRequired[str]
|
|
51
|
+
date_created: NotRequired[str]
|
|
52
|
+
date_updated: str
|
|
53
|
+
date_resolved: NotRequired[str]
|
|
54
|
+
policy_evaluations: list[TypedDict]
|
|
55
|
+
decisions: list[TypedDict]
|
|
56
|
+
|
|
57
|
+
class ListApprovalsResponse(TypedDict, total=False):
|
|
58
|
+
"""listApprovals response."""
|
|
59
|
+
|
|
60
|
+
items: list[TypedDict]
|
|
61
|
+
next_page_token: NotRequired[str]
|
|
62
|
+
|
|
63
|
+
class ListApprovalsQuery(TypedDict, total=False):
|
|
64
|
+
"""listApprovals query parameters."""
|
|
65
|
+
|
|
66
|
+
limit: NotRequired[str]
|
|
67
|
+
pagination_token: NotRequired[str]
|
|
68
|
+
status: NotRequired[Literal["Pending", "Approved", "Denied", "Expired"]]
|
|
69
|
+
initiator_id: NotRequired[str]
|
|
70
|
+
approver_id: NotRequired[str]
|