Skip to content

Commit 8237b70

Browse files
committed
slight corrections
1 parent aada6c0 commit 8237b70

File tree

7 files changed

+32
-15
lines changed

7 files changed

+32
-15
lines changed

src/workos/admin_portal/_resource.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
5+
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
66

77
if TYPE_CHECKING:
88
from .._client import AsyncWorkOSClient, WorkOSClient
@@ -26,6 +26,7 @@ def generate_link(
2626
success_url: Optional[str] = None,
2727
intent: Optional[Union[GenerateLinkIntent, str]] = None,
2828
intent_options: Optional[IntentOptions] = None,
29+
admin_emails: Optional[List[str]] = None,
2930
request_options: Optional[RequestOptions] = None,
3031
) -> PortalLinkResponse:
3132
"""Generate a Portal Link
@@ -45,6 +46,7 @@ def generate_link(
4546
- `certificate_renewal` - Launch Admin Portal for renewing SAML Certificates
4647
- `bring_your_own_key` - Launch Admin Portal for configuring Bring Your Own Key
4748
intent_options: Options to configure the Admin Portal based on the intent.
49+
admin_emails: The email addresses of the IT admins to grant access to the Admin Portal for the given organization. Accepts up to 20 emails.
4850
request_options: Per-request options. Supports extra_headers, timeout, max_retries, and base_url override.
4951
5052
Returns:
@@ -69,6 +71,7 @@ def generate_link(
6971
"intent_options": intent_options.to_dict()
7072
if intent_options is not None
7173
else None,
74+
"admin_emails": admin_emails,
7275
}.items()
7376
if v is not None
7477
}
@@ -95,6 +98,7 @@ async def generate_link(
9598
success_url: Optional[str] = None,
9699
intent: Optional[Union[GenerateLinkIntent, str]] = None,
97100
intent_options: Optional[IntentOptions] = None,
101+
admin_emails: Optional[List[str]] = None,
98102
request_options: Optional[RequestOptions] = None,
99103
) -> PortalLinkResponse:
100104
"""Generate a Portal Link
@@ -114,6 +118,7 @@ async def generate_link(
114118
- `certificate_renewal` - Launch Admin Portal for renewing SAML Certificates
115119
- `bring_your_own_key` - Launch Admin Portal for configuring Bring Your Own Key
116120
intent_options: Options to configure the Admin Portal based on the intent.
121+
admin_emails: The email addresses of the IT admins to grant access to the Admin Portal for the given organization. Accepts up to 20 emails.
117122
request_options: Per-request options. Supports extra_headers, timeout, max_retries, and base_url override.
118123
119124
Returns:
@@ -138,6 +143,7 @@ async def generate_link(
138143
"intent_options": intent_options.to_dict()
139144
if intent_options is not None
140145
else None,
146+
"admin_emails": admin_emails,
141147
}.items()
142148
if v is not None
143149
}

src/workos/admin_portal/models/generate_link.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from dataclasses import dataclass
66
from enum import Enum
77
from typing import cast
8-
from typing import Any, Dict, Optional
8+
from typing import Any, Dict, List, Optional
99
from workos._types import _raise_deserialize_error
1010

