Skip to content

Commit 8cd9643

Browse files
committed
TW-5372 Add application and workspace admin APIs
1 parent fef8e8c commit 8cd9643

11 files changed

Lines changed: 883 additions & 50 deletions

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ v6.14.1
2727
----------
2828
* Fix attachment id to not be a requirement
2929

30+
Unreleased
31+
----------
32+
* Added Policies resource (`client.policies`) with `list`, `find`, `create`, `update` (PUT), and `destroy`
33+
* Added Rules resource (`client.rules`) with `list`, `find`, `create`, `update` (PUT), `destroy`, and `list_evaluations` (per-grant rule evaluations)
34+
* Added Workspaces resource (`client.workspaces`) with `list`, `find`, `create`, `update` (PATCH), `destroy`, `auto_group`, and `manual_assign`
35+
* Added Manage Domains resource (`client.domains`) with `list`, `find`, `create`, `update` (PUT), `destroy`, `info`, and `verify` against `/v3/admin/domains`
36+
* Corrected RedirectUris `update` to use PATCH instead of PUT; added `deleted_at` to the RedirectUri model and made `platform` optional on create
37+
* Verified and extended Applications: added `update` (PATCH `/v3/applications`) and source-only response fields (`idp_settings`, hosted-authentication legal URLs, `v2_application_id`, `domain`, `blocked`, timestamps)
38+
3039
v6.14.0
3140
----------
3241
* Added `message.deleted` to the Webhook enum, appended tests

nylas/client.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from nylas.resources.scheduler import Scheduler
2121
from nylas.resources.notetakers import Notetakers
2222
from nylas.resources.rules import Rules
23+
from nylas.resources.workspaces import Workspaces
2324

2425

2526
class Client:
@@ -246,3 +247,13 @@ def notetakers(self) -> Notetakers:
246247
The Notetakers API.
247248
"""
248249
return Notetakers(self.http_client)
250+
251+
@property
252+
def workspaces(self) -> Workspaces:
253+
"""
254+
Access the Workspaces API.
255+
256+
Returns:
257+
The Workspaces API.
258+
"""
259+
return Workspaces(self.http_client)

nylas/models/application_details.py

Lines changed: 145 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
from dataclasses import dataclass, field
2-
from typing import Literal, Optional, List
2+
from typing import Optional, List
33

44
from dataclasses_json import dataclass_json
5+
from typing_extensions import TypedDict, NotRequired
56

67
from nylas.models.redirect_uri import RedirectUri
78

8-
Region = Literal["us", "eu"]
9-
""" Literal representing the available Nylas API regions. """
9+
Region = str
10+
""" The Nylas API region (free-form string, e.g. ``us``, ``eu``). """
1011

11-
Environment = Literal["production", "staging", "development", "sandbox"]
12-
""" Literal representing the different Nylas API environments. """
12+
Environment = str
13+
""" The Nylas API environment (free-form string, e.g. ``sandbox``). """
1314

1415

1516
@dataclass_json
@@ -46,6 +47,8 @@ class HostedAuthentication:
4647
subtitle: Subtitle for the hosted authentication page.
4748
background_color: Background color of the hosted authentication page.
4849
spacing: CSS spacing attribute in px.
50+
terms_of_service_url: URL pointing to the terms of service.
51+
privacy_policy_url: URL pointing to the privacy policy.
4952
"""
5053

5154
background_image_url: Optional[str] = None
@@ -56,6 +59,23 @@ class HostedAuthentication:
5659
subtitle: Optional[str] = None
5760
background_color: Optional[str] = None
5861
spacing: Optional[int] = None
62+
terms_of_service_url: Optional[str] = None
63+
privacy_policy_url: Optional[str] = None
64+
65+
66+
@dataclass_json
67+
@dataclass
68+
class IdpSettings:
69+
"""
70+
Class representation of identity provider settings for the application.
71+
72+
Attributes:
73+
origins: Comma-separated list of allowed origins.
74+
issuers: Comma-separated list of allowed issuers.
75+
"""
76+
77+
origins: Optional[str] = None
78+
issuers: Optional[str] = None
5979

6080

