Skip to content

Commit 600f046

Browse files
committed
wire ApiKey module through clients
1 parent b4d4ff4 commit 600f046

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

tests/test_client.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ def test_client_with_api_key_and_client_id_environment_variables(self):
3737
os.environ.pop("WORKOS_API_KEY")
3838
os.environ.pop("WORKOS_CLIENT_ID")
3939

40+
def test_initialize_api_keys(self, default_client):
41+
assert bool(default_client.api_keys)
42+
4043
def test_initialize_sso(self, default_client):
4144
assert bool(default_client.sso)
4245

@@ -112,6 +115,9 @@ def test_client_with_api_key_and_client_id_environment_variables(self):
112115
os.environ.pop("WORKOS_API_KEY")
113116
os.environ.pop("WORKOS_CLIENT_ID")
114117

118+
def test_initialize_api_keys(self, default_client):
119+
assert bool(default_client.api_keys)
120+
115121
def test_initialize_directory_sync(self, default_client):
116122
assert bool(default_client.directory_sync)
117123

workos/_base_client.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from workos.fga import FGAModule
77
from workos.utils._base_http_client import DEFAULT_REQUEST_TIMEOUT
88
from workos.utils.http_client import HTTPClient
9+
from workos.api_key import ApiKeyModule
910
from workos.audit_logs import AuditLogsModule
1011
from workos.directory_sync import DirectorySyncModule
1112
from workos.events import EventsModule
@@ -65,6 +66,10 @@ def __init__(
6566
else int(os.getenv("WORKOS_REQUEST_TIMEOUT", DEFAULT_REQUEST_TIMEOUT))
6667
)
6768

69+
@property
70+
@abstractmethod
71+
def api_keys(self) -> ApiKeyModule: ...
72+
6873
@property
6974
@abstractmethod
7075
def audit_logs(self) -> AuditLogsModule: ...

workos/async_client.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import Optional
22
from workos.__about__ import __version__
33
from workos._base_client import BaseClient
4+
from workos.api_key import AsyncApiKey
45
from workos.audit_logs import AuditLogsModule
56
from workos.directory_sync import AsyncDirectorySync
67
from workos.events import AsyncEvents
@@ -45,6 +46,12 @@ def __init__(
4546
timeout=self.request_timeout,
4647
)
4748

49+
@property
50+
def api_keys(self) -> AsyncApiKey:
51+
if not getattr(self, "_api_keys", None):
52+
self._api_keys = AsyncApiKey(self._http_client)
53+
return self._api_keys
54+
4855
@property
4956
def sso(self) -> AsyncSSO:
5057
if not getattr(self, "_sso", None):

workos/client.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import Optional
22
from workos.__about__ import __version__
33
from workos._base_client import BaseClient
4+
from workos.api_key import ApiKey
45
from workos.audit_logs import AuditLogs
56
from workos.directory_sync import DirectorySync
67
from workos.fga import FGA
@@ -45,6 +46,12 @@ def __init__(
4546
timeout=self.request_timeout,
4647
)
4748

49+
@property
50+
def api_keys(self) -> ApiKey:
51+
if not getattr(self, "_api_keys", None):
52+
self._api_keys = ApiKey(self._http_client)
53+
return self._api_keys
54+
4855
@property
4956
def sso(self) -> SSO:
5057
if not getattr(self, "_sso", None):

0 commit comments

Comments
 (0)