workos 1.13.0__py3-none-any.whl → 5.38.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.
- workos/__about__.py +1 -1
- workos/__init__.py +3 -7
- workos/_base_client.py +138 -0
- workos/_client_configuration.py +10 -0
- workos/api_keys.py +53 -0
- workos/async_client.py +144 -0
- workos/audit_logs.py +125 -0
- workos/client.py +105 -20
- workos/directory_sync.py +369 -146
- workos/events.py +111 -0
- workos/exceptions.py +53 -26
- workos/fga.py +649 -0
- workos/mfa.py +152 -116
- workos/organization_domains.py +179 -0
- workos/organizations.py +401 -86
- workos/passwordless.py +67 -43
- workos/pipes.py +93 -0
- workos/portal.py +51 -28
- workos/session.py +337 -0
- workos/sso.py +305 -149
- workos/types/__init__.py +4 -0
- workos/types/api_keys/__init__.py +1 -0
- workos/types/api_keys/api_keys.py +20 -0
- workos/types/audit_logs/__init__.py +6 -0
- workos/types/audit_logs/audit_log_event.py +16 -0
- workos/types/audit_logs/audit_log_event_actor.py +12 -0
- workos/types/audit_logs/audit_log_event_context.py +8 -0
- workos/types/audit_logs/audit_log_event_target.py +12 -0
- workos/types/audit_logs/audit_log_export.py +18 -0
- workos/types/audit_logs/audit_log_metadata.py +4 -0
- workos/types/directory_sync/__init__.py +5 -0
- workos/types/directory_sync/directory.py +31 -0
- workos/types/directory_sync/directory_group.py +16 -0
- workos/types/directory_sync/directory_state.py +28 -0
- workos/types/directory_sync/directory_type.py +24 -0
- workos/types/directory_sync/directory_user.py +50 -0
- workos/types/directory_sync/list_filters.py +21 -0
- workos/types/events/__init__.py +13 -0
- workos/types/events/authentication_payload.py +70 -0
- workos/types/events/connection_payload_with_legacy_fields.py +5 -0
- workos/types/events/directory_group_membership_payload.py +9 -0
- workos/types/events/directory_group_with_previous_attributes.py +6 -0
- workos/types/events/directory_payload.py +16 -0
- workos/types/events/directory_payload_with_legacy_fields.py +29 -0
- workos/types/events/directory_user_with_previous_attributes.py +6 -0
- workos/types/events/event.py +324 -0
- workos/types/events/event_model.py +103 -0
- workos/types/events/event_type.py +59 -0
- workos/types/events/list_filters.py +10 -0
- workos/types/events/organization_domain_verification_failed_payload.py +14 -0
- workos/types/events/previous_attributes.py +3 -0
- workos/types/events/session_payload.py +27 -0
- workos/types/feature_flags/__init__.py +3 -0
- workos/types/feature_flags/feature_flag.py +12 -0
- workos/types/feature_flags/list_filters.py +5 -0
- workos/types/fga/__init__.py +5 -0
- workos/types/fga/authorization_resource_types.py +9 -0
- workos/types/fga/authorization_resources.py +10 -0
- workos/types/fga/check.py +51 -0
- workos/types/fga/list_filters.py +24 -0
- workos/types/fga/warnings.py +33 -0
- workos/types/fga/warrant.py +49 -0
- workos/types/list_resource.py +198 -0
- workos/types/metadata.py +4 -0
- workos/types/mfa/__init__.py +5 -0
- workos/types/mfa/authentication_challenge.py +14 -0
- workos/types/mfa/authentication_challenge_verification_response.py +9 -0
- workos/types/mfa/authentication_factor.py +70 -0
- workos/types/mfa/authentication_factor_totp_and_challenge_response.py +10 -0
- workos/types/mfa/enroll_authentication_factor_type.py +8 -0
- workos/types/organization_domains/__init__.py +1 -0
- workos/types/organization_domains/organization_domain.py +18 -0
- workos/types/organizations/__init__.py +6 -0
- workos/types/organizations/domain_data_input.py +7 -0
- workos/types/organizations/list_filters.py +6 -0
- workos/types/organizations/organization.py +13 -0
- workos/types/organizations/organization_common.py +12 -0
- workos/types/passwordless/__init__.py +2 -0
- workos/types/passwordless/passwordless_session.py +12 -0
- workos/types/passwordless/passwordless_session_type.py +3 -0
- workos/types/pipes/__init__.py +6 -0
- workos/types/pipes/pipes.py +34 -0
- workos/types/portal/__init__.py +2 -0
- workos/types/portal/portal_link.py +7 -0
- workos/types/portal/portal_link_intent.py +11 -0
- workos/types/portal/portal_link_intent_options.py +9 -0
- workos/types/roles/__init__.py +0 -0
- workos/types/roles/role.py +27 -0
- workos/types/sso/__init__.py +4 -0
- workos/types/sso/connection.py +70 -0
- workos/types/sso/connection_domain.py +8 -0
- workos/types/sso/profile.py +35 -0
- workos/types/sso/sso_provider_type.py +10 -0
- workos/types/user_management/__init__.py +12 -0
- workos/types/user_management/authenticate_with_common.py +66 -0
- workos/types/user_management/authentication_response.py +53 -0
- workos/types/user_management/email_verification.py +18 -0
- workos/types/user_management/impersonator.py +8 -0
- workos/types/user_management/invitation.py +26 -0
- workos/types/user_management/list_filters.py +29 -0
- workos/types/user_management/magic_auth.py +18 -0
- workos/types/user_management/oauth_tokens.py +21 -0
- workos/types/user_management/organization_membership.py +25 -0
- workos/types/user_management/password_hash_type.py +4 -0
- workos/types/user_management/password_reset.py +18 -0
- workos/types/user_management/screen_hint.py +3 -0
- workos/types/user_management/session.py +79 -0
- workos/types/user_management/user.py +22 -0
- workos/types/user_management/user_management_provider_type.py +11 -0
- workos/types/vault/__init__.py +2 -0
- workos/types/vault/key.py +25 -0
- workos/types/vault/object.py +38 -0
- workos/types/webhooks/__init__.py +0 -0
- workos/types/webhooks/webhook.py +330 -0
- workos/types/webhooks/webhook_model.py +14 -0
- workos/types/webhooks/webhook_payload.py +4 -0
- workos/types/widgets/__init__.py +2 -0
- workos/types/widgets/widget_scope.py +4 -0
- workos/types/widgets/widget_token_response.py +7 -0
- workos/types/workos_model.py +26 -0
- workos/typing/__init__.py +1 -0
- workos/typing/literals.py +32 -0
- workos/typing/sync_or_async.py +5 -0
- workos/typing/untyped_literal.py +37 -0
- workos/typing/webhooks.py +18 -0
- workos/user_management.py +2400 -0
- workos/utils/_base_http_client.py +252 -0
- workos/utils/crypto_provider.py +39 -0
- workos/utils/http_client.py +214 -0
- workos/utils/pagination_order.py +4 -0
- workos/utils/request_helper.py +27 -0
- workos/vault.py +544 -0
- workos/webhooks.py +96 -39
- workos/widgets.py +55 -0
- {workos-1.13.0.dist-info → workos-5.38.0.dist-info}/LICENSE +1 -1
- {workos-1.13.0.dist-info → workos-5.38.0.dist-info}/METADATA +47 -22
- workos-5.38.0.dist-info/RECORD +141 -0
- {workos-1.13.0.dist-info → workos-5.38.0.dist-info}/WHEEL +1 -1
- workos/audit_trail.py +0 -179
- workos/resources/base.py +0 -36
- workos/resources/directory_sync.py +0 -28
- workos/resources/event.py +0 -42
- workos/resources/event_action.py +0 -11
- workos/resources/mfa.py +0 -32
- workos/resources/sso.py +0 -53
- workos/utils/connection_types.py +0 -35
- workos/utils/pagiantion_order.py +0 -6
- workos/utils/request.py +0 -100
- workos/utils/validation.py +0 -60
- workos-1.13.0.dist-info/RECORD +0 -29
- /workos/{resources/__init__.py → py.typed} +0 -0
- {workos-1.13.0.dist-info → workos-5.38.0.dist-info}/top_level.txt +0 -0
workos/directory_sync.py
CHANGED
|
@@ -1,212 +1,435 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
from workos.
|
|
4
|
-
|
|
1
|
+
from typing import Optional, Protocol
|
|
2
|
+
|
|
3
|
+
from workos.types.directory_sync.list_filters import (
|
|
4
|
+
DirectoryGroupListFilters,
|
|
5
|
+
DirectoryListFilters,
|
|
6
|
+
DirectoryUserListFilters,
|
|
7
|
+
)
|
|
8
|
+
from workos.typing.sync_or_async import SyncOrAsync
|
|
9
|
+
from workos.utils.http_client import AsyncHTTPClient, SyncHTTPClient
|
|
10
|
+
from workos.utils.pagination_order import PaginationOrder
|
|
11
|
+
from workos.utils.request_helper import (
|
|
12
|
+
DEFAULT_LIST_RESPONSE_LIMIT,
|
|
5
13
|
REQUEST_METHOD_DELETE,
|
|
6
14
|
REQUEST_METHOD_GET,
|
|
7
15
|
)
|
|
8
|
-
from workos.
|
|
9
|
-
|
|
16
|
+
from workos.types.directory_sync import (
|
|
17
|
+
DirectoryGroup,
|
|
18
|
+
Directory,
|
|
19
|
+
DirectoryUserWithGroups,
|
|
20
|
+
)
|
|
21
|
+
from workos.types.list_resource import ListMetadata, ListPage, WorkOSListResource
|
|
10
22
|
|
|
11
|
-
|
|
23
|
+
DirectoryUsersListResource = WorkOSListResource[
|
|
24
|
+
DirectoryUserWithGroups, DirectoryUserListFilters, ListMetadata
|
|
25
|
+
]
|
|
12
26
|
|
|
27
|
+
DirectoryGroupsListResource = WorkOSListResource[
|
|
28
|
+
DirectoryGroup, DirectoryGroupListFilters, ListMetadata
|
|
29
|
+
]
|
|
13
30
|
|
|
14
|
-
|
|
15
|
-
|
|
31
|
+
DirectoriesListResource = WorkOSListResource[
|
|
32
|
+
Directory, DirectoryListFilters, ListMetadata
|
|
33
|
+
]
|
|
16
34
|
|
|
17
|
-
@validate_settings(DIRECTORY_SYNC_MODULE)
|
|
18
|
-
def __init__(self):
|
|
19
|
-
pass
|
|
20
35
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if not getattr(self, "_request_helper", None):
|
|
24
|
-
self._request_helper = RequestHelper()
|
|
25
|
-
return self._request_helper
|
|
36
|
+
class DirectorySyncModule(Protocol):
|
|
37
|
+
"""Offers methods through the WorkOS Directory Sync service."""
|
|
26
38
|
|
|
27
39
|
def list_users(
|
|
28
40
|
self,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
41
|
+
*,
|
|
42
|
+
directory_id: Optional[str] = None,
|
|
43
|
+
group_id: Optional[str] = None,
|
|
44
|
+
limit: int = DEFAULT_LIST_RESPONSE_LIMIT,
|
|
45
|
+
before: Optional[str] = None,
|
|
46
|
+
after: Optional[str] = None,
|
|
47
|
+
order: PaginationOrder = "desc",
|
|
48
|
+
) -> SyncOrAsync[DirectoryUsersListResource]:
|
|
36
49
|
"""Gets a list of provisioned Users for a Directory.
|
|
37
50
|
|
|
38
|
-
Note, either '
|
|
51
|
+
Note, either 'directory_id' or 'group_id' must be provided.
|
|
52
|
+
|
|
53
|
+
Kwargs:
|
|
54
|
+
directory_id (str): Directory unique identifier. (Optional)
|
|
55
|
+
group_id (str): Directory Group unique identifier. (Optional)
|
|
56
|
+
limit (int): Maximum number of records to return. (Optional)
|
|
57
|
+
before (str): Pagination cursor to receive records before a provided Directory ID. (Optional)
|
|
58
|
+
after (str): Pagination cursor to receive records after a provided Directory ID. (Optional)
|
|
59
|
+
order (Literal["asc","desc"]): Sort records in either ascending or descending (default) order by created_at timestamp. (Optional)
|
|
60
|
+
|
|
61
|
+
Returns:
|
|
62
|
+
DirectoryUsersListResource: Directory Users response from WorkOS.
|
|
63
|
+
"""
|
|
64
|
+
...
|
|
65
|
+
|
|
66
|
+
def list_groups(
|
|
67
|
+
self,
|
|
68
|
+
*,
|
|
69
|
+
directory_id: Optional[str] = None,
|
|
70
|
+
user_id: Optional[str] = None,
|
|
71
|
+
limit: int = DEFAULT_LIST_RESPONSE_LIMIT,
|
|
72
|
+
before: Optional[str] = None,
|
|
73
|
+
after: Optional[str] = None,
|
|
74
|
+
order: PaginationOrder = "desc",
|
|
75
|
+
) -> SyncOrAsync[DirectoryGroupsListResource]:
|
|
76
|
+
"""Gets a list of provisioned Groups for a Directory .
|
|
77
|
+
|
|
78
|
+
Note, either 'directory_id' or 'user_id' must be provided.
|
|
79
|
+
|
|
80
|
+
Kwargs:
|
|
81
|
+
directory_id (str): Directory unique identifier. (Optional)
|
|
82
|
+
user_id (str): Directory User unique identifier. (Optional)
|
|
83
|
+
limit (int): Maximum number of records to return. (Optional)
|
|
84
|
+
before (str): Pagination cursor to receive records before a provided Directory ID. (Optional)
|
|
85
|
+
after (str): Pagination cursor to receive records after a provided Directory ID. (Optional)
|
|
86
|
+
order (Literal["asc","desc"]): Sort records in either ascending or descending (default) order by created_at timestamp. (Optional)
|
|
87
|
+
|
|
88
|
+
Returns:
|
|
89
|
+
DirectoryGroupsListResource: Directory Groups response from WorkOS.
|
|
90
|
+
"""
|
|
91
|
+
...
|
|
92
|
+
|
|
93
|
+
def list_directories(
|
|
94
|
+
self,
|
|
95
|
+
*,
|
|
96
|
+
search: Optional[str] = None,
|
|
97
|
+
limit: int = DEFAULT_LIST_RESPONSE_LIMIT,
|
|
98
|
+
before: Optional[str] = None,
|
|
99
|
+
after: Optional[str] = None,
|
|
100
|
+
organization_id: Optional[str] = None,
|
|
101
|
+
order: PaginationOrder = "desc",
|
|
102
|
+
) -> SyncOrAsync[DirectoriesListResource]:
|
|
103
|
+
"""Gets details for existing Directories.
|
|
104
|
+
|
|
105
|
+
Kwargs:
|
|
106
|
+
organization_id: ID of an Organization (Optional)
|
|
107
|
+
search (str): Searchable text for a Directory. (Optional)
|
|
108
|
+
limit (int): Maximum number of records to return. (Optional)
|
|
109
|
+
before (str): Pagination cursor to receive records before a provided Directory ID. (Optional)
|
|
110
|
+
after (str): Pagination cursor to receive records after a provided Directory ID. (Optional)
|
|
111
|
+
order (Literal["asc","desc"]): Sort records in either ascending or descending (default) order by created_at timestamp. (Optional)
|
|
112
|
+
|
|
113
|
+
Returns:
|
|
114
|
+
DirectoriesListResource: Directories response from WorkOS.
|
|
115
|
+
"""
|
|
116
|
+
...
|
|
117
|
+
|
|
118
|
+
def get_user(self, user_id: str) -> SyncOrAsync[DirectoryUserWithGroups]:
|
|
119
|
+
"""Gets details for a single provisioned Directory User.
|
|
39
120
|
|
|
40
121
|
Args:
|
|
41
|
-
|
|
42
|
-
group (str): Directory Group unique identifier.
|
|
43
|
-
limit (int): Maximum number of records to return.
|
|
44
|
-
before (str): Pagination cursor to receive records before a provided Directory ID.
|
|
45
|
-
after (str): Pagination cursor to receive records after a provided Directory ID.
|
|
46
|
-
order (Order): Sort records in either ascending or descending order by created_at timestamp.
|
|
122
|
+
user_id (str): Directory User unique identifier.
|
|
47
123
|
|
|
48
124
|
Returns:
|
|
49
|
-
|
|
125
|
+
DirectoryUserWithGroups: Directory User response from WorkOS.
|
|
50
126
|
"""
|
|
51
|
-
|
|
127
|
+
...
|
|
128
|
+
|
|
129
|
+
def get_group(self, group_id: str) -> SyncOrAsync[DirectoryGroup]:
|
|
130
|
+
"""Gets details for a single provisioned Directory Group.
|
|
131
|
+
|
|
132
|
+
Args:
|
|
133
|
+
group_id (str): Directory Group unique identifier.
|
|
134
|
+
|
|
135
|
+
Returns:
|
|
136
|
+
DirectoryGroup: Directory Group response from WorkOS.
|
|
137
|
+
"""
|
|
138
|
+
...
|
|
139
|
+
|
|
140
|
+
def get_directory(self, directory_id: str) -> SyncOrAsync[Directory]:
|
|
141
|
+
"""Gets details for a single Directory
|
|
142
|
+
|
|
143
|
+
Args:
|
|
144
|
+
directory_id (str): Directory unique identifier.
|
|
145
|
+
|
|
146
|
+
Returns:
|
|
147
|
+
Directory: Directory response from WorkOS
|
|
148
|
+
"""
|
|
149
|
+
...
|
|
150
|
+
|
|
151
|
+
def delete_directory(self, directory_id: str) -> SyncOrAsync[None]:
|
|
152
|
+
"""Delete one existing Directory.
|
|
153
|
+
|
|
154
|
+
Args:
|
|
155
|
+
directory_id (str): Directory unique identifier.
|
|
156
|
+
|
|
157
|
+
Returns:
|
|
158
|
+
None
|
|
159
|
+
"""
|
|
160
|
+
...
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
class DirectorySync(DirectorySyncModule):
|
|
164
|
+
_http_client: SyncHTTPClient
|
|
165
|
+
|
|
166
|
+
def __init__(self, http_client: SyncHTTPClient) -> None:
|
|
167
|
+
self._http_client = http_client
|
|
168
|
+
|
|
169
|
+
def list_users(
|
|
170
|
+
self,
|
|
171
|
+
*,
|
|
172
|
+
directory_id: Optional[str] = None,
|
|
173
|
+
group_id: Optional[str] = None,
|
|
174
|
+
limit: int = DEFAULT_LIST_RESPONSE_LIMIT,
|
|
175
|
+
before: Optional[str] = None,
|
|
176
|
+
after: Optional[str] = None,
|
|
177
|
+
order: PaginationOrder = "desc",
|
|
178
|
+
) -> DirectoryUsersListResource:
|
|
179
|
+
|
|
180
|
+
list_params: DirectoryUserListFilters = {
|
|
52
181
|
"limit": limit,
|
|
53
182
|
"before": before,
|
|
54
183
|
"after": after,
|
|
55
184
|
"order": order,
|
|
56
185
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
params["order"] = str(order.value)
|
|
65
|
-
return self.request_helper.request(
|
|
186
|
+
|
|
187
|
+
if group_id is not None:
|
|
188
|
+
list_params["group"] = group_id
|
|
189
|
+
if directory_id is not None:
|
|
190
|
+
list_params["directory"] = directory_id
|
|
191
|
+
|
|
192
|
+
response = self._http_client.request(
|
|
66
193
|
"directory_users",
|
|
67
194
|
method=REQUEST_METHOD_GET,
|
|
68
|
-
params=
|
|
69
|
-
|
|
195
|
+
params=list_params,
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
return WorkOSListResource(
|
|
199
|
+
list_method=self.list_users,
|
|
200
|
+
list_args=list_params,
|
|
201
|
+
**ListPage[DirectoryUserWithGroups](**response).model_dump(),
|
|
70
202
|
)
|
|
71
203
|
|
|
72
204
|
def list_groups(
|
|
73
205
|
self,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
206
|
+
*,
|
|
207
|
+
directory_id: Optional[str] = None,
|
|
208
|
+
user_id: Optional[str] = None,
|
|
209
|
+
limit: int = DEFAULT_LIST_RESPONSE_LIMIT,
|
|
210
|
+
before: Optional[str] = None,
|
|
211
|
+
after: Optional[str] = None,
|
|
212
|
+
order: PaginationOrder = "desc",
|
|
213
|
+
) -> DirectoryGroupsListResource:
|
|
214
|
+
list_params: DirectoryGroupListFilters = {
|
|
215
|
+
"limit": limit,
|
|
216
|
+
"before": before,
|
|
217
|
+
"after": after,
|
|
218
|
+
"order": order,
|
|
219
|
+
}
|
|
84
220
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
before (str): Pagination cursor to receive records before a provided Directory ID.
|
|
90
|
-
after (str): Pagination cursor to receive records after a provided Directory ID.
|
|
91
|
-
order (Order): Sort records in either ascending or descending order by created_at timestamp.
|
|
221
|
+
if user_id is not None:
|
|
222
|
+
list_params["user"] = user_id
|
|
223
|
+
if directory_id is not None:
|
|
224
|
+
list_params["directory"] = directory_id
|
|
92
225
|
|
|
93
|
-
|
|
94
|
-
dict: Directory Groups response from WorkOS.
|
|
95
|
-
"""
|
|
96
|
-
params = {"limit": limit, "before": before, "after": after, "order": order}
|
|
97
|
-
if user is not None:
|
|
98
|
-
params["user"] = user
|
|
99
|
-
if directory is not None:
|
|
100
|
-
params["directory"] = directory
|
|
101
|
-
if order is not None:
|
|
102
|
-
if not isinstance(order, Order):
|
|
103
|
-
raise ValueError("'order' must be of asc or desc order")
|
|
104
|
-
params["order"] = str(order.value)
|
|
105
|
-
return self.request_helper.request(
|
|
226
|
+
response = self._http_client.request(
|
|
106
227
|
"directory_groups",
|
|
107
228
|
method=REQUEST_METHOD_GET,
|
|
108
|
-
params=
|
|
109
|
-
token=workos.api_key,
|
|
229
|
+
params=list_params,
|
|
110
230
|
)
|
|
111
231
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
232
|
+
return WorkOSListResource[
|
|
233
|
+
DirectoryGroup, DirectoryGroupListFilters, ListMetadata
|
|
234
|
+
](
|
|
235
|
+
list_method=self.list_groups,
|
|
236
|
+
list_args=list_params,
|
|
237
|
+
**ListPage[DirectoryGroup](**response).model_dump(),
|
|
238
|
+
)
|
|
117
239
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
return self.request_helper.request(
|
|
122
|
-
"directory_users/{user}".format(user=user),
|
|
240
|
+
def get_user(self, user_id: str) -> DirectoryUserWithGroups:
|
|
241
|
+
response = self._http_client.request(
|
|
242
|
+
"directory_users/{user}".format(user=user_id),
|
|
123
243
|
method=REQUEST_METHOD_GET,
|
|
124
|
-
token=workos.api_key,
|
|
125
244
|
)
|
|
126
245
|
|
|
127
|
-
|
|
128
|
-
"""Gets details for a single provisioned Directory Group.
|
|
246
|
+
return DirectoryUserWithGroups.model_validate(response)
|
|
129
247
|
|
|
130
|
-
|
|
131
|
-
|
|
248
|
+
def get_group(self, group_id: str) -> DirectoryGroup:
|
|
249
|
+
response = self._http_client.request(
|
|
250
|
+
"directory_groups/{group}".format(group=group_id),
|
|
251
|
+
method=REQUEST_METHOD_GET,
|
|
252
|
+
)
|
|
253
|
+
return DirectoryGroup.model_validate(response)
|
|
132
254
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
response = self.request_helper.request(
|
|
137
|
-
"directory_groups/{group}".format(group=group),
|
|
255
|
+
def get_directory(self, directory_id: str) -> Directory:
|
|
256
|
+
response = self._http_client.request(
|
|
257
|
+
"directories/{directory}".format(directory=directory_id),
|
|
138
258
|
method=REQUEST_METHOD_GET,
|
|
139
|
-
token=workos.api_key,
|
|
140
259
|
)
|
|
141
260
|
|
|
142
|
-
return
|
|
261
|
+
return Directory.model_validate(response)
|
|
143
262
|
|
|
144
263
|
def list_directories(
|
|
145
264
|
self,
|
|
146
|
-
|
|
147
|
-
search=None,
|
|
148
|
-
limit=
|
|
149
|
-
before=None,
|
|
150
|
-
after=None,
|
|
151
|
-
|
|
152
|
-
order=
|
|
153
|
-
):
|
|
154
|
-
|
|
265
|
+
*,
|
|
266
|
+
search: Optional[str] = None,
|
|
267
|
+
limit: int = DEFAULT_LIST_RESPONSE_LIMIT,
|
|
268
|
+
before: Optional[str] = None,
|
|
269
|
+
after: Optional[str] = None,
|
|
270
|
+
organization_id: Optional[str] = None,
|
|
271
|
+
order: PaginationOrder = "desc",
|
|
272
|
+
) -> DirectoriesListResource:
|
|
273
|
+
list_params: DirectoryListFilters = {
|
|
274
|
+
"limit": limit,
|
|
275
|
+
"before": before,
|
|
276
|
+
"after": after,
|
|
277
|
+
"order": order,
|
|
278
|
+
"organization_id": organization_id,
|
|
279
|
+
"search": search,
|
|
280
|
+
}
|
|
155
281
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
282
|
+
response = self._http_client.request(
|
|
283
|
+
"directories",
|
|
284
|
+
method=REQUEST_METHOD_GET,
|
|
285
|
+
params=list_params,
|
|
286
|
+
)
|
|
287
|
+
return WorkOSListResource[Directory, DirectoryListFilters, ListMetadata](
|
|
288
|
+
list_method=self.list_directories,
|
|
289
|
+
list_args=list_params,
|
|
290
|
+
**ListPage[Directory](**response).model_dump(),
|
|
291
|
+
)
|
|
164
292
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
293
|
+
def delete_directory(self, directory_id: str) -> None:
|
|
294
|
+
self._http_client.request(
|
|
295
|
+
"directories/{directory}".format(directory=directory_id),
|
|
296
|
+
method=REQUEST_METHOD_DELETE,
|
|
297
|
+
)
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
class AsyncDirectorySync(DirectorySyncModule):
|
|
301
|
+
"""Offers methods through the WorkOS Directory Sync service."""
|
|
302
|
+
|
|
303
|
+
_http_client: AsyncHTTPClient
|
|
304
|
+
|
|
305
|
+
def __init__(self, http_client: AsyncHTTPClient):
|
|
306
|
+
self._http_client = http_client
|
|
307
|
+
|
|
308
|
+
async def list_users(
|
|
309
|
+
self,
|
|
310
|
+
*,
|
|
311
|
+
directory_id: Optional[str] = None,
|
|
312
|
+
group_id: Optional[str] = None,
|
|
313
|
+
limit: int = DEFAULT_LIST_RESPONSE_LIMIT,
|
|
314
|
+
before: Optional[str] = None,
|
|
315
|
+
after: Optional[str] = None,
|
|
316
|
+
order: PaginationOrder = "desc",
|
|
317
|
+
) -> DirectoryUsersListResource:
|
|
318
|
+
|
|
319
|
+
list_params: DirectoryUserListFilters = {
|
|
172
320
|
"limit": limit,
|
|
173
321
|
"before": before,
|
|
174
322
|
"after": after,
|
|
175
323
|
"order": order,
|
|
176
324
|
}
|
|
177
|
-
|
|
178
|
-
|
|
325
|
+
|
|
326
|
+
if group_id is not None:
|
|
327
|
+
list_params["group"] = group_id
|
|
328
|
+
if directory_id is not None:
|
|
329
|
+
list_params["directory"] = directory_id
|
|
330
|
+
|
|
331
|
+
response = await self._http_client.request(
|
|
332
|
+
"directory_users",
|
|
179
333
|
method=REQUEST_METHOD_GET,
|
|
180
|
-
params=
|
|
181
|
-
token=workos.api_key,
|
|
334
|
+
params=list_params,
|
|
182
335
|
)
|
|
183
336
|
|
|
184
|
-
|
|
185
|
-
|
|
337
|
+
return WorkOSListResource(
|
|
338
|
+
list_method=self.list_users,
|
|
339
|
+
list_args=list_params,
|
|
340
|
+
**ListPage[DirectoryUserWithGroups](**response).model_dump(),
|
|
341
|
+
)
|
|
186
342
|
|
|
187
|
-
|
|
188
|
-
|
|
343
|
+
async def list_groups(
|
|
344
|
+
self,
|
|
345
|
+
*,
|
|
346
|
+
directory_id: Optional[str] = None,
|
|
347
|
+
user_id: Optional[str] = None,
|
|
348
|
+
limit: int = DEFAULT_LIST_RESPONSE_LIMIT,
|
|
349
|
+
before: Optional[str] = None,
|
|
350
|
+
after: Optional[str] = None,
|
|
351
|
+
order: PaginationOrder = "desc",
|
|
352
|
+
) -> DirectoryGroupsListResource:
|
|
353
|
+
list_params: DirectoryGroupListFilters = {
|
|
354
|
+
"limit": limit,
|
|
355
|
+
"before": before,
|
|
356
|
+
"after": after,
|
|
357
|
+
"order": order,
|
|
358
|
+
}
|
|
359
|
+
if user_id is not None:
|
|
360
|
+
list_params["user"] = user_id
|
|
361
|
+
if directory_id is not None:
|
|
362
|
+
list_params["directory"] = directory_id
|
|
189
363
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
"""
|
|
193
|
-
return self.request_helper.request(
|
|
194
|
-
"directories/{directory_id}".format(directory_id=directory_id),
|
|
364
|
+
response = await self._http_client.request(
|
|
365
|
+
"directory_groups",
|
|
195
366
|
method=REQUEST_METHOD_GET,
|
|
196
|
-
|
|
367
|
+
params=list_params,
|
|
197
368
|
)
|
|
198
369
|
|
|
199
|
-
|
|
200
|
-
|
|
370
|
+
return WorkOSListResource[
|
|
371
|
+
DirectoryGroup, DirectoryGroupListFilters, ListMetadata
|
|
372
|
+
](
|
|
373
|
+
list_method=self.list_groups,
|
|
374
|
+
list_args=list_params,
|
|
375
|
+
**ListPage[DirectoryGroup](**response).model_dump(),
|
|
376
|
+
)
|
|
201
377
|
|
|
202
|
-
|
|
203
|
-
|
|
378
|
+
async def get_user(self, user_id: str) -> DirectoryUserWithGroups:
|
|
379
|
+
response = await self._http_client.request(
|
|
380
|
+
"directory_users/{user}".format(user=user_id),
|
|
381
|
+
method=REQUEST_METHOD_GET,
|
|
382
|
+
)
|
|
204
383
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
"
|
|
384
|
+
return DirectoryUserWithGroups.model_validate(response)
|
|
385
|
+
|
|
386
|
+
async def get_group(self, group_id: str) -> DirectoryGroup:
|
|
387
|
+
response = await self._http_client.request(
|
|
388
|
+
"directory_groups/{group}".format(group=group_id),
|
|
389
|
+
method=REQUEST_METHOD_GET,
|
|
390
|
+
)
|
|
391
|
+
return DirectoryGroup.model_validate(response)
|
|
392
|
+
|
|
393
|
+
async def get_directory(self, directory_id: str) -> Directory:
|
|
394
|
+
response = await self._http_client.request(
|
|
395
|
+
"directories/{directory}".format(directory=directory_id),
|
|
396
|
+
method=REQUEST_METHOD_GET,
|
|
397
|
+
)
|
|
398
|
+
|
|
399
|
+
return Directory.model_validate(response)
|
|
400
|
+
|
|
401
|
+
async def list_directories(
|
|
402
|
+
self,
|
|
403
|
+
*,
|
|
404
|
+
search: Optional[str] = None,
|
|
405
|
+
limit: int = DEFAULT_LIST_RESPONSE_LIMIT,
|
|
406
|
+
before: Optional[str] = None,
|
|
407
|
+
after: Optional[str] = None,
|
|
408
|
+
organization_id: Optional[str] = None,
|
|
409
|
+
order: PaginationOrder = "desc",
|
|
410
|
+
) -> DirectoriesListResource:
|
|
411
|
+
list_params: DirectoryListFilters = {
|
|
412
|
+
"organization_id": organization_id,
|
|
413
|
+
"search": search,
|
|
414
|
+
"limit": limit,
|
|
415
|
+
"before": before,
|
|
416
|
+
"after": after,
|
|
417
|
+
"order": order,
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
response = await self._http_client.request(
|
|
421
|
+
"directories",
|
|
422
|
+
method=REQUEST_METHOD_GET,
|
|
423
|
+
params=list_params,
|
|
424
|
+
)
|
|
425
|
+
return WorkOSListResource[Directory, DirectoryListFilters, ListMetadata](
|
|
426
|
+
list_method=self.list_directories,
|
|
427
|
+
list_args=list_params,
|
|
428
|
+
**ListPage[Directory](**response).model_dump(),
|
|
429
|
+
)
|
|
430
|
+
|
|
431
|
+
async def delete_directory(self, directory_id: str) -> None:
|
|
432
|
+
await self._http_client.request(
|
|
433
|
+
"directories/{directory}".format(directory=directory_id),
|
|
210
434
|
method=REQUEST_METHOD_DELETE,
|
|
211
|
-
token=workos.api_key,
|
|
212
435
|
)
|