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.
Files changed (152) hide show
  1. workos/__about__.py +1 -1
  2. workos/__init__.py +3 -7
  3. workos/_base_client.py +138 -0
  4. workos/_client_configuration.py +10 -0
  5. workos/api_keys.py +53 -0
  6. workos/async_client.py +144 -0
  7. workos/audit_logs.py +125 -0
  8. workos/client.py +105 -20
  9. workos/directory_sync.py +369 -146
  10. workos/events.py +111 -0
  11. workos/exceptions.py +53 -26
  12. workos/fga.py +649 -0
  13. workos/mfa.py +152 -116
  14. workos/organization_domains.py +179 -0
  15. workos/organizations.py +401 -86
  16. workos/passwordless.py +67 -43
  17. workos/pipes.py +93 -0
  18. workos/portal.py +51 -28
  19. workos/session.py +337 -0
  20. workos/sso.py +305 -149
  21. workos/types/__init__.py +4 -0
  22. workos/types/api_keys/__init__.py +1 -0
  23. workos/types/api_keys/api_keys.py +20 -0
  24. workos/types/audit_logs/__init__.py +6 -0
  25. workos/types/audit_logs/audit_log_event.py +16 -0
  26. workos/types/audit_logs/audit_log_event_actor.py +12 -0
  27. workos/types/audit_logs/audit_log_event_context.py +8 -0
  28. workos/types/audit_logs/audit_log_event_target.py +12 -0
  29. workos/types/audit_logs/audit_log_export.py +18 -0
  30. workos/types/audit_logs/audit_log_metadata.py +4 -0
  31. workos/types/directory_sync/__init__.py +5 -0
  32. workos/types/directory_sync/directory.py +31 -0
  33. workos/types/directory_sync/directory_group.py +16 -0
  34. workos/types/directory_sync/directory_state.py +28 -0
  35. workos/types/directory_sync/directory_type.py +24 -0
  36. workos/types/directory_sync/directory_user.py +50 -0
  37. workos/types/directory_sync/list_filters.py +21 -0
  38. workos/types/events/__init__.py +13 -0
  39. workos/types/events/authentication_payload.py +70 -0
  40. workos/types/events/connection_payload_with_legacy_fields.py +5 -0
  41. workos/types/events/directory_group_membership_payload.py +9 -0
  42. workos/types/events/directory_group_with_previous_attributes.py +6 -0
  43. workos/types/events/directory_payload.py +16 -0
  44. workos/types/events/directory_payload_with_legacy_fields.py +29 -0
  45. workos/types/events/directory_user_with_previous_attributes.py +6 -0
  46. workos/types/events/event.py +324 -0
  47. workos/types/events/event_model.py +103 -0
  48. workos/types/events/event_type.py +59 -0
  49. workos/types/events/list_filters.py +10 -0
  50. workos/types/events/organization_domain_verification_failed_payload.py +14 -0
  51. workos/types/events/previous_attributes.py +3 -0
  52. workos/types/events/session_payload.py +27 -0
  53. workos/types/feature_flags/__init__.py +3 -0
  54. workos/types/feature_flags/feature_flag.py +12 -0
  55. workos/types/feature_flags/list_filters.py +5 -0
  56. workos/types/fga/__init__.py +5 -0
  57. workos/types/fga/authorization_resource_types.py +9 -0
  58. workos/types/fga/authorization_resources.py +10 -0
  59. workos/types/fga/check.py +51 -0
  60. workos/types/fga/list_filters.py +24 -0
  61. workos/types/fga/warnings.py +33 -0
  62. workos/types/fga/warrant.py +49 -0
  63. workos/types/list_resource.py +198 -0
  64. workos/types/metadata.py +4 -0
  65. workos/types/mfa/__init__.py +5 -0
  66. workos/types/mfa/authentication_challenge.py +14 -0
  67. workos/types/mfa/authentication_challenge_verification_response.py +9 -0
  68. workos/types/mfa/authentication_factor.py +70 -0
  69. workos/types/mfa/authentication_factor_totp_and_challenge_response.py +10 -0
  70. workos/types/mfa/enroll_authentication_factor_type.py +8 -0
  71. workos/types/organization_domains/__init__.py +1 -0
  72. workos/types/organization_domains/organization_domain.py +18 -0
  73. workos/types/organizations/__init__.py +6 -0
  74. workos/types/organizations/domain_data_input.py +7 -0
  75. workos/types/organizations/list_filters.py +6 -0
  76. workos/types/organizations/organization.py +13 -0
  77. workos/types/organizations/organization_common.py +12 -0
  78. workos/types/passwordless/__init__.py +2 -0
  79. workos/types/passwordless/passwordless_session.py +12 -0
  80. workos/types/passwordless/passwordless_session_type.py +3 -0
  81. workos/types/pipes/__init__.py +6 -0
  82. workos/types/pipes/pipes.py +34 -0
  83. workos/types/portal/__init__.py +2 -0
  84. workos/types/portal/portal_link.py +7 -0
  85. workos/types/portal/portal_link_intent.py +11 -0
  86. workos/types/portal/portal_link_intent_options.py +9 -0
  87. workos/types/roles/__init__.py +0 -0
  88. workos/types/roles/role.py +27 -0
  89. workos/types/sso/__init__.py +4 -0
  90. workos/types/sso/connection.py +70 -0
  91. workos/types/sso/connection_domain.py +8 -0
  92. workos/types/sso/profile.py +35 -0
  93. workos/types/sso/sso_provider_type.py +10 -0
  94. workos/types/user_management/__init__.py +12 -0
  95. workos/types/user_management/authenticate_with_common.py +66 -0
  96. workos/types/user_management/authentication_response.py +53 -0
  97. workos/types/user_management/email_verification.py +18 -0
  98. workos/types/user_management/impersonator.py +8 -0
  99. workos/types/user_management/invitation.py +26 -0
  100. workos/types/user_management/list_filters.py +29 -0
  101. workos/types/user_management/magic_auth.py +18 -0
  102. workos/types/user_management/oauth_tokens.py +21 -0
  103. workos/types/user_management/organization_membership.py +25 -0
  104. workos/types/user_management/password_hash_type.py +4 -0
  105. workos/types/user_management/password_reset.py +18 -0
  106. workos/types/user_management/screen_hint.py +3 -0
  107. workos/types/user_management/session.py +79 -0
  108. workos/types/user_management/user.py +22 -0
  109. workos/types/user_management/user_management_provider_type.py +11 -0
  110. workos/types/vault/__init__.py +2 -0
  111. workos/types/vault/key.py +25 -0
  112. workos/types/vault/object.py +38 -0
  113. workos/types/webhooks/__init__.py +0 -0
  114. workos/types/webhooks/webhook.py +330 -0
  115. workos/types/webhooks/webhook_model.py +14 -0
  116. workos/types/webhooks/webhook_payload.py +4 -0
  117. workos/types/widgets/__init__.py +2 -0
  118. workos/types/widgets/widget_scope.py +4 -0
  119. workos/types/widgets/widget_token_response.py +7 -0
  120. workos/types/workos_model.py +26 -0
  121. workos/typing/__init__.py +1 -0
  122. workos/typing/literals.py +32 -0
  123. workos/typing/sync_or_async.py +5 -0
  124. workos/typing/untyped_literal.py +37 -0
  125. workos/typing/webhooks.py +18 -0
  126. workos/user_management.py +2400 -0
  127. workos/utils/_base_http_client.py +252 -0
  128. workos/utils/crypto_provider.py +39 -0
  129. workos/utils/http_client.py +214 -0
  130. workos/utils/pagination_order.py +4 -0
  131. workos/utils/request_helper.py +27 -0
  132. workos/vault.py +544 -0
  133. workos/webhooks.py +96 -39
  134. workos/widgets.py +55 -0
  135. {workos-1.13.0.dist-info → workos-5.38.0.dist-info}/LICENSE +1 -1
  136. {workos-1.13.0.dist-info → workos-5.38.0.dist-info}/METADATA +47 -22
  137. workos-5.38.0.dist-info/RECORD +141 -0
  138. {workos-1.13.0.dist-info → workos-5.38.0.dist-info}/WHEEL +1 -1
  139. workos/audit_trail.py +0 -179
  140. workos/resources/base.py +0 -36
  141. workos/resources/directory_sync.py +0 -28
  142. workos/resources/event.py +0 -42
  143. workos/resources/event_action.py +0 -11
  144. workos/resources/mfa.py +0 -32
  145. workos/resources/sso.py +0 -53
  146. workos/utils/connection_types.py +0 -35
  147. workos/utils/pagiantion_order.py +0 -6
  148. workos/utils/request.py +0 -100
  149. workos/utils/validation.py +0 -60
  150. workos-1.13.0.dist-info/RECORD +0 -29
  151. /workos/{resources/__init__.py → py.typed} +0 -0
  152. {workos-1.13.0.dist-info → workos-5.38.0.dist-info}/top_level.txt +0 -0