6181
@dataclass_json
@@ -70,14 +90,134 @@ class ApplicationDetails:
7090
region: Region identifier.
7191
environment: Environment identifier.
7292
branding: Branding details for the application.
93+
v2_application_id: The associated v2 application ID, if any.
94+
domain: The white-label domain associated with the application, if any.
7395
hosted_authentication: Hosted authentication branding details.
96+
idp_settings: Identity provider settings.
7497
callback_uris: List of redirect URIs.
98+
created_at: Unix timestamp (seconds) when the application was created.
99+
updated_at: Unix timestamp (seconds) when the application was last updated.
100+
blocked: Whether the application is blocked.
75101
"""
76102

77103
application_id: str
78104
organization_id: str
79105
region: Region
80106
environment: Environment
81107
branding: Branding
108+
v2_application_id: Optional[str] = None
109+
domain: Optional[str] = None
82110
hosted_authentication: Optional[HostedAuthentication] = None
111+
idp_settings: Optional[IdpSettings] = None
83112
callback_uris: List[RedirectUri] = field(default_factory=list)
113+
created_at: Optional[int] = None
114+
updated_at: Optional[int] = None
115+
blocked: Optional[bool] = None
116+
117+
118+
class WritableBranding(TypedDict):
119+
"""
120+
Class representing branding details for a create/update application call.
121+
122+
Attributes:
123+
name: Name of the application.
124+
icon_url: URL pointing to the application icon.
125+
website_url: Application/publisher website URL.
126+
description: Description of the application.
127+
"""
128+
129+
name: NotRequired[str]
130+
icon_url: NotRequired[str]
131+
website_url: NotRequired[str]
132+
description: NotRequired[str]
133+
134+
135+
class WritableHostedAuthentication(TypedDict):
136+
"""
137+
Class representing hosted authentication details for a create/update application call.
138+
139+
Attributes:
140+
background_image_url: URL pointing to the background image.
141+
alignment: Alignment of the background image.
142+
color_primary: Primary color of the hosted authentication page.
143+
color_secondary: Secondary color of the hosted authentication page.
144+
title: Title of the hosted authentication page.
145+
subtitle: Subtitle for the hosted authentication page.
146+
background_color: Background color of the hosted authentication page.
147+
spacing: CSS spacing attribute in px.
148+
terms_of_service_url: URL pointing to the terms of service.
149+
privacy_policy_url: URL pointing to the privacy policy.
150+
"""
151+
152+
background_image_url: NotRequired[str]
153+
alignment: NotRequired[str]
154+
color_primary: NotRequired[str]
155+
color_secondary: NotRequired[str]
156+
title: NotRequired[str]
157+
subtitle: NotRequired[str]
158+
background_color: NotRequired[str]
159+
spacing: NotRequired[int]
160+
terms_of_service_url: NotRequired[str]
161+
privacy_policy_url: NotRequired[str]
162+
163+
164+
class WritableIdpSettings(TypedDict):
165+
"""
166+
Class representing identity provider settings for a create/update application call.
167+
168+
Attributes:
169+
origins: Comma-separated list of allowed origins.
170+
issuers: Comma-separated list of allowed issuers.
171+
"""
172+
173+
origins: NotRequired[str]
174+
issuers: NotRequired[str]
175+
176+
177+
class WritableAdditionalSettings(TypedDict):
178+
"""
179+
Class representing additional application settings for an update call.
180+
181+
These settings are write-only: they can be set via the update call but are
182+
stripped from every response and are not bound on the application model.
183+
184+
Attributes:
185+
login_url: The login URL.
186+
logout_url: The logout URL.
187+
refresh_token_expiration_absolute: Absolute refresh token expiration.
188+
refresh_token_expiration_idle: Idle refresh token expiration.
189+
rotate_refresh_token: Whether to rotate the refresh token.
190+
allow_query_param_in_redirect_uri: Whether query params are allowed in redirect URIs.
191+
"""
192+
193+
login_url: NotRequired[str]
194+
logout_url: NotRequired[str]
195+
refresh_token_expiration_absolute: NotRequired[int]
196+
refresh_token_expiration_idle: NotRequired[int]
197+
rotate_refresh_token: NotRequired[bool]
198+
allow_query_param_in_redirect_uri: NotRequired[bool]
199+
200+
201+
class UpdateApplicationRequest(TypedDict):
202+
"""
203+
Class representing a request to update a Nylas application.
204+
205+
Note:
206+
``callback_uris`` / ``redirect_uris`` cannot be set via this request; the
207+
server silently ignores them. Manage callback URIs via the dedicated
208+
redirect-uris endpoints. ``additional_settings`` is write-only and is
209+
stripped from the response.
210+
211+
Attributes:
212+
branding: Branding details for the application.
213+
hosted_authentication: Hosted authentication branding details.
214+
idp_settings: Identity provider settings.
215+
domain: The white-label domain associated with the application.
216+
additional_settings: Additional (write-only) application settings.
217+
"""
218+
219+
branding: NotRequired[WritableBranding]
220+
hosted_authentication: NotRequired[WritableHostedAuthentication]
221+
idp_settings: NotRequired[WritableIdpSettings]
222+
domain: NotRequired[str]
223+
additional_settings: NotRequired[WritableAdditionalSettings]

nylas/models/redirect_uri.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,14 @@ class RedirectUri:
3939
url: Redirect URL.
4040
platform: Platform identifier.
4141
settings: Configuration settings.
42+
deleted_at: Soft-delete timestamp (Unix seconds); omitted when not deleted.
4243
"""
4344

4445
id: str
4546
url: str
4647
platform: str
4748
settings: Optional[RedirectUriSettings] = None
49+
deleted_at: Optional[int] = None
4850

4951

5052
class WritableRedirectUriSettings(TypedDict):
@@ -74,12 +76,12 @@ class CreateRedirectUriRequest(TypedDict):
7476
7577
Attributes:
7678
url: Redirect URL.
77-
platform: Platform identifier.
79+
platform: Platform identifier. Optional; defaults to "web" server-side.
7880
settings: Optional settings for the redirect uri.
7981
"""
8082

8183
url: str
82-
platform: str
84+
platform: NotRequired[str]
8385
settings: NotRequired[WritableRedirectUriSettings]
8486

8587

0 commit comments

Comments
 (0)