Skip to content

Commit ffdf169

Browse files
committed
Refactored types and updated where session is exposed based on review feedback
1 parent 01d9bd4 commit ffdf169

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

workos/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from workos.client import SyncClient as WorkOSClient
22
from workos.async_client import AsyncClient as AsyncWorkOSClient
3-
from workos.types.user_management.session import Session as Session
43

5-
__all__ = ["WorkOSClient", "AsyncWorkOSClient", "Session"]
4+
__all__ = ["WorkOSClient", "AsyncWorkOSClient"]

workos/types/user_management/session.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,19 @@ class SessionConfig(TypedDict, total=False):
4848
cookie_password: str
4949

5050

51+
AuthMethodType = Literal[
52+
"external_auth",
53+
"impersonation",
54+
"magic_code",
55+
"migrated_session",
56+
"oauth",
57+
"passkey",
58+
"password",
59+
"sso",
60+
"unknown",
61+
]
62+
63+
5164
class Session(WorkOSModel):
5265
"""Representation of a WorkOS User Management Session."""
5366

@@ -56,10 +69,11 @@ class Session(WorkOSModel):
5669
user_id: str
5770
organization_id: Optional[str] = None
5871
status: str
59-
auth_method: Optional[str] = None
72+
auth_method: AuthMethodType
73+
impersonator: Optional[Impersonator] = None
6074
ip_address: Optional[str] = None
6175
user_agent: Optional[str] = None
62-
expires_at: Optional[str] = None
76+
expires_at: str
6377
ended_at: Optional[str] = None
6478
created_at: str
6579
updated_at: str

workos/user_management.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,13 +1404,13 @@ def list_sessions(
14041404
self,
14051405
*,
14061406
user_id: str,
1407-
limit: Optional[int] = None,
1407+
limit: Optional[int] = DEFAULT_LIST_RESPONSE_LIMIT,
14081408
before: Optional[str] = None,
14091409
after: Optional[str] = None,
14101410
order: Optional[PaginationOrder] = None,
14111411
) -> "SessionsListResource":
14121412
params: ListArgs = {
1413-
"limit": limit or DEFAULT_LIST_RESPONSE_LIMIT,
1413+
"limit": limit,
14141414
"before": before,
14151415
"after": after,
14161416
"order": order,
@@ -1423,7 +1423,7 @@ def list_sessions(
14231423
)
14241424

14251425
list_args: SessionsListFilters = {
1426-
"limit": limit or DEFAULT_LIST_RESPONSE_LIMIT,
1426+
"limit": limit,
14271427
"before": before,
14281428
"after": after,
14291429
"order": order,
@@ -2105,13 +2105,13 @@ async def list_sessions(
21052105
self,
21062106
*,
21072107
user_id: str,
2108-
limit: Optional[int] = None,
2108+
limit: Optional[int] = DEFAULT_LIST_RESPONSE_LIMIT,
21092109
before: Optional[str] = None,
21102110
after: Optional[str] = None,
21112111
order: Optional[PaginationOrder] = None,
21122112
) -> "SessionsListResource":
21132113
params: ListArgs = {
2114-
"limit": limit or DEFAULT_LIST_RESPONSE_LIMIT,
2114+
"limit": limit,
21152115
"before": before,
21162116
"after": after,
21172117
"order": order,
@@ -2124,7 +2124,7 @@ async def list_sessions(
21242124
)
21252125

21262126
list_args: SessionsListFilters = {
2127-
"limit": limit or DEFAULT_LIST_RESPONSE_LIMIT,
2127+
"limit": limit,
21282128
"before": before,
21292129
"after": after,
21302130
"order": order,

0 commit comments

Comments
 (0)