diff --git a/.stats.yml b/.stats.yml index 27e0c64c..424dc58b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 41 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-777eedfd80c3e04a8739959418783d1c976180f4f09d7a883f7de5c2b6cda5a6.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-f1779210fbedfc6099076412405288b489f727cbb0b3a85e7b7c12fabb37ef47.yml diff --git a/api.md b/api.md index cd63bd0a..52c77465 100644 --- a/api.md +++ b/api.md @@ -226,14 +226,14 @@ Methods: Types: ```python -from finch.types.jobs import AutomatedAsyncJob, AutomatedCreateResponse +from finch.types.jobs import AutomatedAsyncJob, AutomatedCreateResponse, AutomatedListResponse ``` Methods: - client.jobs.automated.create(\*\*params) -> AutomatedCreateResponse - client.jobs.automated.retrieve(job_id) -> AutomatedAsyncJob -- client.jobs.automated.list(\*\*params) -> SyncPage[AutomatedAsyncJob] +- client.jobs.automated.list(\*\*params) -> AutomatedListResponse ## Manual diff --git a/src/finch/resources/jobs/automated.py b/src/finch/resources/jobs/automated.py index ce3e70ca..3fa895ce 100644 --- a/src/finch/resources/jobs/automated.py +++ b/src/finch/resources/jobs/automated.py @@ -16,10 +16,10 @@ from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper -from ...pagination import SyncPage, AsyncPage from ...types.jobs import automated_list_params, automated_create_params -from ..._base_client import AsyncPaginator, make_request_options +from ..._base_client import make_request_options from ...types.jobs.automated_async_job import AutomatedAsyncJob +from ...types.jobs.automated_list_response import AutomatedListResponse from ...types.jobs.automated_create_response import AutomatedCreateResponse __all__ = ["Automated", "AsyncAutomated"] @@ -200,7 +200,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncPage[AutomatedAsyncJob]: + ) -> AutomatedListResponse: """Get all automated jobs. Automated jobs are completed by a machine. By default, @@ -220,9 +220,8 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ - return self._get_api_list( + return self._get( "/jobs/automated", - page=SyncPage[AutomatedAsyncJob], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -236,7 +235,7 @@ def list( automated_list_params.AutomatedListParams, ), ), - model=AutomatedAsyncJob, + cast_to=AutomatedListResponse, ) @@ -404,7 +403,7 @@ async def retrieve( cast_to=AutomatedAsyncJob, ) - def list( + async def list( self, *, limit: int | NotGiven = NOT_GIVEN, @@ -415,7 +414,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[AutomatedAsyncJob, AsyncPage[AutomatedAsyncJob]]: + ) -> AutomatedListResponse: """Get all automated jobs. Automated jobs are completed by a machine. By default, @@ -435,15 +434,14 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ - return self._get_api_list( + return await self._get( "/jobs/automated", - page=AsyncPage[AutomatedAsyncJob], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout, - query=maybe_transform( + query=await async_maybe_transform( { "limit": limit, "offset": offset, @@ -451,7 +449,7 @@ def list( automated_list_params.AutomatedListParams, ), ), - model=AutomatedAsyncJob, + cast_to=AutomatedListResponse, ) diff --git a/src/finch/types/jobs/__init__.py b/src/finch/types/jobs/__init__.py index b5eaa10b..ee2d3e8e 100644 --- a/src/finch/types/jobs/__init__.py +++ b/src/finch/types/jobs/__init__.py @@ -6,4 +6,5 @@ from .automated_async_job import AutomatedAsyncJob as AutomatedAsyncJob from .automated_list_params import AutomatedListParams as AutomatedListParams from .automated_create_params import AutomatedCreateParams as AutomatedCreateParams +from .automated_list_response import AutomatedListResponse as AutomatedListResponse from .automated_create_response import AutomatedCreateResponse as AutomatedCreateResponse diff --git a/src/finch/types/jobs/automated_list_response.py b/src/finch/types/jobs/automated_list_response.py new file mode 100644 index 00000000..d934dea6 --- /dev/null +++ b/src/finch/types/jobs/automated_list_response.py @@ -0,0 +1,34 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from ..._models import BaseModel +from .automated_async_job import AutomatedAsyncJob + +__all__ = ["AutomatedListResponse", "Meta", "MetaQuotas", "MetaQuotasDataSyncAll"] + + +class MetaQuotasDataSyncAll(BaseModel): + allowed_refreshes: Optional[int] = None + + remaining_refreshes: Optional[int] = None + + +class MetaQuotas(BaseModel): + data_sync_all: Optional[MetaQuotasDataSyncAll] = None + + +class Meta(BaseModel): + quotas: Optional[MetaQuotas] = None + """Information about remaining quotas for this connection. + + Only applicable for customers opted in to use Finch's Data Sync Refresh endpoint + (`POST /jobs/automated`). Please contact a Finch representative for more + details. + """ + + +class AutomatedListResponse(BaseModel): + data: List[AutomatedAsyncJob] + + meta: Meta diff --git a/tests/api_resources/jobs/test_automated.py b/tests/api_resources/jobs/test_automated.py index db83b0e5..c0dc5e49 100644 --- a/tests/api_resources/jobs/test_automated.py +++ b/tests/api_resources/jobs/test_automated.py @@ -9,8 +9,11 @@ from finch import Finch, AsyncFinch from tests.utils import assert_matches_type -from finch.pagination import SyncPage, AsyncPage -from finch.types.jobs import AutomatedAsyncJob, AutomatedCreateResponse +from finch.types.jobs import ( + AutomatedAsyncJob, + AutomatedListResponse, + AutomatedCreateResponse, +) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -124,7 +127,7 @@ def test_path_params_retrieve(self, client: Finch) -> None: @parametrize def test_method_list(self, client: Finch) -> None: automated = client.jobs.automated.list() - assert_matches_type(SyncPage[AutomatedAsyncJob], automated, path=["response"]) + assert_matches_type(AutomatedListResponse, automated, path=["response"]) @parametrize def test_method_list_with_all_params(self, client: Finch) -> None: @@ -132,7 +135,7 @@ def test_method_list_with_all_params(self, client: Finch) -> None: limit=0, offset=0, ) - assert_matches_type(SyncPage[AutomatedAsyncJob], automated, path=["response"]) + assert_matches_type(AutomatedListResponse, automated, path=["response"]) @parametrize def test_raw_response_list(self, client: Finch) -> None: @@ -141,7 +144,7 @@ def test_raw_response_list(self, client: Finch) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" automated = response.parse() - assert_matches_type(SyncPage[AutomatedAsyncJob], automated, path=["response"]) + assert_matches_type(AutomatedListResponse, automated, path=["response"]) @parametrize def test_streaming_response_list(self, client: Finch) -> None: @@ -150,7 +153,7 @@ def test_streaming_response_list(self, client: Finch) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" automated = response.parse() - assert_matches_type(SyncPage[AutomatedAsyncJob], automated, path=["response"]) + assert_matches_type(AutomatedListResponse, automated, path=["response"]) assert cast(Any, response.is_closed) is True @@ -264,7 +267,7 @@ async def test_path_params_retrieve(self, async_client: AsyncFinch) -> None: @parametrize async def test_method_list(self, async_client: AsyncFinch) -> None: automated = await async_client.jobs.automated.list() - assert_matches_type(AsyncPage[AutomatedAsyncJob], automated, path=["response"]) + assert_matches_type(AutomatedListResponse, automated, path=["response"]) @parametrize async def test_method_list_with_all_params(self, async_client: AsyncFinch) -> None: @@ -272,7 +275,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncFinch) -> No limit=0, offset=0, ) - assert_matches_type(AsyncPage[AutomatedAsyncJob], automated, path=["response"]) + assert_matches_type(AutomatedListResponse, automated, path=["response"]) @parametrize 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: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" automated = response.parse() - assert_matches_type(AsyncPage[AutomatedAsyncJob], automated, path=["response"]) + assert_matches_type(AutomatedListResponse, automated, path=["response"]) @parametrize 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: assert response.http_request.headers.get("X-Stainless-Lang") == "python" automated = await response.parse() - assert_matches_type(AsyncPage[AutomatedAsyncJob], automated, path=["response"]) + assert_matches_type(AutomatedListResponse, automated, path=["response"]) assert cast(Any, response.is_closed) is True