1111
from .intent_options import IntentOptions
@@ -34,6 +34,8 @@ class GenerateLink:
3434
- `bring_your_own_key` - Launch Admin Portal for configuring Bring Your Own Key"""
3535
intent_options: Optional["IntentOptions"] = None
3636
"""Options to configure the Admin Portal based on the intent."""
37+
admin_emails: Optional[List[str]] = None
38+
"""The email addresses of the IT admins to grant access to the Admin Portal for the given organization. Accepts up to 20 emails."""
3739

3840
@classmethod
3941
def from_dict(cls, data: Dict[str, Any]) -> "GenerateLink":
@@ -49,6 +51,7 @@ def from_dict(cls, data: Dict[str, Any]) -> "GenerateLink":
4951
intent_options=IntentOptions.from_dict(cast(Dict[str, Any], _v))
5052
if (_v := data.get("intent_options")) is not None
5153
else None,
54+
admin_emails=data.get("admin_emails"),
5255
)
5356
except (KeyError, ValueError) as e:
5457
_raise_deserialize_error("GenerateLink", e)
@@ -67,4 +70,6 @@ def to_dict(self) -> Dict[str, Any]:
6770
)
6871
if self.intent_options is not None:
6972
result["intent_options"] = self.intent_options.to_dict()
73+
if self.admin_emails is not None:
74+
result["admin_emails"] = self.admin_emails
7075
return result

src/workos/api_keys/models/api_key.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class ApiKey:
2626
"""A descriptive name for the API Key."""
2727
obfuscated_value: str
2828
"""An obfuscated representation of the API Key value."""
29-
last_used_at: Optional[str]
29+
last_used_at: Optional[datetime]
3030
"""Timestamp of when the API Key was last used."""
3131
permissions: List[str]
3232
"""The permission slugs assigned to the API Key."""
@@ -45,7 +45,9 @@ def from_dict(cls, data: Dict[str, Any]) -> "ApiKey":
4545
owner=ApiKeyOwner.from_dict(cast(Dict[str, Any], data["owner"])),
4646
name=data["name"],
4747
obfuscated_value=data["obfuscated_value"],
48-
last_used_at=data["last_used_at"],
48+
last_used_at=_parse_datetime(_v)
49+
if (_v := data["last_used_at"]) is not None
50+
else None,
4951
permissions=data["permissions"],
5052
created_at=_parse_datetime(data["created_at"]),
5153
updated_at=_parse_datetime(data["updated_at"]),
@@ -62,7 +64,7 @@ def to_dict(self) -> Dict[str, Any]:
6264
result["name"] = self.name
6365
result["obfuscated_value"] = self.obfuscated_value
6466
if self.last_used_at is not None:
65-
result["last_used_at"] = self.last_used_at
67+
result["last_used_at"] = _format_datetime(self.last_used_at)
6668
else:
6769
result["last_used_at"] = None
6870
result["permissions"] = self.permissions

src/workos/api_keys/models/api_key_with_value.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class ApiKeyWithValue:
2626
"""A descriptive name for the API Key."""
2727
obfuscated_value: str
2828
"""An obfuscated representation of the API Key value."""
29-
last_used_at: Optional[str]
29+
last_used_at: Optional[datetime]
3030
"""Timestamp of when the API Key was last used."""
3131
permissions: List[str]
3232
"""The permission slugs assigned to the API Key."""
@@ -49,7 +49,9 @@ def from_dict(cls, data: Dict[str, Any]) -> "ApiKeyWithValue":
4949
),
5050
name=data["name"],
5151
obfuscated_value=data["obfuscated_value"],
52-
last_used_at=data["last_used_at"],
52+
last_used_at=_parse_datetime(_v)
53+
if (_v := data["last_used_at"]) is not None
54+
else None,
5355
permissions=data["permissions"],
5456
created_at=_parse_datetime(data["created_at"]),
5557
updated_at=_parse_datetime(data["updated_at"]),
@@ -67,7 +69,7 @@ def to_dict(self) -> Dict[str, Any]:
6769
result["name"] = self.name
6870
result["obfuscated_value"] = self.obfuscated_value
6971
if self.last_used_at is not None:
70-
result["last_used_at"] = self.last_used_at
72+
result["last_used_at"] = _format_datetime(self.last_used_at)
7173
else:
7274
result["last_used_at"] = None
7375
result["permissions"] = self.permissions

src/workos/audit_logs/models/audit_log_event.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
from __future__ import annotations
44

55
from dataclasses import dataclass
6+
from datetime import datetime
67
from typing import cast
78
from typing import Any, Dict, List, Optional, Union
89
from workos._types import _raise_deserialize_error
10+
from workos._types import _format_datetime, _parse_datetime
911

1012
from .audit_log_event_actor import AuditLogEventActor
1113
from .audit_log_event_context import AuditLogEventContext
@@ -18,7 +20,7 @@ class AuditLogEvent:
1820

1921
action: str
2022
"""Identifier of what happened."""
21-
occurred_at: str
23+
occurred_at: datetime
2224
"""ISO-8601 value of when the action occurred."""
2325
actor: "AuditLogEventActor"
2426
"""The entity that performed the action."""
@@ -37,7 +39,7 @@ def from_dict(cls, data: Dict[str, Any]) -> "AuditLogEvent":
3739
try:
3840
return cls(
3941
action=data["action"],
40-
occurred_at=data["occurred_at"],
42+
occurred_at=_parse_datetime(data["occurred_at"]),
4143
actor=AuditLogEventActor.from_dict(cast(Dict[str, Any], data["actor"])),
4244
targets=[
4345
AuditLogEventTarget.from_dict(cast(Dict[str, Any], item))
@@ -56,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]:
5658
"""Serialize to a dictionary."""
5759
result: Dict[str, Any] = {}
5860
result["action"] = self.action
59-
result["occurred_at"] = self.occurred_at
61+
result["occurred_at"] = _format_datetime(self.occurred_at)
6062
result["actor"] = self.actor.to_dict()
6163
result["targets"] = [item.to_dict() for item in self.targets]
6264
result["context"] = self.context.to_dict()

tests/fixtures/generate_link.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,8 @@
88
"bookmark_slug": "chatgpt",
99
"provider_type": "GoogleSAML"
1010
}
11-
}
11+
},
12+
"admin_emails": [
13+
"admin@example.com"
14+
]
1215
}

tests/test_sso.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,7 @@ def test_get_profile_and_token(self, workos, httpx_mock):
136136
assert request.method == "POST"
137137
assert request.url.path.endswith("/sso/token")
138138
body = json.loads(request.content)
139-
assert body["client_id"] == "client_test"
140-
assert body["client_secret"] == "sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU"
141139
assert body["code"] == "test_code"
142-
assert body["grant_type"] == "authorization_code"
143140

144141
def test_list_connections_with_request_options(self, workos, httpx_mock):
145142
httpx_mock.add_response(json={"data": [], "list_metadata": {}})

0 commit comments

Comments
 (0)