|
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 |
10 | 6 | from workos.types.list_resource import ListMetadata, ListPage, WorkOSListResource |
11 | 7 | from workos.typing.sync_or_async import SyncOrAsync |
12 | 8 | from workos.utils.http_client import AsyncHTTPClient, SyncHTTPClient |
|
26 | 22 | ConnectApplication, ConnectApplicationListFilters, ListMetadata |
27 | 23 | ] |
28 | 24 |
|
29 | | -ClientSecretsListResource = WorkOSListResource[ |
30 | | - ClientSecret, ClientSecretListFilters, ListMetadata |
31 | | -] |
32 | | - |
33 | 25 |
|
34 | 26 | class ConnectModule(Protocol): |
35 | 27 | """Offers methods through the WorkOS Connect service.""" |
@@ -145,25 +137,14 @@ def create_client_secret(self, application_id: str) -> SyncOrAsync[ClientSecret] |
145 | 137 | def list_client_secrets( |
146 | 138 | self, |
147 | 139 | 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]: |
| 140 | + ) -> SyncOrAsync[Sequence[ClientSecret]]: |
154 | 141 | """List client secrets for a connect application. |
155 | 142 |
|
156 | 143 | Args: |
157 | 144 | application_id (str): Application ID or client ID. |
158 | 145 |
|
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 | 146 | Returns: |
166 | | - ClientSecretsListResource: Client secrets list response from WorkOS. |
| 147 | + Sequence[ClientSecret]: Client secrets for the application. |
167 | 148 | """ |
168 | 149 | ... |
169 | 150 |
|
@@ -297,30 +278,13 @@ def create_client_secret(self, application_id: str) -> ClientSecret: |
297 | 278 | def list_client_secrets( |
298 | 279 | self, |
299 | 280 | 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 | | - |
| 281 | + ) -> Sequence[ClientSecret]: |
313 | 282 | response = self._http_client.request( |
314 | 283 | f"{CONNECT_APPLICATIONS_PATH}/{application_id}/client_secrets", |
315 | 284 | method=REQUEST_METHOD_GET, |
316 | | - params=list_params, |
317 | 285 | ) |
318 | 286 |
|
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 | | - ) |
| 287 | + return [ClientSecret.model_validate(secret) for secret in response] |
324 | 288 |
|
325 | 289 | def delete_client_secret(self, client_secret_id: str) -> None: |
326 | 290 | self._http_client.request( |
@@ -447,30 +411,13 @@ async def create_client_secret(self, application_id: str) -> ClientSecret: |
447 | 411 | async def list_client_secrets( |
448 | 412 | self, |
449 | 413 | 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 | | - |
| 414 | + ) -> Sequence[ClientSecret]: |
463 | 415 | response = await self._http_client.request( |
464 | 416 | f"{CONNECT_APPLICATIONS_PATH}/{application_id}/client_secrets", |
465 | 417 | method=REQUEST_METHOD_GET, |
466 | | - params=list_params, |
467 | 418 | ) |
468 | 419 |
|
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 | | - ) |
| 420 | + return [ClientSecret.model_validate(secret) for secret in response] |
474 | 421 |
|
475 | 422 | async def delete_client_secret(self, client_secret_id: str) -> None: |
476 | 423 | await self._http_client.request( |
|
0 commit comments