workos 5.39.1__tar.gz → 5.40.0__tar.gz

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 (145) hide show
  1. {workos-5.39.1 → workos-5.40.0}/PKG-INFO +1 -1
  2. {workos-5.39.1 → workos-5.40.0}/pyproject.toml +1 -1
  3. {workos-5.39.1 → workos-5.40.0}/src/workos/async_client.py +5 -5
  4. workos-5.40.0/src/workos/audit_logs.py +561 -0
  5. {workos-5.39.1 → workos-5.40.0}/src/workos/types/audit_logs/__init__.py +6 -0
  6. workos-5.40.0/src/workos/types/audit_logs/audit_log_action.py +28 -0
  7. workos-5.40.0/src/workos/types/audit_logs/audit_log_configuration.py +41 -0
  8. workos-5.40.0/src/workos/types/audit_logs/audit_log_retention.py +13 -0
  9. workos-5.40.0/src/workos/types/audit_logs/audit_log_schema.py +49 -0
  10. workos-5.40.0/src/workos/types/audit_logs/audit_log_schema_input.py +78 -0
  11. workos-5.40.0/src/workos/types/audit_logs/list_filters.py +13 -0
  12. {workos-5.39.1 → workos-5.40.0}/src/workos/types/list_resource.py +3 -0
  13. workos-5.39.1/src/workos/audit_logs.py +0 -125
  14. {workos-5.39.1 → workos-5.40.0}/README.md +0 -0
  15. {workos-5.39.1 → workos-5.40.0}/src/workos/__init__.py +0 -0
  16. {workos-5.39.1 → workos-5.40.0}/src/workos/_base_client.py +0 -0
  17. {workos-5.39.1 → workos-5.40.0}/src/workos/_client_configuration.py +0 -0
  18. {workos-5.39.1 → workos-5.40.0}/src/workos/api_keys.py +0 -0
  19. {workos-5.39.1 → workos-5.40.0}/src/workos/client.py +0 -0
  20. {workos-5.39.1 → workos-5.40.0}/src/workos/directory_sync.py +0 -0
  21. {workos-5.39.1 → workos-5.40.0}/src/workos/events.py +0 -0
  22. {workos-5.39.1 → workos-5.40.0}/src/workos/exceptions.py +0 -0
  23. {workos-5.39.1 → workos-5.40.0}/src/workos/fga.py +0 -0
  24. {workos-5.39.1 → workos-5.40.0}/src/workos/mfa.py +0 -0
  25. {workos-5.39.1 → workos-5.40.0}/src/workos/organization_domains.py +0 -0
  26. {workos-5.39.1 → workos-5.40.0}/src/workos/organizations.py +0 -0
  27. {workos-5.39.1 → workos-5.40.0}/src/workos/passwordless.py +0 -0
  28. {workos-5.39.1 → workos-5.40.0}/src/workos/pipes.py +0 -0
  29. {workos-5.39.1 → workos-5.40.0}/src/workos/portal.py +0 -0
  30. {workos-5.39.1 → workos-5.40.0}/src/workos/py.typed +0 -0
  31. {workos-5.39.1 → workos-5.40.0}/src/workos/session.py +0 -0
  32. {workos-5.39.1 → workos-5.40.0}/src/workos/sso.py +0 -0
  33. {workos-5.39.1 → workos-5.40.0}/src/workos/types/__init__.py +0 -0
  34. {workos-5.39.1 → workos-5.40.0}/src/workos/types/api_keys/__init__.py +0 -0
  35. {workos-5.39.1 → workos-5.40.0}/src/workos/types/api_keys/api_keys.py +0 -0
  36. {workos-5.39.1 → workos-5.40.0}/src/workos/types/audit_logs/audit_log_event.py +0 -0
  37. {workos-5.39.1 → workos-5.40.0}/src/workos/types/audit_logs/audit_log_event_actor.py +0 -0
  38. {workos-5.39.1 → workos-5.40.0}/src/workos/types/audit_logs/audit_log_event_context.py +0 -0
  39. {workos-5.39.1 → workos-5.40.0}/src/workos/types/audit_logs/audit_log_event_target.py +0 -0
  40. {workos-5.39.1 → workos-5.40.0}/src/workos/types/audit_logs/audit_log_export.py +0 -0
  41. {workos-5.39.1 → workos-5.40.0}/src/workos/types/audit_logs/audit_log_metadata.py +0 -0
  42. {workos-5.39.1 → workos-5.40.0}/src/workos/types/directory_sync/__init__.py +0 -0
  43. {workos-5.39.1 → workos-5.40.0}/src/workos/types/directory_sync/directory.py +0 -0
  44. {workos-5.39.1 → workos-5.40.0}/src/workos/types/directory_sync/directory_group.py +0 -0
  45. {workos-5.39.1 → workos-5.40.0}/src/workos/types/directory_sync/directory_state.py +0 -0
  46. {workos-5.39.1 → workos-5.40.0}/src/workos/types/directory_sync/directory_type.py +0 -0
  47. {workos-5.39.1 → workos-5.40.0}/src/workos/types/directory_sync/directory_user.py +0 -0
  48. {workos-5.39.1 → workos-5.40.0}/src/workos/types/directory_sync/list_filters.py +0 -0
  49. {workos-5.39.1 → workos-5.40.0}/src/workos/types/events/__init__.py +0 -0
  50. {workos-5.39.1 → workos-5.40.0}/src/workos/types/events/authentication_payload.py +0 -0
  51. {workos-5.39.1 → workos-5.40.0}/src/workos/types/events/connection_payload_with_legacy_fields.py +0 -0
  52. {workos-5.39.1 → workos-5.40.0}/src/workos/types/events/directory_group_membership_payload.py +0 -0
  53. {workos-5.39.1 → workos-5.40.0}/src/workos/types/events/directory_group_with_previous_attributes.py +0 -0
  54. {workos-5.39.1 → workos-5.40.0}/src/workos/types/events/directory_payload.py +0 -0
  55. {workos-5.39.1 → workos-5.40.0}/src/workos/types/events/directory_payload_with_legacy_fields.py +0 -0
  56. {workos-5.39.1 → workos-5.40.0}/src/workos/types/events/directory_user_with_previous_attributes.py +0 -0
  57. {workos-5.39.1 → workos-5.40.0}/src/workos/types/events/event.py +0 -0
  58. {workos-5.39.1 → workos-5.40.0}/src/workos/types/events/event_model.py +0 -0
  59. {workos-5.39.1 → workos-5.40.0}/src/workos/types/events/event_type.py +0 -0
  60. {workos-5.39.1 → workos-5.40.0}/src/workos/types/events/list_filters.py +0 -0
  61. {workos-5.39.1 → workos-5.40.0}/src/workos/types/events/organization_domain_verification_failed_payload.py +0 -0
  62. {workos-5.39.1 → workos-5.40.0}/src/workos/types/events/previous_attributes.py +0 -0
  63. {workos-5.39.1 → workos-5.40.0}/src/workos/types/events/session_payload.py +0 -0
  64. {workos-5.39.1 → workos-5.40.0}/src/workos/types/feature_flags/__init__.py +0 -0
  65. {workos-5.39.1 → workos-5.40.0}/src/workos/types/feature_flags/feature_flag.py +0 -0
  66. {workos-5.39.1 → workos-5.40.0}/src/workos/types/feature_flags/list_filters.py +0 -0
  67. {workos-5.39.1 → workos-5.40.0}/src/workos/types/fga/__init__.py +0 -0
  68. {workos-5.39.1 → workos-5.40.0}/src/workos/types/fga/authorization_resource_types.py +0 -0
  69. {workos-5.39.1 → workos-5.40.0}/src/workos/types/fga/authorization_resources.py +0 -0
  70. {workos-5.39.1 → workos-5.40.0}/src/workos/types/fga/check.py +0 -0
  71. {workos-5.39.1 → workos-5.40.0}/src/workos/types/fga/list_filters.py +0 -0
  72. {workos-5.39.1 → workos-5.40.0}/src/workos/types/fga/warnings.py +0 -0
  73. {workos-5.39.1 → workos-5.40.0}/src/workos/types/fga/warrant.py +0 -0
  74. {workos-5.39.1 → workos-5.40.0}/src/workos/types/metadata.py +0 -0
  75. {workos-5.39.1 → workos-5.40.0}/src/workos/types/mfa/__init__.py +0 -0
  76. {workos-5.39.1 → workos-5.40.0}/src/workos/types/mfa/authentication_challenge.py +0 -0
  77. {workos-5.39.1 → workos-5.40.0}/src/workos/types/mfa/authentication_challenge_verification_response.py +0 -0
  78. {workos-5.39.1 → workos-5.40.0}/src/workos/types/mfa/authentication_factor.py +0 -0
  79. {workos-5.39.1 → workos-5.40.0}/src/workos/types/mfa/authentication_factor_totp_and_challenge_response.py +0 -0
  80. {workos-5.39.1 → workos-5.40.0}/src/workos/types/mfa/enroll_authentication_factor_type.py +0 -0
  81. {workos-5.39.1 → workos-5.40.0}/src/workos/types/organization_domains/__init__.py +0 -0
  82. {workos-5.39.1 → workos-5.40.0}/src/workos/types/organization_domains/organization_domain.py +0 -0
  83. {workos-5.39.1 → workos-5.40.0}/src/workos/types/organizations/__init__.py +0 -0
  84. {workos-5.39.1 → workos-5.40.0}/src/workos/types/organizations/domain_data_input.py +0 -0
  85. {workos-5.39.1 → workos-5.40.0}/src/workos/types/organizations/list_filters.py +0 -0
  86. {workos-5.39.1 → workos-5.40.0}/src/workos/types/organizations/organization.py +0 -0
  87. {workos-5.39.1 → workos-5.40.0}/src/workos/types/organizations/organization_common.py +0 -0
  88. {workos-5.39.1 → workos-5.40.0}/src/workos/types/passwordless/__init__.py +0 -0
  89. {workos-5.39.1 → workos-5.40.0}/src/workos/types/passwordless/passwordless_session.py +0 -0
  90. {workos-5.39.1 → workos-5.40.0}/src/workos/types/passwordless/passwordless_session_type.py +0 -0
  91. {workos-5.39.1 → workos-5.40.0}/src/workos/types/pipes/__init__.py +0 -0
  92. {workos-5.39.1 → workos-5.40.0}/src/workos/types/pipes/pipes.py +0 -0
  93. {workos-5.39.1 → workos-5.40.0}/src/workos/types/portal/__init__.py +0 -0
  94. {workos-5.39.1 → workos-5.40.0}/src/workos/types/portal/portal_link.py +0 -0
  95. {workos-5.39.1 → workos-5.40.0}/src/workos/types/portal/portal_link_intent.py +0 -0
  96. {workos-5.39.1 → workos-5.40.0}/src/workos/types/portal/portal_link_intent_options.py +0 -0
  97. {workos-5.39.1 → workos-5.40.0}/src/workos/types/roles/__init__.py +0 -0
  98. {workos-5.39.1 → workos-5.40.0}/src/workos/types/roles/role.py +0 -0
  99. {workos-5.39.1 → workos-5.40.0}/src/workos/types/sso/__init__.py +0 -0
  100. {workos-5.39.1 → workos-5.40.0}/src/workos/types/sso/connection.py +0 -0
  101. {workos-5.39.1 → workos-5.40.0}/src/workos/types/sso/connection_domain.py +0 -0
  102. {workos-5.39.1 → workos-5.40.0}/src/workos/types/sso/profile.py +0 -0
  103. {workos-5.39.1 → workos-5.40.0}/src/workos/types/sso/sso_provider_type.py +0 -0
  104. {workos-5.39.1 → workos-5.40.0}/src/workos/types/user_management/__init__.py +0 -0
  105. {workos-5.39.1 → workos-5.40.0}/src/workos/types/user_management/authenticate_with_common.py +0 -0
  106. {workos-5.39.1 → workos-5.40.0}/src/workos/types/user_management/authentication_response.py +0 -0
  107. {workos-5.39.1 → workos-5.40.0}/src/workos/types/user_management/email_verification.py +0 -0
  108. {workos-5.39.1 → workos-5.40.0}/src/workos/types/user_management/impersonator.py +0 -0
  109. {workos-5.39.1 → workos-5.40.0}/src/workos/types/user_management/invitation.py +0 -0
  110. {workos-5.39.1 → workos-5.40.0}/src/workos/types/user_management/list_filters.py +0 -0
  111. {workos-5.39.1 → workos-5.40.0}/src/workos/types/user_management/magic_auth.py +0 -0
  112. {workos-5.39.1 → workos-5.40.0}/src/workos/types/user_management/oauth_tokens.py +0 -0
  113. {workos-5.39.1 → workos-5.40.0}/src/workos/types/user_management/organization_membership.py +0 -0
  114. {workos-5.39.1 → workos-5.40.0}/src/workos/types/user_management/password_hash_type.py +0 -0
  115. {workos-5.39.1 → workos-5.40.0}/src/workos/types/user_management/password_reset.py +0 -0
  116. {workos-5.39.1 → workos-5.40.0}/src/workos/types/user_management/screen_hint.py +0 -0
  117. {workos-5.39.1 → workos-5.40.0}/src/workos/types/user_management/session.py +0 -0
  118. {workos-5.39.1 → workos-5.40.0}/src/workos/types/user_management/user.py +0 -0
  119. {workos-5.39.1 → workos-5.40.0}/src/workos/types/user_management/user_management_provider_type.py +0 -0
  120. {workos-5.39.1 → workos-5.40.0}/src/workos/types/vault/__init__.py +0 -0
  121. {workos-5.39.1 → workos-5.40.0}/src/workos/types/vault/key.py +0 -0
  122. {workos-5.39.1 → workos-5.40.0}/src/workos/types/vault/object.py +0 -0
  123. {workos-5.39.1 → workos-5.40.0}/src/workos/types/webhooks/__init__.py +0 -0
  124. {workos-5.39.1 → workos-5.40.0}/src/workos/types/webhooks/webhook.py +0 -0
  125. {workos-5.39.1 → workos-5.40.0}/src/workos/types/webhooks/webhook_model.py +0 -0
  126. {workos-5.39.1 → workos-5.40.0}/src/workos/types/webhooks/webhook_payload.py +0 -0
  127. {workos-5.39.1 → workos-5.40.0}/src/workos/types/widgets/__init__.py +0 -0
  128. {workos-5.39.1 → workos-5.40.0}/src/workos/types/widgets/widget_scope.py +0 -0
  129. {workos-5.39.1 → workos-5.40.0}/src/workos/types/widgets/widget_token_response.py +0 -0
  130. {workos-5.39.1 → workos-5.40.0}/src/workos/types/workos_model.py +0 -0
  131. {workos-5.39.1 → workos-5.40.0}/src/workos/typing/__init__.py +0 -0
  132. {workos-5.39.1 → workos-5.40.0}/src/workos/typing/literals.py +0 -0
  133. {workos-5.39.1 → workos-5.40.0}/src/workos/typing/sync_or_async.py +0 -0
  134. {workos-5.39.1 → workos-5.40.0}/src/workos/typing/untyped_literal.py +0 -0
  135. {workos-5.39.1 → workos-5.40.0}/src/workos/typing/webhooks.py +0 -0
  136. {workos-5.39.1 → workos-5.40.0}/src/workos/user_management.py +0 -0
  137. {workos-5.39.1 → workos-5.40.0}/src/workos/utils/__init__.py +0 -0
  138. {workos-5.39.1 → workos-5.40.0}/src/workos/utils/_base_http_client.py +0 -0
  139. {workos-5.39.1 → workos-5.40.0}/src/workos/utils/crypto_provider.py +0 -0
  140. {workos-5.39.1 → workos-5.40.0}/src/workos/utils/http_client.py +0 -0
  141. {workos-5.39.1 → workos-5.40.0}/src/workos/utils/pagination_order.py +0 -0
  142. {workos-5.39.1 → workos-5.40.0}/src/workos/utils/request_helper.py +0 -0
  143. {workos-5.39.1 → workos-5.40.0}/src/workos/vault.py +0 -0
  144. {workos-5.39.1 → workos-5.40.0}/src/workos/webhooks.py +0 -0
  145. {workos-5.39.1 → workos-5.40.0}/src/workos/widgets.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: workos
