Skip to content

Commit 9c2b530

Browse files
chore(internal): codegen related update (#617)
1 parent 3f0a07e commit 9c2b530

File tree

6 files changed

+61
-25
lines changed

6 files changed

+61
-25
lines changed

.stats.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 41
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-777eedfd80c3e04a8739959418783d1c976180f4f09d7a883f7de5c2b6cda5a6.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-f1779210fbedfc6099076412405288b489f727cbb0b3a85e7b7c12fabb37ef47.yml

api.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -238,14 +238,14 @@ Methods:
238238
Types:
239239

240240
```python
241-
from finch.types.jobs import AutomatedAsyncJob, AutomatedCreateResponse
241+
from finch.types.jobs import AutomatedAsyncJob, AutomatedCreateResponse, AutomatedListResponse
242242
```
243243

244244
Methods:
245245

246246
- <code title="post /jobs/automated">client.jobs.automated.<a href="./src/finch/resources/jobs/automated.py">create</a>(\*\*<a href="src/finch/types/jobs/automated_create_params.py">params</a>) -> <a href="./src/finch/types/jobs/automated_create_response.py">AutomatedCreateResponse</a></code>
247247
- <code title="get /jobs/automated/{job_id}">client.jobs.automated.<a href="./src/finch/resources/jobs/automated.py">retrieve</a>(job_id) -> <a href="./src/finch/types/jobs/automated_async_job.py">AutomatedAsyncJob</a></code>
248-
- <code title="get /jobs/automated">client.jobs.automated.<a href="./src/finch/resources/jobs/automated.py">list</a>(\*\*<a href="src/finch/types/jobs/automated_list_params.py">params</a>) -> <a href="./src/finch/types/jobs/automated_async_job.py">SyncPage[AutomatedAsyncJob]</a></code>
248+
- <code title="get /jobs/automated">client.jobs.automated.<a href="./src/finch/resources/jobs/automated.py">list</a>(\*\*<a href="src/finch/types/jobs/automated_list_params.py">params</a>) -> <a href="./src/finch/types/jobs/automated_list_response.py">AutomatedListResponse</a></code>
249249

250250
## Manual
251251

src/finch/resources/jobs/automated.py

+10-12
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
from ..._compat import cached_property
1717
from ..._resource import SyncAPIResource, AsyncAPIResource
1818
from ..._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
19-
from ...pagination import SyncPage, AsyncPage
2019
from ...types.jobs import automated_list_params, automated_create_params
21-
from ..._base_client import AsyncPaginator, make_request_options
20+
from ..._base_client import make_request_options
2221
from ...types.jobs.automated_async_job import AutomatedAsyncJob
22+
from ...types.jobs.automated_list_response import AutomatedListResponse
2323
from ...types.jobs.automated_create_response import AutomatedCreateResponse
2424

2525
__all__ = ["Automated", "AsyncAutomated"]
@@ -200,7 +200,7 @@ def list(
200200
extra_query: Query | None = None,
201201
extra_body: Body | None = None,
202202
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
203-
) -> SyncPage[AutomatedAsyncJob]:
203+
) -> AutomatedListResponse:
204204
"""Get all automated jobs.
205205
206206
Automated jobs are completed by a machine. By default,
@@ -220,9 +220,8 @@ def list(
220220
221221
timeout: Override the client-level default timeout for this request, in seconds
222222
"""
223-
return self._get_api_list(
223+
return self._get(
224224
"/jobs/automated",
225-
page=SyncPage[AutomatedAsyncJob],
226225
options=make_request_options(
227226
extra_headers=extra_headers,
228227
extra_query=extra_query,
@@ -236,7 +235,7 @@ def list(
236235
automated_list_params.AutomatedListParams,
237236
),
238237
),
239-
model=AutomatedAsyncJob,
238+
cast_to=AutomatedListResponse,
240239
)
241240

242241

@@ -404,7 +403,7 @@ async def retrieve(
404403
cast_to=AutomatedAsyncJob,
405404
)
406405

407-
def list(
406+
async def list(
408407
self,
409408
*,
410409
limit: int | NotGiven = NOT_GIVEN,
@@ -415,7 +414,7 @@ def list(
415414
extra_query: Query | None = None,
416415
extra_body: Body | None = None,
417416
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
418-
) -> AsyncPaginator[AutomatedAsyncJob, AsyncPage[AutomatedAsyncJob]]:
417+
) -> AutomatedListResponse:
419418
"""Get all automated jobs.
420419
421420
Automated jobs are completed by a machine. By default,
@@ -435,23 +434,22 @@ def list(
435434
436435
timeout: Override the client-level default timeout for this request, in seconds
437436
"""
438-
return self._get_api_list(
437+
return await self._get(
439438
"/jobs/automated",
440-
page=AsyncPage[AutomatedAsyncJob],
441439
options=make_request_options(
442440
extra_headers=extra_headers,
443441
extra_query=extra_query,
444442
extra_body=extra_body,
445443
timeout=timeout,
446-
query=maybe_transform(
444+
query=await async_maybe_transform(
447445
{
448446
"limit": limit,
449447
"offset": offset,
450448
},
451449
automated_list_params.AutomatedListParams,
452450
),
453451
),
454-
model=AutomatedAsyncJob,
452+
cast_to=AutomatedListResponse,
455453
)
456454

457455

src/finch/types/jobs/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
from .automated_async_job import AutomatedAsyncJob as AutomatedAsyncJob
77
from .automated_list_params import AutomatedListParams as AutomatedListParams
88
from .automated_create_params import AutomatedCreateParams as AutomatedCreateParams
9+
from .automated_list_response import AutomatedListResponse as AutomatedListResponse
910
from .automated_create_response import AutomatedCreateResponse as AutomatedCreateResponse
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from typing import List, Optional
4+
5+
from ..._models import BaseModel
6+
from .automated_async_job import AutomatedAsyncJob
7+
8+
__all__ = ["AutomatedListResponse", "Meta", "MetaQuotas", "MetaQuotasDataSyncAll"]
9+
10+
11+
class MetaQuotasDataSyncAll(BaseModel):
12+
allowed_refreshes: Optional[int] = None
13+
14+
remaining_refreshes: Optional[int] = None
15+
16+
17+
class MetaQuotas(BaseModel):
18+
data_sync_all: Optional[MetaQuotasDataSyncAll] = None
19+
20+
21+
class Meta(BaseModel):
22+
quotas: Optional[MetaQuotas] = None
23+
"""Information about remaining quotas for this connection.
24+
25+
Only applicable for customers opted in to use Finch's Data Sync Refresh endpoint
26+
(`POST /jobs/automated`). Please contact a Finch representative for more
27+
details.
28+
"""
29+
30+
31+
class AutomatedListResponse(BaseModel):
32+
data: List[AutomatedAsyncJob]
33+
34+
meta: Meta

tests/api_resources/jobs/test_automated.py

+13-10
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99

1010
from finch import Finch, AsyncFinch
1111
from tests.utils import assert_matches_type
12-
from finch.pagination import SyncPage, AsyncPage
13-
from finch.types.jobs import AutomatedAsyncJob, AutomatedCreateResponse
12+
from finch.types.jobs import (
13+
AutomatedAsyncJob,
14+
AutomatedListResponse,
15+
AutomatedCreateResponse,
16+
)
1417

1518
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
1619

@@ -124,15 +127,15 @@ def test_path_params_retrieve(self, client: Finch) -> None:
124127
@parametrize
125128
def test_method_list(self, client: Finch) -> None:
126129
automated = client.jobs.automated.list()
127-
assert_matches_type(SyncPage[AutomatedAsyncJob], automated, path=["response"])
130+
assert_matches_type(AutomatedListResponse, automated, path=["response"])
128131

129132
@parametrize
130133
def test_method_list_with_all_params(self, client: Finch) -> None:
131134
automated = client.jobs.automated.list(
132135
limit=0,
133136
offset=0,
134137
)
135-
assert_matches_type(SyncPage[AutomatedAsyncJob], automated, path=["response"])
138+
assert_matches_type(AutomatedListResponse, automated, path=["response"])
136139

137140
@parametrize
138141
def test_raw_response_list(self, client: Finch) -> None:
@@ -141,7 +144,7 @@ def test_raw_response_list(self, client: Finch) -> None:
141144
assert response.is_closed is True
142145
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
143146
automated = response.parse()
144-
assert_matches_type(SyncPage[AutomatedAsyncJob], automated, path=["response"])
147+
assert_matches_type(AutomatedListResponse, automated, path=["response"])
145148

146149
@parametrize
147150
def test_streaming_response_list(self, client: Finch) -> None:
@@ -150,7 +153,7 @@ def test_streaming_response_list(self, client: Finch) -> None:
150153
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
151154

152155
automated = response.parse()
153-
assert_matches_type(SyncPage[AutomatedAsyncJob], automated, path=["response"])
156+
assert_matches_type(AutomatedListResponse, automated, path=["response"])
154157

155158
assert cast(Any, response.is_closed) is True
156159

@@ -264,15 +267,15 @@ async def test_path_params_retrieve(self, async_client: AsyncFinch) -> None:
264267
@parametrize
265268
async def test_method_list(self, async_client: AsyncFinch) -> None:
266269
automated = await async_client.jobs.automated.list()
267-
assert_matches_type(AsyncPage[AutomatedAsyncJob], automated, path=["response"])
270+
assert_matches_type(AutomatedListResponse, automated, path=["response"])
268271

269272
@parametrize
270273
async def test_method_list_with_all_params(self, async_client: AsyncFinch) -> None:
271274
automated = await async_client.jobs.automated.list(
272275
limit=0,
273276
offset=0,
274277
)
275-
assert_matches_type(AsyncPage[AutomatedAsyncJob], automated, path=["response"])
278+
assert_matches_type(AutomatedListResponse, automated, path=["response"])
276279

277280
@parametrize
278281
async def test_raw_response_list(self, async_client: AsyncFinch) -> None:
@@ -281,7 +284,7 @@ async def test_raw_response_list(self, async_client: AsyncFinch) -> None:
281284
assert response.is_closed is True
282285
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
283286
automated = response.parse()
284-
assert_matches_type(AsyncPage[AutomatedAsyncJob], automated, path=["response"])
287+
assert_matches_type(AutomatedListResponse, automated, path=["response"])
285288

286289
@parametrize
287290
async def test_streaming_response_list(self, async_client: AsyncFinch) -> None:
@@ -290,6 +293,6 @@ async def test_streaming_response_list(self, async_client: AsyncFinch) -> None:
290293
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
291294

292295
automated = await response.parse()
293-
assert_matches_type(AsyncPage[AutomatedAsyncJob], automated, path=["response"])
296+
assert_matches_type(AutomatedListResponse, automated, path=["response"])
294297

295298
assert cast(Any, response.is_closed) is True

0 commit comments

Comments
 (0)