workos/audit_trail.py DELETED
@@ -1,179 +0,0 @@
1
- import workos
2
- from workos.utils.pagiantion_order import Order
3
- from workos.exceptions import ConfigurationException
4
- from workos.resources.event import WorkOSEvent
5
- from workos.utils.request import RequestHelper, REQUEST_METHOD_GET, REQUEST_METHOD_POST
6
- from workos.utils.validation import AUDIT_TRAIL_MODULE, validate_settings
7
-
8
- EVENTS_PATH = "events"
9
- METADATA_LIMIT = 50
10
- DEFAULT_EVENT_LIMIT = 10
11
-
12
-
13
- class AuditTrail(object):
14
- """Offers methods through the WorkOS Audit Trail service."""
15
-
16
- @validate_settings(AUDIT_TRAIL_MODULE)
17
- def __init__(self):
18
- pass
19
-
20
- @property
21
- def request_helper(self):
22
- if not getattr(self, "_request_helper", None):
23
- self._request_helper = RequestHelper()
24
- return self._request_helper
25
-
26
- def create_event(self, event, idempotency_key=None):
27
- """Create an Audit Trail event.
28
-
29
- Args:
30
- event (dict) - An event object
31
- event[action] (str) - Specific activity performed by the actor.
32
- event[action_type] (str) - Corresponding CRUD category of the
33
- event. Can be one of C, R, U, or D.
34
- event[actor_name] (str) - Display name of the entity performing the action
35
- event[actor_id] (str) - Unique identifier of the entity performing the action
36
- event[group] (str) - A single organization containing related .
37
- members. This will normally be the customer of a vendor's application
38
- event[location] (str) - Identifier for where the event
39
- originated. This will be an IP address (IPv4 or IPv6),
40
- hostname, or device ID.
41
- event[occurred_at] (str) - ISO-8601 datetime at which the event
42
- happened, with millisecond precision.
43
- event[metadata] (str) - Arbitrary key-value data containing
44
- information associated with the event. Note: There is a limit of 50
45
- keys. Key names can be up to 40 characters long, and values can be up
46
- to 500 characters long.
47
- event[target_id] (str) - Unique identifier of the object or
48
- resource being acted upon.
49
- event[target_name] (str) - Display name of the object or
50
- resource that is being acted upon.
51
- idempotency_key (str) - An idempotency key
52
-
53
- Returns:
54
- boolean: Returns True
55
- """
56
- if len(event.get("metadata", {})) > METADATA_LIMIT:
57
- raise ValueError(
58
- "Number of metadata keys exceeds {}.".format(METADATA_LIMIT)
59
- )
60
-
61
- headers = {
62
- "idempotency-key": idempotency_key,
63
- }
64
-
65
- response = self.request_helper.request(
66
- EVENTS_PATH,
67
- method=REQUEST_METHOD_POST,
68
- params=event,
69
- headers=headers,
70
- token=workos.api_key,
71
- )
72
-
73
- return response["success"]
74
-
75
- def get_events(
76
- self,
77
- before=None,
78
- after=None,
79
- limit=DEFAULT_EVENT_LIMIT,
80
- group=None,
81
- action=None,
82
- action_type=None,
83
- actor_name=None,
84
- actor_id=None,
85
- target_name=None,
86
- target_id=None,
87
- occurred_at=None,
88
- occurred_at_gt=None,
89
- occurred_at_gte=None,
90
- occurred_at_lt=None,
91
- occurred_at_lte=None,
92
- search=None,
93
- order=None,
94
- ):
95
- """Filter for Audit Trail Events.
96
-
97
- Kwargs:
98
- before (str) - Event ID to look before
99
- after (str) - Event ID to look after
100
- limit (int) - Number of Events to return
101
- order (Order) - Order to paginate records
102
- group (str|list) - Group or groups to filter for
103
- action (str|list) - Action or actions to filter for
104
- action_type (str|list) - Action type or types to filter for
105
- actor_name (str|list) - Actor name or name to filter for
106
- actor_id (str|list) - Actor ID or IDs to filter for
107
- target_name (str|list) - Target name or names to filter for
108
- target_id (str|list) - Target ID or IDs to filter for
109
- occurred_at (str) - ISO-8601 datetime of when an event occurred
110
- occurred_at_gt (str) - ISO-8601 datetime of when an event occurred after
111
- occurred_at_gte (str) - ISO-8601 datetime of when an event occurred at or after
112
- occurred_at_lt (str) - ISO-8601 datetime of when an event occurred before
113
- occurred_at_lte (str) - ISO-8601 datetime of when an event occured at or before
114
- search (str) - Keyword search
115
-
116
- Returns:
117
- tuple
118
- list - List of WorkOSEvent objects
119
- string - Event ID to use as before cursor
120
- string - Event ID to use as after cursor
121
- """
122
- params = {
123
- "before": before,
124
- "after": after,
125
- "limit": limit,
126
- "order": order,
127
- }
128
-
129
- if group is not None:
130
- params["group[]"] = group
131
-
132
- if action is not None:
133
- params["action[]"] = action
134
-
135
- if action_type is not None:
136
- params["action_type[]"] = action_type
137
-
138
- if actor_name is not None:
139
- params["actor_name[]"] = actor_name
140
-
141
- if actor_id is not None:
142
- params["actor_id[]"] = actor_id
143
-
144
- if target_name is not None:
145
- params["target_name[]"] = target_name
146
-
147
- if target_id is not None:
148
- params["target_id[]"] = target_id
149
-
150
- if occurred_at is not None:
151
- params["occurred_at"] = occurred_at
152
- else:
153
- if occurred_at_gte is not None:
154
- params["occurred_at_gte"] = occurred_at_gte
155
- elif occurred_at_gt is not None:
156
- params["occurred_at_gt"] = occurred_at_gt
157
-
158
- if occurred_at_lte is not None:
159
- params["occurred_at_lte"] = occurred_at_lte
160
- elif occurred_at_lt is not None:
161
- params["occurred_at_lt"] = occurred_at_lt
162
-
163
- if search is not None:
164
- params["search"] = search
165
-
166
- response = self.request_helper.request(
167
- EVENTS_PATH,
168
- method=REQUEST_METHOD_GET,
169
- params=params,
170
- token=workos.api_key,
171
- )
172
-
173
- events = [
174
- WorkOSEvent.construct_from_response(data) for data in response["data"]
175
- ]
176
- before = response["list_metadata"]["before"]
177
- after = response["list_metadata"]["after"]
178
-
179
- return (events, before, after)
workos/resources/base.py DELETED
@@ -1,36 +0,0 @@
1
- class WorkOSBaseResource(object):
2
- """Representation of a WorkOS Resource as returned through the API.
3
-
4
- Attributes:
5
- OBJECT_FIELDS (list): List of fields a Resource is comprised of.
6
- """
7
-
8
- OBJECT_FIELDS = []
9
-
10
- @classmethod
11
- def construct_from_response(cls, response):
12
- """Returns an instance of WorkOSBaseResource.
13
-
14
- Args:
15
- response (dict): Resource data from a WorkOS API response
16
-
17
- Returns:
18
- WorkOSBaseResource: Instance of a WorkOSBaseResource with OBJECT_FIELDS fields set
19
- """
20
- obj = cls()
21
- for field in cls.OBJECT_FIELDS:
22
- setattr(obj, field, response.get(field))
23
-
24
- return obj
25
-
26
- def to_dict(self):
27
- """Returns a dict representation of the WorkOSBaseResource.
28
-
29
- Returns:
30
- dict: A dict representation of the WorkOSBaseResource
31
- """
32
- obj_dict = {}
33
- for field in self.OBJECT_FIELDS:
34
- obj_dict[field] = getattr(self, field, None)
35
-
36
- return obj_dict
@@ -1,28 +0,0 @@
1
- from workos.resources.base import WorkOSBaseResource
2
-
3
-
4
- class WorkOSDirectoryGroup(WorkOSBaseResource):
5
- """Representation of a Directory Group as returned by WorkOS through the Directory Sync feature.
6
-
7
- Attributes:
8
- OBJECT_FIELDS (list): List of fields a WorkOSDirectoryGroup is comprised of.
9
- """
10
-
11
- OBJECT_FIELDS = [
12
- "id",
13
- "idp_id",
14
- "directory_id",
15
- "name",
16
- "created_at",
17
- "updated_at",
18
- "raw_attributes",
19
- ]
20
-
21
- @classmethod
22
- def construct_from_response(cls, response):
23
- return super(WorkOSDirectoryGroup, cls).construct_from_response(response)
24
-
25
- def to_dict(self):
26
- directory_group = super(WorkOSDirectoryGroup, self).to_dict()
27
-
28
- return directory_group
workos/resources/event.py DELETED
@@ -1,42 +0,0 @@
1
- from workos.resources.base import WorkOSBaseResource
2
- from workos.resources.event_action import WorkOSEventAction
3
-
4
-
5
- class WorkOSEvent(WorkOSBaseResource):
6
- """Representation of an Event as returned by WorkOS through the Audit Trail feature.
7
-
8
- Attributes:
9
- OBJECT_FIELDS (list): List of fields a WorkOSEvent is comprised of.
10
- """
11
-
12
- OBJECT_FIELDS = [
13
- "id",
14
- "group",
15
- "location",
16
- "latitude",
17
- "longitude",
18
- "type",
19
- "actor_name",
20
- "actor_id",
21
- "target_name",
22
- "target_id",
23
- "metadata",
24
- "occurred_at",
25
- ]
26
-
27
- @classmethod
28
- def construct_from_response(cls, response):
29
- event = super(WorkOSEvent, cls).construct_from_response(response)
30
-
31
- event_action = WorkOSEventAction.construct_from_response(response["action"])
32
- event.action = event_action
33
-
34
- return event
35
-
36
- def to_dict(self):
37
- event_dict = super(WorkOSEvent, self).to_dict()
38
-
39
- event_action_dict = self.action.to_dict()
40
- event_dict["action"] = event_action_dict
41
-
42
- return event_dict
@@ -1,11 +0,0 @@
1
- from workos.resources.base import WorkOSBaseResource
2
-
3
-
4
- class WorkOSEventAction(WorkOSBaseResource):
5
- """Representation of an Event Action as returned by WorkOS through the Audit Trail feature.
6
-
7
- Attributes:
8
- OBJECT_FIELDS (list): List of fields a WorkOSEventAction is comprised of.
9
- """
10
-
11
- OBJECT_FIELDS = ["id", "name"]
workos/resources/mfa.py DELETED
@@ -1,32 +0,0 @@
1
- from workos.resources.base import WorkOSBaseResource
2
-
3
-
4
- class WorkOSChallenge(WorkOSBaseResource):
5
- """Representation of a MFA Challenge Response as returned by WorkOS through the MFA feature.
6
-
7
- Attributes:
8
- OBJECT_FIELDS (list): List of fields a WorkOSChallenge is comprised of.
9
- """
10
-
11
- OBJECT_FIELDS = [
12
- "object",
13
- "id",
14
- "created_at",
15
- "updated_at",
16
- "expires_at",
17
- "code",
18
- "authentication_factor_id",
19
- ]
20
-
21
- @classmethod
22
- def construct_from_response(cls, response):
23
- challenge_response = super(WorkOSChallenge, cls).construct_from_response(
24
- response
25
- )
26
-
27
- return challenge_response
28
-
29
- def to_dict(self):
30
- challenge_response_dict = super(WorkOSChallenge, self).to_dict()
31
-
32
- return challenge_response_dict
workos/resources/sso.py DELETED
@@ -1,53 +0,0 @@
1
- from workos.resources.base import WorkOSBaseResource
2
-
3
-
4
- class WorkOSProfile(WorkOSBaseResource):
5
- """Representation of a User Profile as returned by WorkOS through the SSO feature.
6
-
7
- Attributes:
8
- OBJECT_FIELDS (list): List of fields a WorkOSProfile is comprised of.
9
- """
10
-
11
- OBJECT_FIELDS = [
12
- "id",
13
- "email",
14
- "first_name",
15
- "last_name",
16
- "organization_id",
17
- "connection_id",
18
- "connection_type",
19
- "idp_id",
20
- "raw_attributes",
21
- ]
22
-
23
-
24
- class WorkOSProfileAndToken(WorkOSBaseResource):
25
- """Representation of a User Profile and Access Token as returned by WorkOS through the SSO feature.
26
-
27
- Attributes:
28
- OBJECT_FIELDS (list): List of fields a WorkOSProfileAndToken is comprised of.
29
- """
30
-
31
- OBJECT_FIELDS = [
32
- "access_token",
33
- ]
34
-
35
- @classmethod
36
- def construct_from_response(cls, response):
37
- profile_and_token = super(WorkOSProfileAndToken, cls).construct_from_response(
38
- response
39
- )
40
-
41
- profile_and_token.profile = WorkOSProfile.construct_from_response(
42
- response["profile"]
43
- )
44
-
45
- return profile_and_token
46
-
47
- def to_dict(self):
48
- profile_and_token_dict = super(WorkOSProfileAndToken, self).to_dict()
49
-
50
- profile_dict = self.profile.to_dict()
51
- profile_and_token_dict["profile"] = profile_dict
52
-
53
- return profile_and_token_dict
@@ -1,35 +0,0 @@
1
- from enum import Enum
2
-
3
-
4
- class ConnectionType(Enum):
5
- ADFSSAML = "ADFSSAML"
6
- AdpOidc = "AdpOidc"
7
- Auth0SAML = "Auth0SAML"
8
- AzureSAML = "AzureSAML"
9
- CasSAML = "CasSAML"
10
- CloudflareSAML = "CloudflareSAML"
11
- ClassLinkSAML = "ClassLinkSAML"
12
- CyberArkSAML = "CyberArkSAML"
13
- DuoSAML = "DuoSAML"
14
- GenericOIDC = "GenericOIDC"
15
- GenericSAML = "GenericSAML"
16
- GoogleOAuth = "GoogleOAuth"
17
- GoogleSAML = "GoogleSAML"
18
- JumpCloudSAML = "JumpCloudSAML"
19
- KeycloakSAML = "KeycloakSAML"
20
- LastPassSAML = "LastPassSAML"
21
- MagicLink = "MagicLink"
22
- MicrosoftOAuth = "MicrosoftOAuth"
23
- MiniOrangeSAML = "MiniOrangeSAML"
24
- NetIqSAML = "NetIqSAML"
25
- OktaSAML = "OktaSAML"
26
- OneLoginSAML = "OneLoginSAML"
27
- OracleSAML = "OracleSAML"
28
- PingFederateSAML = "PingFederateSAML"
29
- PingOneSAML = "PingOneSAML"
30
- RipplingSAML = "RipplingSAML"
31
- SalesforceSAML = "SalesforceSAML"
32
- ShibbolethGenericSAML = "ShibbolethGenericSAML"
33
- ShibbolethSAML = "ShibbolethSAML"
34
- SimpleSamlPhpSAML = "SimpleSamlPhpSAML"
35
- VMwareSAML = "VMwareSAML"
@@ -1,6 +0,0 @@
1
- from enum import Enum
2
-
3
-
4
- class Order(Enum):
5
- Asc = "asc"
6
- Desc = "desc"
workos/utils/request.py DELETED
@@ -1,100 +0,0 @@
1
- import requests
2
-
3
- import workos
4
- from workos.exceptions import (
5
- AuthorizationException,
6
- AuthenticationException,
7
- BadRequestException,
8
- ServerException,
9
- )
10
-
11
- BASE_HEADERS = {
12
- "User-Agent": "WorkOS Python/{}".format(workos.__version__),
13
- }
14
-
15
- RESPONSE_TYPE_CODE = "code"
16
-
17
- REQUEST_METHOD_DELETE = "delete"
18
- REQUEST_METHOD_GET = "get"
19
- REQUEST_METHOD_POST = "post"
20
- REQUEST_METHOD_PUT = "put"
21
-
22
-
23
- class RequestHelper(object):
24
- def __init__(self):
25
- self.set_base_api_url(workos.base_api_url)
26
-
27
- def set_base_api_url(self, base_api_url):
28
- """Creates an accessible template for constructing the URL for an API request.
29
-
30
- Args:
31
- base_api_url (str): Base URL for api requests (Should end with a /)
32
- """
33
- self.base_api_url = "{}{{}}".format(base_api_url)
34
-
35
- def generate_api_url(self, path):
36
- return self.base_api_url.format(path)
37
-
38
- def request(
39
- self,
40
- path,
41
- method=REQUEST_METHOD_GET,
42
- params=None,
43
- headers=None,
44
- token=None,
45
- ):
46
- """Executes a request against the WorkOS API.
47
-
48
- Args:
49
- path (str): Path for the api request that'd be appended to the base API URL
50
-
51
- Kwargs:
52
- method (str): One of the supported methods as defined by the REQUEST_METHOD_X constants
53
- params (dict): Query params to be added to the request
54
- token (str): Bearer token
55
-
56
- Returns:
57
- dict: Response from WorkOS
58
- """
59
- if headers is None:
60
- headers = {}
61
-
62
- if token:
63
- headers["Authorization"] = "Bearer {}".format(token)
64
-
65
- headers.update(BASE_HEADERS)
66
- url = self.generate_api_url(path)
67
-
68
- request_fn = getattr(requests, method)
69
- if method == REQUEST_METHOD_GET:
70
- response = request_fn(url, headers=headers, params=params)
71
- else:
72
- response = request_fn(url, headers=headers, json=params)
73
-
74
- response_json = None
75
- content_type = (
76
- response.headers.get("content-type")
77
- if response.headers is not None
78
- else None
79
- )
80
- if content_type is not None and "application/json" in content_type:
81
- try:
82
- response_json = response.json()
83
- except ValueError:
84
- raise ServerException(response)
85
-
86
- status_code = response.status_code
87
- if status_code >= 400 and status_code < 500:
88
- if status_code == 401:
89
- raise AuthenticationException(response)
90
- elif status_code == 403:
91
- raise AuthorizationException(response)
92
- error = response_json.get("error")
93
- error_description = response_json.get("error_description")
94
- raise BadRequestException(
95
- response, error=error, error_description=error_description
96
- )
97
- elif status_code >= 500 and status_code < 600:
98
- raise ServerException(response)
99
-
100
- return response_json
@@ -1,60 +0,0 @@
1
- from functools import wraps
2
-
3
- import workos
4
- from workos.exceptions import ConfigurationException
5
-
6
- AUDIT_TRAIL_MODULE = "AuditTrail"
7
- DIRECTORY_SYNC_MODULE = "DirectorySync"
8
- ORGANIZATIONS_MODULE = "Organizations"
9
- PASSWORDLESS_MODULE = "Passwordless"
10
- PORTAL_MODULE = "Portal"
11
- SSO_MODULE = "SSO"
12
- WEBHOOKS_MODULE = "Webhooks"
13
- MFA_MODULE = "MFA"
14
-
15
- REQUIRED_SETTINGS_FOR_MODULE = {
16
- AUDIT_TRAIL_MODULE: [
17
- "api_key",
18
- ],
19
- DIRECTORY_SYNC_MODULE: [
20
- "api_key",
21
- ],
22
- ORGANIZATIONS_MODULE: [
23
- "api_key",
24
- ],
25
- PASSWORDLESS_MODULE: [
26
- "api_key",
27
- ],
28
- PORTAL_MODULE: [
29
- "api_key",
30
- ],
31
- SSO_MODULE: [
32
- "api_key",
33
- "client_id",
34
- ],
35
- WEBHOOKS_MODULE: ["api_key"],
36
- MFA_MODULE: ["api_key"],
37
- }
38
-
39
-
40
- def validate_settings(module_name):
41
- def decorator(fn):
42
- @wraps(fn)
43
- def wrapper(*args, **kwargs):
44
- missing_settings = []
45
-
46
- for setting in REQUIRED_SETTINGS_FOR_MODULE[module_name]:
47
- if not getattr(workos, setting, None):
48
- missing_settings.append(setting)
49
-
50
- if missing_settings:
51
- raise ConfigurationException(
52
- "The following settings are missing for {}: {}".format(
53
- module_name, ", ".join(missing_settings)
54
- )
55
- )
56
- return fn(*args, **kwargs)
57
-
58
- return wrapper
59
-
60
- return decorator
@@ -1,29 +0,0 @@
1
- workos/__about__.py,sha256=09W8oXM89DWVZvy5XUEetO89tN80IJL6lCgH6RO5jyU,406
2
- workos/__init__.py,sha256=EBYXvVZCRbkoUs8IMgjd5mwWIiVsrglUWueOYxd9IZY,207
3
- workos/audit_trail.py,sha256=pSWIRb06W9H_8sB2JEM7FSx-br7GfahhjZ7kJyuMfYA,6599
4
- workos/client.py,sha256=ntGw0_j8a-OqW3p7lL7ao1vODKq1Sj90uEs4TsHYZ4Q,1714
5
- workos/directory_sync.py,sha256=pdTB7NjMZ0isNsFSbxE9HOMCE7ch_vm0J-d8qj1rDcw,6965
6
- workos/exceptions.py,sha256=iSLDPtUat7xsaKmkGxlwB4W0SFEZZ_Yl-1JxmYDtTPY,1497
7
- workos/mfa.py,sha256=GPJYF2ADk3cPB_4hsxgXbymKwjJ9hPpDuxvcYeIVHYs,5307
8
- workos/organizations.py,sha256=qFtNijMEBuaFdlZ_TxsfHmYoMVi0R9ZlYWfDqbRwrHA,4970
9
- workos/passwordless.py,sha256=bRGZ0OJA3gv9Gge7Nas19jtoUYU92sopzUOFguOs230,2620
10
- workos/portal.py,sha256=iy1LsD9dHUEAv7pQ1XnWTnAfiymWN1T1Z1lTh_WiSks,1540
11
- workos/sso.py,sha256=bOU7A8oP5IgpGeekjpqho0xhomhwpvz7LJUzDJj66JI,8497
12
- workos/webhooks.py,sha256=eqzDwHw4tQF7pcb_8Po4VlmxENzviFRcL8tuS8uKhOM,3093
13
- workos/resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
- workos/resources/base.py,sha256=hcu2qBhD_Av-sAzuTzd9yyqRntCQ5wgn_s_I_c6lWiY,1024
15
- workos/resources/directory_sync.py,sha256=dTkNaLdzrJ2xfsWQCziAuxerQaNwSpGmoVhNXqUN6xI,759
16
- workos/resources/event.py,sha256=8K-vJdSAt92r7hetmzwJtBVggnUaoiJO_d7pMPGpyJ8,1101
17
- workos/resources/event_action.py,sha256=WPJragfYl9yPD9U7G9hSehW08N3M3zBFfd_5i-_AxWI,339
18
- workos/resources/mfa.py,sha256=GN43xqLgTndMo6biU4eTTCMsYvuafy7TpKs_ihvxxtM,830
19
- workos/resources/sso.py,sha256=PQxsO8GoPxjfHRsT7w_naUnfaA0xFOj28WJ7A2IKWm8,1412
20
- workos/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
- workos/utils/connection_types.py,sha256=GEc4oAU8TMqKRw2ZhyBAB0Ahm-URs0eA6uDUfLrShuQ,1076
22
- workos/utils/pagiantion_order.py,sha256=VyVpx9Q1bOqIt5G3NisfBbGNZi9JB1igqgtSh-iwBMM,77
23
- workos/utils/request.py,sha256=niOd_Zhimt-nsEuvBHfA1G2YBhKT3yz_PCg5vxKCwUI,3003
24
- workos/utils/validation.py,sha256=hPrjte8S63oHiMR-e1ql5lp9-r-YFYhdG7p4ss_SJlc,1441
25
- workos-1.13.0.dist-info/LICENSE,sha256=RAEmkw4BYTzgAxZbzzw_DDUlpPgg02u-_9qtEfcAOOw,1063
26
- workos-1.13.0.dist-info/METADATA,sha256=B-ACUlQIaXOwC2e7rVZREH9MZzjZ-ajIet7kfJIYkcI,3079
27
- workos-1.13.0.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
28
- workos-1.13.0.dist-info/top_level.txt,sha256=ZFskIfue1Tw-JwjyIXRvdsAl9i0DX9VbqmgICXV84Sk,7
29
- workos-1.13.0.dist-info/RECORD,,
File without changes