3
- Version: 5.39.1
3
+ Version: 5.40.0
4
4
  Summary: WorkOS Python Client
5
5
  Author: WorkOS
6
6
  Author-email: WorkOS <team@workos.com>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "workos"
3
- version = "5.39.1"
3
+ version = "5.40.0"
4
4
  description = "WorkOS Python Client"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -2,7 +2,7 @@ from typing import Optional
2
2
  from importlib.metadata import version
3
3
  from workos._base_client import BaseClient
4
4
  from workos.api_keys import AsyncApiKeys
5
- from workos.audit_logs import AuditLogsModule
5
+ from workos.audit_logs import AsyncAuditLogs
6
6
  from workos.directory_sync import AsyncDirectorySync
7
7
  from workos.events import AsyncEvents
8
8
  from workos.fga import FGAModule
@@ -64,10 +64,10 @@ class AsyncClient(BaseClient):
64
64
  return self._sso
65
65
 
66
66
  @property
67
- def audit_logs(self) -> AuditLogsModule:
68
- raise NotImplementedError(
69
- "Audit logs APIs are not yet supported in the async client."
70
- )
67
+ def audit_logs(self) -> AsyncAuditLogs:
68
+ if not getattr(self, "_audit_logs", None):
69
+ self._audit_logs = AsyncAuditLogs(self._http_client)
70
+ return self._audit_logs
71
71
 
