Skip to content

Commit 4483636

Browse files
birdcargjtorikian
andauthored
Implement the remaining Audit Logs functionality (#515)
* Add the rest of the Audit Logs implementation * Replace asyncio.iscoroutinefunction with inspect Starting in Python 3.14, use of `asyncio.iscoroutinefunction` emits a deprecation warning (c.f. python/cpython#122858). The recommendation is to use inspect.iscoroutinefunction instead. * Use 'schema' field and handle pydantic's warning * Test sync and async variants propertly * it's in now * feat(audit-logs): Add typed inputs for create_schema Introduces TypedDict definitions for the simplified schema input format: - AuditLogSchemaTargetInput for target definitions - AuditLogSchemaActorInput for actor definitions - MetadataSchemaInput for metadata field type mappings Also adds serialize_schema_options() to transform the simplified format (e.g., {"status": "string"}) to the full JSON Schema format expected by the API. * refactor(audit-logs): Use typed inputs in create_schema Replaces generic Mapping[str, Any] parameters with the new typed inputs. Uses shared serialize_schema_options() function instead of inline JSON building, reducing duplication between sync and async implementations. * fix(audit-logs): Make optional fields nullable in response models The API can return null for actor in AuditLogSchema (when no custom metadata defined) and for retention_period_in_days in AuditLogRetention (when not configured). Updated models to accept None. * test(audit-logs): Update tests for simplified input format Updates create_schema tests to use the new simplified input format and verifies the serialization to full JSON Schema format. Adds edge case tests for nullable fields (actor in schema, retention_period_in_days). --------- Co-authored-by: Garen Torikian <gjtorikian@users.noreply.github.com>
1 parent bf23a30 commit 4483636

13 files changed

+1340
-79
lines changed

src/workos/async_client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from importlib.metadata import version
33
from workos._base_client import BaseClient
44
from workos.api_keys import AsyncApiKeys
5-
from workos.audit_logs import AuditLogsModule
5+
from workos.audit_logs import AsyncAuditLogs
66
from workos.directory_sync import AsyncDirectorySync
77
from workos.events import AsyncEvents
88
from workos.fga import FGAModule
@@ -64,10 +64,10 @@ def sso(self) -> AsyncSSO:
6464
return self._sso
6565

6666
@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
7171

7272
@property
7373
def directory_sync(self) -> AsyncDirectorySync:

0 commit comments

Comments
 (0)