Skip to content

Commit 245994b

Browse files
gjtorikianclaude
andcommitted
feat: rename client classes to WorkOSClient / AsyncWorkOSClient
Regenerate SDK with Client suffix restored on all client classes. Also fixes hand-maintained files (session, passwordless, vault, public_client) and adds TYPE_CHECKING imports for forward-ref return types. Updates migration guide accordingly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 711b4ec commit 245994b

47 files changed

Lines changed: 605 additions & 529 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/V6_MIGRATION_GUIDE.md

Lines changed: 217 additions & 287 deletions
Large diffs are not rendered by default.

src/workos/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
"""WorkOS Python SDK."""
44

5-
from ._client import AsyncWorkOS, WorkOS
5+
from ._client import AsyncWorkOSClient, WorkOSClient
66
from ._errors import WorkOSError
77
from ._pagination import AsyncPage, ListMetadata, SyncPage
88
from ._types import RequestOptions
99

1010
__all__ = [
11-
"WorkOS",
12-
"AsyncWorkOS",
11+
"WorkOSClient",
12+
"AsyncWorkOSClient",
1313
"WorkOSError",
1414
"SyncPage",
1515
"AsyncPage",

src/workos/_client.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
RETRY_MULTIPLIER = 2
6767

6868

69-
class _BaseWorkOS:
69+
class _BaseWorkOSClient:
7070
"""Shared WorkOS client implementation."""
7171

7272
def __init__(
@@ -140,7 +140,7 @@ def _calculate_retry_delay(
140140
attempt: int, retry_after: Optional[str] = None
141141
) -> float:
142142
"""Calculate retry delay with exponential backoff and jitter."""
143-
parsed_retry_after = _BaseWorkOS._parse_retry_after(retry_after)
143+
parsed_retry_after = _BaseWorkOSClient._parse_retry_after(retry_after)
144144
if parsed_retry_after is not None:
145145
return parsed_retry_after
146146
delay = min(INITIAL_RETRY_DELAY * (RETRY_MULTIPLIER**attempt), MAX_RETRY_DELAY)
@@ -253,7 +253,7 @@ def _raise_error(response: httpx.Response) -> None:
253253
error_class = STATUS_CODE_TO_ERROR.get(response.status_code)
254254
if error_class:
255255
if error_class is RateLimitExceededError:
256-
retry_after = _BaseWorkOS._parse_retry_after(
256+
retry_after = _BaseWorkOSClient._parse_retry_after(
257257
response.headers.get("Retry-After")
258258
)
259259
raise RateLimitExceededError(
@@ -320,7 +320,7 @@ def _raise_error(response: httpx.Response) -> None:
320320
)
321321

322322

323-
class WorkOS(_BaseWorkOS):
323+
class WorkOSClient(_BaseWorkOSClient):
324324
"""Synchronous WorkOS API client."""
325325

326326
def __init__(
@@ -362,7 +362,7 @@ def close(self) -> None:
362362
"""Close the underlying HTTP client and release resources."""
363363
self._client.close()
364364

365-
def __enter__(self) -> "WorkOS":
365+
def __enter__(self) -> "WorkOSClient":
366366
return self
367367

368368
def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None:
@@ -579,7 +579,7 @@ def _fetch(*, after: Optional[str] = None) -> SyncPage[D]:
579579
return SyncPage(data=items, list_metadata=list_metadata, _fetch_page=_fetch)
580580

581581

582-
class AsyncWorkOS(_BaseWorkOS):
582+
class AsyncWorkOSClient(_BaseWorkOSClient):
583583
"""Asynchronous WorkOS API client."""
584584

585585
def __init__(
@@ -621,7 +621,7 @@ async def close(self) -> None:
621621
"""Close the underlying HTTP client and release resources."""
622622
await self._client.aclose()
623623

624-
async def __aenter__(self) -> "AsyncWorkOS":
624+
async def __aenter__(self) -> "AsyncWorkOSClient":
625625
return self
626626

627627
async def __aexit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None:

src/workos/admin_portal/_resource.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
66

77
if TYPE_CHECKING:
8-
from .._client import AsyncWorkOS, WorkOS
8+
from .._client import AsyncWorkOSClient, WorkOSClient
99

1010
from .._types import RequestOptions, enum_value
1111
from .models import IntentOptions, PortalLinkResponse
@@ -15,7 +15,7 @@
1515
class AdminPortal:
1616
"""Admin Portal API resources."""
1717

18-
def __init__(self, client: "WorkOS") -> None:
18+
def __init__(self, client: "WorkOSClient") -> None:
1919
self._client = client
2020

2121
def generate_link(
@@ -85,7 +85,7 @@ def generate_link(
8585
class AsyncAdminPortal:
8686
"""Admin Portal API resources (async)."""
8787

88-
def __init__(self, client: "AsyncWorkOS") -> None:
88+
def __init__(self, client: "AsyncWorkOSClient") -> None:
8989
self._client = client
9090

9191
async def generate_link(

src/workos/api_keys/_resource.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
66

77
if TYPE_CHECKING:
8-
from .._client import AsyncWorkOS, WorkOS
8+
from .._client import AsyncWorkOSClient, WorkOSClient
99

1010
from .._types import RequestOptions, enum_value
1111
from .models import ApiKey, ApiKeyValidationResponse, ApiKeyWithValue
@@ -16,7 +16,7 @@
1616
class ApiKeys:
1717
"""Api Keys API resources."""
1818

19-
def __init__(self, client: "WorkOS") -> None:
19+
def __init__(self, client: "WorkOSClient") -> None:
2020
self._client = client
2121

2222
def create_validations(
@@ -176,7 +176,7 @@ def create_organization_api_keys(
176176
class AsyncApiKeys:
177177
"""Api Keys API resources (async)."""
178178

179-
def __init__(self, client: "AsyncWorkOS") -> None:
179+
def __init__(self, client: "AsyncWorkOSClient") -> None:
180180
self._client = client
181181

182182
async def create_validations(

src/workos/audit_logs/_resource.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
66

77
if TYPE_CHECKING:
8-
from .._client import AsyncWorkOS, WorkOS
8+
from .._client import AsyncWorkOSClient, WorkOSClient
99

1010
from .._types import RequestOptions, enum_value
1111
from .models import (
@@ -25,7 +25,7 @@
2525
class AuditLogs:
2626
"""Audit Logs API resources."""
2727

28-
def __init__(self, client: "WorkOS") -> None:
28+
def __init__(self, client: "WorkOSClient") -> None:
2929
self._client = client
3030

3131
def list_organization_audit_logs_retention(
@@ -380,7 +380,7 @@ def get_export(
380380
class AsyncAuditLogs:
381381
"""Audit Logs API resources (async)."""
382382

383-
def __init__(self, client: "AsyncWorkOS") -> None:
383+
def __init__(self, client: "AsyncWorkOSClient") -> None:
384384
self._client = client
385385

386386
async def list_organization_audit_logs_retention(

src/workos/authorization/_resource.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
66

77
if TYPE_CHECKING:
8-
from .._client import AsyncWorkOS, WorkOS
8+
from .._client import AsyncWorkOSClient, WorkOSClient
99

1010
from .._types import RequestOptions, enum_value
1111
from .models import (
@@ -26,7 +26,7 @@
2626
class Authorization:
2727
"""Authorization API resources."""
2828

29-
def __init__(self, client: "WorkOS") -> None:
29+
def __init__(self, client: "WorkOSClient") -> None:
3030
self._client = client
3131

3232
def check_organization_membership(
@@ -1580,7 +1580,7 @@ def delete_permission(
15801580
class AsyncAuthorization:
15811581
"""Authorization API resources (async)."""
15821582

1583-
def __init__(self, client: "AsyncWorkOS") -> None:
1583+
def __init__(self, client: "AsyncWorkOSClient") -> None:
15841584
self._client = client
15851585

15861586
async def check_organization_membership(

src/workos/connect/_resource.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union, cast
66

77
if TYPE_CHECKING:
8-
from .._client import AsyncWorkOS, WorkOS
8+
from .._client import AsyncWorkOSClient, WorkOSClient
99

1010
from .._types import RequestOptions, enum_value
1111
from .models import (
@@ -26,7 +26,7 @@
2626
class Connect:
2727
"""Connect API resources."""
2828

29-
def __init__(self, client: "WorkOS") -> None:
29+
def __init__(self, client: "WorkOSClient") -> None:
3030
self._client = client
3131

3232
def complete_oauth2(
@@ -446,7 +446,7 @@ def delete_client_secret(
446446
class AsyncConnect:
447447
"""Connect API resources (async)."""
448448

449-
def __init__(self, client: "AsyncWorkOS") -> None:
449+
def __init__(self, client: "AsyncWorkOSClient") -> None:
450450
self._client = client
451451

452452
async def complete_oauth2(

src/workos/directory_sync/_resource.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from typing import TYPE_CHECKING, Optional, Union
66

77
if TYPE_CHECKING:
8-
from .._client import AsyncWorkOS, WorkOS
8+
from .._client import AsyncWorkOSClient, WorkOSClient
99

1010
from .._types import RequestOptions, enum_value
1111
from .models import Directory, DirectoryGroup, DirectoryUserWithGroups
@@ -16,7 +16,7 @@
1616
class DirectorySync:
1717
"""Directory Sync API resources."""
1818

19-
def __init__(self, client: "WorkOS") -> None:
19+
def __init__(self, client: "WorkOSClient") -> None:
2020
self._client = client
2121

2222
def list_directories(
@@ -309,7 +309,7 @@ def get_directory_user(
309309
class AsyncDirectorySync:
310310
"""Directory Sync API resources (async)."""
311311

312-
def __init__(self, client: "AsyncWorkOS") -> None:
312+
def __init__(self, client: "AsyncWorkOSClient") -> None:
313313
self._client = client
314314

315315
async def list_directories(

src/workos/events/_resource.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from typing import TYPE_CHECKING, List, Optional, Union
66

77
if TYPE_CHECKING:
8-
from .._client import AsyncWorkOS, WorkOS
8+
from .._client import AsyncWorkOSClient, WorkOSClient
99

1010
from .._types import RequestOptions, enum_value
1111
from .models import EventSchema
@@ -16,7 +16,7 @@
1616
class Events:
1717
"""Events API resources."""
1818

19-
def __init__(self, client: "WorkOS") -> None:
19+
def __init__(self, client: "WorkOSClient") -> None:
2020
self._client = client
2121

2222
def list_events(
@@ -83,7 +83,7 @@ def list_events(
8383
class AsyncEvents:
8484
"""Events API resources (async)."""
8585

86-
def __init__(self, client: "AsyncWorkOS") -> None:
86+
def __init__(self, client: "AsyncWorkOSClient") -> None:
8787
self._client = client
8888

8989
async def list_events(

0 commit comments

Comments
 (0)