72
72
  @property
73
73
  def directory_sync(self) -> AsyncDirectorySync:
@@ -0,0 +1,561 @@
1
+ from typing import Dict, Literal, Optional, Protocol, Sequence
2
+
3
+ from workos.types.audit_logs import (
4
+ AuditLogAction,
5
+ AuditLogConfiguration,
6
+ AuditLogExport,
7
+ AuditLogRetention,
8
+ AuditLogSchema,
9
+ AuditLogSchemaListFilters,
10
+ AuditLogActionListFilters,
11
+ )
12
+ from workos.types.audit_logs.audit_log_schema_input import (
13
+ AuditLogSchemaActorInput,
14
+ AuditLogSchemaTargetInput,
15
+ MetadataSchemaInput,
16
+ serialize_schema_options,
17
+ )
18
+ from workos.types.audit_logs.audit_log_event import AuditLogEvent
19
+ from workos.types.list_resource import ListMetadata, ListPage, WorkOSListResource
20
+ from workos.typing.sync_or_async import SyncOrAsync
21
+ from workos.utils.http_client import AsyncHTTPClient, SyncHTTPClient
22
+ from workos.utils.pagination_order import PaginationOrder
23
+ from workos.utils.request_helper import (
24
+ DEFAULT_LIST_RESPONSE_LIMIT,
25
+ REQUEST_METHOD_GET,
26
+ REQUEST_METHOD_POST,
27
+ REQUEST_METHOD_PUT,
28
+ )
29
+
30
+ EVENTS_PATH = "audit_logs/events"
31
+ EXPORTS_PATH = "audit_logs/exports"
32
+ ACTIONS_PATH = "audit_logs/actions"
33
+
34
+
35
+ AuditLogActionsListResource = WorkOSListResource[
36
+ AuditLogAction, AuditLogActionListFilters, ListMetadata
37
+ ]
38
+
39
+ AuditLogSchemasListResource = WorkOSListResource[
40
+ AuditLogSchema, AuditLogSchemaListFilters, ListMetadata
41
+ ]
42
+
43
+
44
+ class AuditLogsModule(Protocol):
45
+ """Offers methods through the WorkOS Audit Logs service."""
46
+
47
+ def create_event(
48
+ self,
49
+ *,
50
+ organization_id: str,
51
+ event: AuditLogEvent,
52
+ idempotency_key: Optional[str] = None,
53
+ ) -> SyncOrAsync[None]:
54
+ """Create an Audit Logs event.
55
+
56
+ Kwargs:
57
+ organization_id (str): Organization's unique identifier.
58
+ event (AuditLogEvent): An AuditLogEvent object.
59
+ idempotency_key (str): Idempotency key. (Optional)
60
+ Returns:
61
+ None
62
+ """
63
+ ...
64
+
65
+ def create_export(
66
+ self,
67
+ *,
68
+ organization_id: str,
69
+ range_start: str,
70
+ range_end: str,
71
+ actions: Optional[Sequence[str]] = None,
72
+ targets: Optional[Sequence[str]] = None,
73
+ actor_names: Optional[Sequence[str]] = None,
74
+ actor_ids: Optional[Sequence[str]] = None,
75
+ ) -> SyncOrAsync[AuditLogExport]:
76
+ """Trigger the creation of an export of audit logs.
77
+
78
+ Kwargs:
79
+ organization_id (str): Organization's unique identifier.
80
+ range_start (str): Start date of the date range filter.
81
+ range_end (str): End date of the date range filter.
82
+ actions (list): Optional list of actions to filter. (Optional)
83
+ actor_names (list): Optional list of actors to filter by name. (Optional)
84
+ actor_ids (list): Optional list of actors to filter by ID. (Optional)
85
+ targets (list): Optional list of targets to filter. (Optional)
86
+
87
+ Returns:
88
+ AuditLogExport: Object that describes the audit log export
89
+ """
90
+ ...
91
+
92
+ def get_export(self, audit_log_export_id: str) -> SyncOrAsync[AuditLogExport]:
93
+ """Retrieve a created export.
94
+
95
+ Args:
96
+ audit_log_export_id (str): Audit log export unique identifier.
97
+
98
+ Returns:
99
+ AuditLogExport: Object that describes the audit log export
100
+ """
101
+ ...
102
+
103
+ def create_schema(
104
+ self,
105
+ *,
106
+ action: str,
107
+ targets: Sequence[AuditLogSchemaTargetInput],
108
+ actor: Optional[AuditLogSchemaActorInput] = None,
109
+ metadata: Optional[MetadataSchemaInput] = None,
110
+ idempotency_key: Optional[str] = None,
111
+ ) -> SyncOrAsync[AuditLogSchema]:
112
+ """Create an Audit Log schema for an action.
113
+
114
+ Kwargs:
115
+ action (str): The action name for the schema (e.g., 'user.signed_in').
116
+ targets (list): List of target definitions with type and optional metadata.
117
+ Each target has a 'type' and optional 'metadata' mapping property
118
+ names to types (e.g., {"status": "string"}).
119
+ actor (dict): Optional actor definition with metadata schema. (Optional)
120
+ The metadata maps property names to types (e.g., {"role": "string"}).
121
+ metadata (dict): Optional event-level metadata schema. (Optional)
122
+ Maps property names to types (e.g., {"invoice_id": "string"}).
123
+ idempotency_key (str): Idempotency key. (Optional)
124
+
125
+ Returns:
126
+ AuditLogSchema: The created audit log schema
127
+ """
128
+ ...
129
+
130
+ def list_schemas(
131
+ self,
132
+ *,
133
+ action: str,
134
+ limit: int = DEFAULT_LIST_RESPONSE_LIMIT,
135
+ before: Optional[str] = None,
136
+ after: Optional[str] = None,
137
+ order: PaginationOrder = "desc",
138
+ ) -> SyncOrAsync[AuditLogSchemasListResource]:
139
+ """List all schemas for an Audit Log action.
140
+
141
+ Kwargs:
142
+ action (str): The action name to list schemas for.
143
+ limit (int): Maximum number of records to return. (Optional)
144
+ before (str): Pagination cursor to receive records before a provided ID. (Optional)
145
+ after (str): Pagination cursor to receive records after a provided ID. (Optional)
146
+ order (Literal["asc","desc"]): Sort order by created_at timestamp. (Optional)
147
+
148
+ Returns:
149
+ AuditLogSchemasListResource: Paginated list of audit log schemas
150
+ """
151
+ ...
152
+
153
+ def list_actions(
154
+ self,
155
+ *,
156
+ limit: int = DEFAULT_LIST_RESPONSE_LIMIT,
157
+ before: Optional[str] = None,
158
+ after: Optional[str] = None,
159
+ order: PaginationOrder = "desc",
160
+ ) -> SyncOrAsync[AuditLogActionsListResource]:
161
+ """List all registered Audit Log actions.
162
+
163
+ Kwargs:
164
+ limit (int): Maximum number of records to return. (Optional)
165
+ before (str): Pagination cursor to receive records before a provided ID. (Optional)
166
+ after (str): Pagination cursor to receive records after a provided ID. (Optional)
167
+ order (Literal["asc","desc"]): Sort order by created_at timestamp. (Optional)
168
+
169
+ Returns:
170
+ AuditLogActionsListResource: Paginated list of audit log actions
171
+ """
172
+ ...
173
+
174
+ def get_retention(self, organization_id: str) -> SyncOrAsync[AuditLogRetention]:
175
+ """Get the event retention period for an organization.
176
+
177
+ Args:
178
+ organization_id (str): Organization's unique identifier.
179
+
180
+ Returns:
181
+ AuditLogRetention: The retention configuration
182
+ """
183
+ ...
184
+
185
+ def set_retention(
186
+ self,
187
+ *,
188
+ organization_id: str,
189
+ retention_period_in_days: Literal[30, 365],
190
+ ) -> SyncOrAsync[AuditLogRetention]:
191
+ """Set the event retention period for an organization.
192
+
193
+ Kwargs:
194
+ organization_id (str): Organization's unique identifier.
195
+ retention_period_in_days (int): The number of days to retain events (30 or 365).
196
+
197
+ Returns:
198
+ AuditLogRetention: The updated retention configuration
199
+ """
200
+ ...
201
+
202
+ def get_configuration(
203
+ self, organization_id: str
204
+ ) -> SyncOrAsync[AuditLogConfiguration]:
205
+ """Get the audit log configuration for an organization.
206
+
207
+ Args:
208
+ organization_id (str): Organization's unique identifier.
209
+
210
+ Returns:
211
+ AuditLogConfiguration: The complete audit log configuration
212
+ """
213
+ ...
214
+
215
+
216
+ class AuditLogs(AuditLogsModule):
217
+ _http_client: SyncHTTPClient
218
+
219
+ def __init__(self, http_client: SyncHTTPClient):
220
+ self._http_client = http_client
221
+
222
+ def create_event(
223
+ self,
224
+ *,
225
+ organization_id: str,
226
+ event: AuditLogEvent,
227
+ idempotency_key: Optional[str] = None,
228
+ ) -> None:
229
+ json = {"organization_id": organization_id, "event": event}
230
+
231
+ headers: Dict[str, str] = {}
232
+ if idempotency_key:
233
+ headers["idempotency-key"] = idempotency_key
234
+
235
+ self._http_client.request(
236
+ EVENTS_PATH, method=REQUEST_METHOD_POST, json=json, headers=headers
237
+ )
238
+
239
+ def create_export(
240
+ self,
241
+ *,
242
+ organization_id: str,
243
+ range_start: str,
244
+ range_end: str,
245
+ actions: Optional[Sequence[str]] = None,
246
+ targets: Optional[Sequence[str]] = None,
247
+ actor_names: Optional[Sequence[str]] = None,
248
+ actor_ids: Optional[Sequence[str]] = None,
249
+ ) -> AuditLogExport:
250
+ json = {
251
+ "actions": actions,
252
+ "actor_ids": actor_ids,
253
+ "actor_names": actor_names,
254
+ "organization_id": organization_id,
255
+ "range_start": range_start,
256
+ "range_end": range_end,
257
+ "targets": targets,
258
+ }
259
+
260
+ response = self._http_client.request(
261
+ EXPORTS_PATH, method=REQUEST_METHOD_POST, json=json
262
+ )
263
+
264
+ return AuditLogExport.model_validate(response)
265
+
266
+ def get_export(self, audit_log_export_id: str) -> AuditLogExport:
267
+ response = self._http_client.request(
268
+ f"{EXPORTS_PATH}/{audit_log_export_id}",
269
+ method=REQUEST_METHOD_GET,
270
+ )
271
+
272
+ return AuditLogExport.model_validate(response)
273
+
274
+ def create_schema(
275
+ self,
276
+ *,
277
+ action: str,
278
+ targets: Sequence[AuditLogSchemaTargetInput],
279
+ actor: Optional[AuditLogSchemaActorInput] = None,
280
+ metadata: Optional[MetadataSchemaInput] = None,
281
+ idempotency_key: Optional[str] = None,
282
+ ) -> AuditLogSchema:
283
+ json = serialize_schema_options(targets, actor, metadata)
284
+
285
+ headers: Dict[str, str] = {}
286
+ if idempotency_key:
287
+ headers["idempotency-key"] = idempotency_key
288
+
289
+ response = self._http_client.request(
290
+ f"{ACTIONS_PATH}/{action}/schemas",
291
+ method=REQUEST_METHOD_POST,
292
+ json=json,
293
+ headers=headers,
294
+ )
295
+
296
+ return AuditLogSchema.model_validate(response)
297
+
298
+ def list_schemas(
299
+ self,
300
+ *,
301
+ action: str,
302
+ limit: int = DEFAULT_LIST_RESPONSE_LIMIT,
303
+ before: Optional[str] = None,
304
+ after: Optional[str] = None,
305
+ order: PaginationOrder = "desc",
306
+ ) -> AuditLogSchemasListResource:
307
+ list_params: AuditLogSchemaListFilters = {
308
+ "limit": limit,
309
+ "before": before,
310
+ "after": after,
311
+ "order": order,
312
+ }
313
+
314
+ response = self._http_client.request(
315
+ f"{ACTIONS_PATH}/{action}/schemas",
316
+ method=REQUEST_METHOD_GET,
317
+ params=list_params,
318
+ )
319
+
320
+ return WorkOSListResource[
321
+ AuditLogSchema, AuditLogSchemaListFilters, ListMetadata
322
+ ](
323
+ list_method=lambda **kwargs: self.list_schemas(action=action, **kwargs),
324
+ list_args=list_params,
325
+ **ListPage[AuditLogSchema](**response).model_dump(),
326
+ )
327
+
328
+ def list_actions(
329
+ self,
330
+ *,
331
+ limit: int = DEFAULT_LIST_RESPONSE_LIMIT,
332
+ before: Optional[str] = None,
333
+ after: Optional[str] = None,
334
+ order: PaginationOrder = "desc",
335
+ ) -> AuditLogActionsListResource:
336
+ list_params: AuditLogActionListFilters = {
337
+ "limit": limit,
338
+ "before": before,
339
+ "after": after,
340
+ "order": order,
341
+ }
342
+
343
+ response = self._http_client.request(
344
+ ACTIONS_PATH,
345
+ method=REQUEST_METHOD_GET,
346
+ params=list_params,
347
+ )
348
+
349
+ return WorkOSListResource[
350
+ AuditLogAction, AuditLogActionListFilters, ListMetadata
351
+ ](
352
+ list_method=self.list_actions,
353
+ list_args=list_params,
354
+ **ListPage[AuditLogAction](**response).model_dump(),
355
+ )
356
+
357
+ def get_retention(self, organization_id: str) -> AuditLogRetention:
358
+ response = self._http_client.request(
359
+ f"organizations/{organization_id}/audit_logs_retention",
360
+ method=REQUEST_METHOD_GET,
361
+ )
362
+
363
+ return AuditLogRetention.model_validate(response)
364
+
365
+ def set_retention(
366
+ self,
367
+ *,
368
+ organization_id: str,
369
+ retention_period_in_days: Literal[30, 365],
370
+ ) -> AuditLogRetention:
371
+ json = {"retention_period_in_days": retention_period_in_days}
372
+
373
+ response = self._http_client.request(
374
+ f"organizations/{organization_id}/audit_logs_retention",
375
+ method=REQUEST_METHOD_PUT,
376
+ json=json,
377
+ )
378
+
379
+ return AuditLogRetention.model_validate(response)
380
+
381
+ def get_configuration(self, organization_id: str) -> AuditLogConfiguration:
382
+ response = self._http_client.request(
383
+ f"organizations/{organization_id}/audit_log_configuration",
384
+ method=REQUEST_METHOD_GET,
385
+ )
386
+
387
+ return AuditLogConfiguration.model_validate(response)
388
+
389
+
390
+ class AsyncAuditLogs(AuditLogsModule):
391
+ _http_client: AsyncHTTPClient
392
+
393
+ def __init__(self, http_client: AsyncHTTPClient):
394
+ self._http_client = http_client
395
+
396
+ async def create_event(
397
+ self,
398
+ *,
399
+ organization_id: str,
400
+ event: AuditLogEvent,
401
+ idempotency_key: Optional[str] = None,
402
+ ) -> None:
403
+ json = {"organization_id": organization_id, "event": event}
404
+
405
+ headers: Dict[str, str] = {}
406
+ if idempotency_key:
407
+ headers["idempotency-key"] = idempotency_key
408
+
409
+ await self._http_client.request(
410
+ EVENTS_PATH, method=REQUEST_METHOD_POST, json=json, headers=headers
411
+ )
412
+
413
+ async def create_export(
414
+ self,
415
+ *,
416
+ organization_id: str,
417
+ range_start: str,
418
+ range_end: str,
419
+ actions: Optional[Sequence[str]] = None,
420
+ targets: Optional[Sequence[str]] = None,
421
+ actor_names: Optional[Sequence[str]] = None,
422
+ actor_ids: Optional[Sequence[str]] = None,
423
+ ) -> AuditLogExport:
424
+ json = {
425
+ "actions": actions,
426
+ "actor_ids": actor_ids,
427
+ "actor_names": actor_names,
428
+ "organization_id": organization_id,
429
+ "range_start": range_start,
430
+ "range_end": range_end,
431
+ "targets": targets,
432
+ }
433
+
434
+ response = await self._http_client.request(
435
+ EXPORTS_PATH, method=REQUEST_METHOD_POST, json=json
436
+ )
437
+
438
+ return AuditLogExport.model_validate(response)
439
+
440
+ async def get_export(self, audit_log_export_id: str) -> AuditLogExport:
441
+ response = await self._http_client.request(
442
+ f"{EXPORTS_PATH}/{audit_log_export_id}",
443
+ method=REQUEST_METHOD_GET,
444
+ )
445
+
446
+ return AuditLogExport.model_validate(response)
447
+
448
+ async def create_schema(
449
+ self,
450
+ *,
451
+ action: str,
452
+ targets: Sequence[AuditLogSchemaTargetInput],
453
+ actor: Optional[AuditLogSchemaActorInput] = None,
454
+ metadata: Optional[MetadataSchemaInput] = None,
455
+ idempotency_key: Optional[str] = None,
456
+ ) -> AuditLogSchema:
457
+ json = serialize_schema_options(targets, actor, metadata)
458
+
459
+ headers: Dict[str, str] = {}
460
+ if idempotency_key:
461
+ headers["idempotency-key"] = idempotency_key
462
+
463
+ response = await self._http_client.request(
464
+ f"{ACTIONS_PATH}/{action}/schemas",
465
+ method=REQUEST_METHOD_POST,
466
+ json=json,
467
+ headers=headers,
468
+ )
469
+
470
+ return AuditLogSchema.model_validate(response)
471
+
472
+ async def list_schemas(
473
+ self,
474
+ *,
475
+ action: str,
476
+ limit: int = DEFAULT_LIST_RESPONSE_LIMIT,
477
+ before: Optional[str] = None,
478
+ after: Optional[str] = None,
479
+ order: PaginationOrder = "desc",
480
+ ) -> AuditLogSchemasListResource:
481
+ list_params: AuditLogSchemaListFilters = {
482
+ "limit": limit,
483
+ "before": before,
484
+ "after": after,
485
+ "order": order,
486
+ }
487
+
488
+ response = await self._http_client.request(
489
+ f"{ACTIONS_PATH}/{action}/schemas",
490
+ method=REQUEST_METHOD_GET,
491
+ params=list_params,
492
+ )
493
+
494
+ return WorkOSListResource[
495
+ AuditLogSchema, AuditLogSchemaListFilters, ListMetadata
496
+ ](
497
+ list_method=lambda **kwargs: self.list_schemas(action=action, **kwargs),
498
+ list_args=list_params,
499
+ **ListPage[AuditLogSchema](**response).model_dump(),
500
+ )
501
+
502
+ async def list_actions(
503
+ self,
504
+ *,
505
+ limit: int = DEFAULT_LIST_RESPONSE_LIMIT,
506
+ before: Optional[str] = None,
507
+ after: Optional[str] = None,
508
+ order: PaginationOrder = "desc",
509
+ ) -> AuditLogActionsListResource:
510
+ list_params: AuditLogActionListFilters = {
511
+ "limit": limit,
512
+ "before": before,
513
+ "after": after,
514
+ "order": order,
515
+ }
516
+
517
+ response = await self._http_client.request(
518
+ ACTIONS_PATH,
519
+ method=REQUEST_METHOD_GET,
520
+ params=list_params,
521
+ )
522
+
523
+ return WorkOSListResource[
524
+ AuditLogAction, AuditLogActionListFilters, ListMetadata
525
+ ](
526
+ list_method=self.list_actions,
527
+ list_args=list_params,
528
+ **ListPage[AuditLogAction](**response).model_dump(),
529
+ )
530
+
531
+ async def get_retention(self, organization_id: str) -> AuditLogRetention:
532
+ response = await self._http_client.request(
533
+ f"organizations/{organization_id}/audit_logs_retention",
534
+ method=REQUEST_METHOD_GET,
535
+ )
536
+
537
+ return AuditLogRetention.model_validate(response)
538
+
539
+ async def set_retention(
540
+ self,
541
+ *,
542
+ organization_id: str,
543
+ retention_period_in_days: Literal[30, 365],
544
+ ) -> AuditLogRetention:
545
+ json = {"retention_period_in_days": retention_period_in_days}
546
+
547
+ response = await self._http_client.request(
548
+ f"organizations/{organization_id}/audit_logs_retention",
549
+ method=REQUEST_METHOD_PUT,
550
+ json=json,
551
+ )
552
+
553
+ return AuditLogRetention.model_validate(response)
554
+
555
+ async def get_configuration(self, organization_id: str) -> AuditLogConfiguration:
556
+ response = await self._http_client.request(
557
+ f"organizations/{organization_id}/audit_log_configuration",
558
+ method=REQUEST_METHOD_GET,
559
+ )
560
+
561
+ return AuditLogConfiguration.model_validate(response)
@@ -1,6 +1,12 @@
1
+ from .audit_log_action import *
2
+ from .audit_log_configuration import *
1
3
  from .audit_log_event_actor import *
