|
1 | | -from functools import partial |
2 | 1 | from typing import Optional, Protocol, Sequence |
3 | 2 |
|
4 | 3 | from workos.types.connect import ClientSecret, ConnectApplication |
5 | 4 | from workos.types.connect.connect_application import ApplicationType |
6 | | -from workos.types.connect.list_filters import ( |
7 | | - ClientSecretListFilters, |
8 | | - ConnectApplicationListFilters, |
9 | | -) |
| 5 | +from workos.types.connect.list_filters import ConnectApplicationListFilters |
| 6 | +from workos.types.connect.redirect_uri_input import RedirectUriInput |
10 | 7 | from workos.types.list_resource import ListMetadata, ListPage, WorkOSListResource |
11 | 8 | from workos.typing.sync_or_async import SyncOrAsync |
12 | 9 | from workos.utils.http_client import AsyncHTTPClient, SyncHTTPClient |
|
26 | 23 | ConnectApplication, ConnectApplicationListFilters, ListMetadata |
27 | 24 | ] |
28 | 25 |
|
29 | | -ClientSecretsListResource = WorkOSListResource[ |
30 | | - ClientSecret, ClientSecretListFilters, ListMetadata |
31 | | -] |
32 | | - |
33 | 26 |
|
34 | 27 | class ConnectModule(Protocol): |
35 | 28 | """Offers methods through the WorkOS Connect service.""" |
@@ -76,7 +69,7 @@ def create_application( |
76 | 69 | is_first_party: bool, |
77 | 70 | description: Optional[str] = None, |
78 | 71 | scopes: Optional[Sequence[str]] = None, |
79 | | - redirect_uris: Optional[Sequence[str]] = None, |
| 72 | + redirect_uris: Optional[Sequence[RedirectUriInput]] = None, |
80 | 73 | uses_pkce: Optional[bool] = None, |
81 | 74 | organization_id: Optional[str] = None, |
82 | 75 | ) -> SyncOrAsync[ConnectApplication]: |
@@ -104,7 +97,7 @@ def update_application( |
104 | 97 | name: Optional[str] = None, |
105 | 98 | description: Optional[str] = None, |
106 | 99 | scopes: Optional[Sequence[str]] = None, |
107 | | - redirect_uris: Optional[Sequence[str]] = None, |
| 100 | + redirect_uris: Optional[Sequence[RedirectUriInput]] = None, |
108 | 101 | ) -> SyncOrAsync[ConnectApplication]: |
109 | 102 | """Update a connect application. |
110 | 103 |
|
@@ -145,25 +138,14 @@ def create_client_secret(self, application_id: str) -> SyncOrAsync[ClientSecret] |
145 | 138 | def list_client_secrets( |
146 | 139 | self, |
147 | 140 | application_id: str, |
148 | | - *, |
149 | | - limit: int = DEFAULT_LIST_RESPONSE_LIMIT, |
150 | | - before: Optional[str] = None, |
151 | | - after: Optional[str] = None, |
152 | | - order: PaginationOrder = "desc", |
153 | | - ) -> SyncOrAsync[ClientSecretsListResource]: |
| 141 | + ) -> SyncOrAsync[Sequence[ClientSecret]]: |
154 | 142 | """List client secrets for a connect application. |
155 | 143 |
|
156 | 144 | Args: |
157 | 145 | application_id (str): Application ID or client ID. |
158 | 146 |
|
159 | | - Kwargs: |
160 | | - limit (int): Maximum number of records to return. (Optional) |
161 | | - before (str): Pagination cursor to receive records before a provided ID. (Optional) |
162 | | - after (str): Pagination cursor to receive records after a provided ID. (Optional) |
163 | | - order (Literal["asc","desc"]): Sort records in either ascending or descending order. (Optional) |
164 | | -
|
165 | 147 | Returns: |
166 | | - ClientSecretsListResource: Client secrets list response from WorkOS. |
| 148 | + Sequence[ClientSecret]: Client secrets for the application. |
167 | 149 | """ |
168 | 150 | ... |
169 | 151 |
|
@@ -232,7 +214,7 @@ def create_application( |
232 | 214 | is_first_party: bool, |
233 | 215 | description: Optional[str] = None, |
234 | 216 | scopes: Optional[Sequence[str]] = None, |
235 | | - redirect_uris: Optional[Sequence[str]] = None, |
| 217 | + redirect_uris: Optional[Sequence[RedirectUriInput]] = None, |
236 | 218 | uses_pkce: Optional[bool] = None, |
237 | 219 | organization_id: Optional[str] = None, |
238 | 220 | ) -> ConnectApplication: |
@@ -262,7 +244,7 @@ def update_application( |
262 | 244 | name: Optional[str] = None, |
263 | 245 | description: Optional[str] = None, |
264 | 246 | scopes: Optional[Sequence[str]] = None, |
265 | | - redirect_uris: Optional[Sequence[str]] = None, |
| 247 | + redirect_uris: Optional[Sequence[RedirectUriInput]] = None, |
266 | 248 | ) -> ConnectApplication: |
267 | 249 | json = { |
268 | 250 | "name": name, |
@@ -297,30 +279,13 @@ def create_client_secret(self, application_id: str) -> ClientSecret: |
297 | 279 | def list_client_secrets( |
298 | 280 | self, |
299 | 281 | application_id: str, |
300 | | - *, |
301 | | - limit: int = DEFAULT_LIST_RESPONSE_LIMIT, |
302 | | - before: Optional[str] = None, |
303 | | - after: Optional[str] = None, |
304 | | - order: PaginationOrder = "desc", |
305 | | - ) -> ClientSecretsListResource: |
306 | | - list_params: ClientSecretListFilters = { |
307 | | - "limit": limit, |
308 | | - "before": before, |
309 | | - "after": after, |
310 | | - "order": order, |
311 | | - } |
312 | | - |
| 282 | + ) -> Sequence[ClientSecret]: |
313 | 283 | response = self._http_client.request( |
314 | 284 | f"{CONNECT_APPLICATIONS_PATH}/{application_id}/client_secrets", |
315 | 285 | method=REQUEST_METHOD_GET, |
316 | | - params=list_params, |
317 | 286 | ) |
318 | 287 |
|
319 | | - return WorkOSListResource[ClientSecret, ClientSecretListFilters, ListMetadata]( |
320 | | - list_method=partial(self.list_client_secrets, application_id), |
321 | | - list_args=list_params, |
322 | | - **ListPage[ClientSecret](**response).model_dump(), |
323 | | - ) |
| 288 | + return [ClientSecret.model_validate(secret) for secret in response] |
324 | 289 |
|
325 | 290 | def delete_client_secret(self, client_secret_id: str) -> None: |
326 | 291 | self._http_client.request( |
@@ -382,7 +347,7 @@ async def create_application( |
382 | 347 | is_first_party: bool, |
383 | 348 | description: Optional[str] = None, |
384 | 349 | scopes: Optional[Sequence[str]] = None, |
385 | | - redirect_uris: Optional[Sequence[str]] = None, |
| 350 | + redirect_uris: Optional[Sequence[RedirectUriInput]] = None, |
386 | 351 | uses_pkce: Optional[bool] = None, |
387 | 352 | organization_id: Optional[str] = None, |
388 | 353 | ) -> ConnectApplication: |
@@ -412,7 +377,7 @@ async def update_application( |
412 | 377 | name: Optional[str] = None, |
413 | 378 | description: Optional[str] = None, |
414 | 379 | scopes: Optional[Sequence[str]] = None, |
415 | | - redirect_uris: Optional[Sequence[str]] = None, |
| 380 | + redirect_uris: Optional[Sequence[RedirectUriInput]] = None, |
416 | 381 | ) -> ConnectApplication: |
417 | 382 | json = { |
418 | 383 | "name": name, |
@@ -447,30 +412,13 @@ async def create_client_secret(self, application_id: str) -> ClientSecret: |
447 | 412 | async def list_client_secrets( |
448 | 413 | self, |
449 | 414 | application_id: str, |
450 | | - *, |
451 | | - limit: int = DEFAULT_LIST_RESPONSE_LIMIT, |
452 | | - before: Optional[str] = None, |
453 | | - after: Optional[str] = None, |
454 | | - order: PaginationOrder = "desc", |
455 | | - ) -> ClientSecretsListResource: |
456 | | - list_params: ClientSecretListFilters = { |
457 | | - "limit": limit, |
458 | | - "before": before, |
459 | | - "after": after, |
460 | | - "order": order, |
461 | | - } |
462 | | - |
| 415 | + ) -> Sequence[ClientSecret]: |
463 | 416 | response = await self._http_client.request( |
464 | 417 | f"{CONNECT_APPLICATIONS_PATH}/{application_id}/client_secrets", |
465 | 418 | method=REQUEST_METHOD_GET, |
466 | | - params=list_params, |
467 | 419 | ) |
468 | 420 |
|
469 | | - return WorkOSListResource[ClientSecret, ClientSecretListFilters, ListMetadata]( |
470 | | - list_method=partial(self.list_client_secrets, application_id), |
471 | | - list_args=list_params, |
472 | | - **ListPage[ClientSecret](**response).model_dump(), |
473 | | - ) |
| 421 | + return [ClientSecret.model_validate(secret) for secret in response] |
474 | 422 |
|
475 | 423 | async def delete_client_secret(self, client_secret_id: str) -> None: |
476 | 424 | await self._http_client.request( |
|
0 commit comments