2
4
  from .audit_log_event_context import *
3
5
  from .audit_log_event_target import *
4
6
  from .audit_log_event import *
5
7
  from .audit_log_export import *
6
8
  from .audit_log_metadata import *
9
+ from .audit_log_retention import *
10
+ from .audit_log_schema import *
11
+ from .audit_log_schema_input import *
12
+ from .list_filters import *
@@ -0,0 +1,28 @@
1
+ import warnings
2
+ from typing import Literal
3
+
4
+ from workos.types.audit_logs.audit_log_schema import AuditLogSchema
5
+ from workos.types.workos_model import WorkOSModel
6
+
7
+ # Suppress Pydantic warning about 'schema' shadowing BaseModel.schema()
8
+ # (a deprecated method replaced by model_json_schema() in Pydantic v2)
9
+ warnings.filterwarnings(
10
+ "ignore",
11
+ message='Field name "schema" in "AuditLogAction" shadows an attribute',
12
+ category=UserWarning,
13
+ )
14
+
15
+
16
+ class AuditLogAction(WorkOSModel):
17
+ """Representation of a WorkOS audit log action.
18
+
19
+ An audit log action represents a configured action type that can be
20
+ used in audit log events. Each action has an associated schema that
21
+ defines the structure of events for that action.
22
+ """
23
+
24
+ object: Literal["audit_log_action"]
25
+ name: str
26
+ schema: AuditLogSchema # type: ignore[assignment]
27
+ created_at: str
28
+ updated_at: str
@@ -0,0 +1,41 @@
1
+ from typing import Literal, Optional
2
+
3
+ from workos.types.workos_model import WorkOSModel
4
+ from workos.typing.literals import LiteralOrUntyped
5
+
6
+
7
+ AuditLogStreamType = Literal[
8
+ "Datadog", "Splunk", "S3", "GoogleCloudStorage", "GenericHttps"
9
+ ]
10
+
11
+ AuditLogStreamState = Literal["active", "inactive", "error", "invalid"]
12
+
13
+ AuditLogTrailState = Literal["active", "inactive", "disabled"]
14
+
15
+
16
+ class AuditLogStream(WorkOSModel):
17
+ """Representation of a WorkOS audit log stream.
18
+
19
+ An audit log stream sends audit log events to an external destination
20
+ such as Datadog, Splunk, S3, Google Cloud Storage, or a custom HTTPS endpoint.
21
+ """
22
+
23
+ id: str
24
+ type: LiteralOrUntyped[AuditLogStreamType]
25
+ state: LiteralOrUntyped[AuditLogStreamState]
26
+ last_synced_at: Optional[str] = None
27
+ created_at: str
28
+
29
+
30
+ class AuditLogConfiguration(WorkOSModel):
31
+ """Representation of a WorkOS audit log configuration for an organization.
32
+
33
+ The audit log configuration provides a single view of an organization's
34
+ audit logging setup, including retention settings, state, and optional
35
+ log stream configuration.
36
+ """
37
+
38
+ organization_id: str
39
+ retention_period_in_days: int
40
+ state: LiteralOrUntyped[AuditLogTrailState]
41
+ log_stream: Optional[AuditLogStream] = None
@@ -0,0 +1,13 @@
1
+ from typing import Optional
2
+
3
+ from workos.types.workos_model import WorkOSModel
4
+
5
+
6
+ class AuditLogRetention(WorkOSModel):
7
+ """Representation of a WorkOS audit log retention configuration.
8
+
9
+ Specifies how long audit log events are retained for an organization.
10
+ Valid values are 30 and 365 days, or None if not configured.
11
+ """
12
+
13
+ retention_period_in_days: Optional[int] = None