diff --git a/.stats.yml b/.stats.yml index 35c62c13..a49daff7 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 39 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-b67c6cc5bff73851c98deeabb3ef7548eb89abfa88aca36886084416fdc347f4.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-a340c9ef2dc8b9c0e755549d473fb1033ce6b75b606aacdc1a4ae22d2456c6ad.yml diff --git a/src/finch/resources/jobs/automated.py b/src/finch/resources/jobs/automated.py index b8bcb702..af6b303c 100644 --- a/src/finch/resources/jobs/automated.py +++ b/src/finch/resources/jobs/automated.py @@ -2,13 +2,14 @@ from __future__ import annotations -from typing_extensions import Literal +from typing_extensions import Literal, overload import httpx from ... import _legacy_response from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven from ..._utils import ( + required_args, maybe_transform, async_maybe_transform, ) @@ -44,6 +45,7 @@ def with_streaming_response(self) -> AutomatedWithStreamingResponse: """ return AutomatedWithStreamingResponse(self) + @overload def create( self, *, @@ -55,21 +57,68 @@ def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> AutomatedCreateResponse: - """Enqueue an automated job. + """ + Enqueue an automated job. + + `data_sync_all`: Enqueue a job to re-sync all data for a connection. + `data_sync_all` has a concurrency limit of 1 job at a time per connection. This + means that if this endpoint is called while a job is already in progress for + this connection, Finch will return the `job_id` of the job that is currently in + progress. Finch allows a fixed window rate limit of 1 forced refresh per hour + per connection. + + `w4_data_sync`: Enqueues a job for sync W-4 data for a particular individual, + identified by `individual_id`. This feature is currently in beta. + + This endpoint is available for _Scale_ tier customers as an add-on. To request + access to this endpoint, please contact your Finch account manager. + + Args: + type: The type of job to start. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def create( + self, + *, + individual_id: str, + type: Literal["w4_data_sync"], + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> AutomatedCreateResponse: + """ + Enqueue an automated job. - Currently, only the `data_sync_all` job type is - supported, which will enqueue a job to re-sync all data for a connection. + `data_sync_all`: Enqueue a job to re-sync all data for a connection. `data_sync_all` has a concurrency limit of 1 job at a time per connection. This means that if this endpoint is called while a job is already in progress for this connection, Finch will return the `job_id` of the job that is currently in progress. Finch allows a fixed window rate limit of 1 forced refresh per hour per connection. + `w4_data_sync`: Enqueues a job for sync W-4 data for a particular individual, + identified by `individual_id`. This feature is currently in beta. + This endpoint is available for _Scale_ tier customers as an add-on. To request access to this endpoint, please contact your Finch account manager. Args: - type: The type of job to start. Currently the only supported type is `data_sync_all` + individual_id: The unique ID of the individual for W-4 data sync. + + type: The type of job to start. extra_headers: Send extra headers @@ -79,9 +128,30 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + ... + + @required_args(["type"], ["individual_id", "type"]) + def create( + self, + *, + type: Literal["data_sync_all"] | Literal["w4_data_sync"], + individual_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> AutomatedCreateResponse: return self._post( "/jobs/automated", - body=maybe_transform({"type": type}, automated_create_params.AutomatedCreateParams), + body=maybe_transform( + { + "type": type, + "individual_id": individual_id, + }, + automated_create_params.AutomatedCreateParams, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -192,6 +262,7 @@ def with_streaming_response(self) -> AsyncAutomatedWithStreamingResponse: """ return AsyncAutomatedWithStreamingResponse(self) + @overload async def create( self, *, @@ -203,21 +274,68 @@ async def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> AutomatedCreateResponse: - """Enqueue an automated job. + """ + Enqueue an automated job. + + `data_sync_all`: Enqueue a job to re-sync all data for a connection. + `data_sync_all` has a concurrency limit of 1 job at a time per connection. This + means that if this endpoint is called while a job is already in progress for + this connection, Finch will return the `job_id` of the job that is currently in + progress. Finch allows a fixed window rate limit of 1 forced refresh per hour + per connection. + + `w4_data_sync`: Enqueues a job for sync W-4 data for a particular individual, + identified by `individual_id`. This feature is currently in beta. + + This endpoint is available for _Scale_ tier customers as an add-on. To request + access to this endpoint, please contact your Finch account manager. + + Args: + type: The type of job to start. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def create( + self, + *, + individual_id: str, + type: Literal["w4_data_sync"], + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> AutomatedCreateResponse: + """ + Enqueue an automated job. - Currently, only the `data_sync_all` job type is - supported, which will enqueue a job to re-sync all data for a connection. + `data_sync_all`: Enqueue a job to re-sync all data for a connection. `data_sync_all` has a concurrency limit of 1 job at a time per connection. This means that if this endpoint is called while a job is already in progress for this connection, Finch will return the `job_id` of the job that is currently in progress. Finch allows a fixed window rate limit of 1 forced refresh per hour per connection. + `w4_data_sync`: Enqueues a job for sync W-4 data for a particular individual, + identified by `individual_id`. This feature is currently in beta. + This endpoint is available for _Scale_ tier customers as an add-on. To request access to this endpoint, please contact your Finch account manager. Args: - type: The type of job to start. Currently the only supported type is `data_sync_all` + individual_id: The unique ID of the individual for W-4 data sync. + + type: The type of job to start. extra_headers: Send extra headers @@ -227,9 +345,30 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + ... + + @required_args(["type"], ["individual_id", "type"]) + async def create( + self, + *, + type: Literal["data_sync_all"] | Literal["w4_data_sync"], + individual_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> AutomatedCreateResponse: return await self._post( "/jobs/automated", - body=await async_maybe_transform({"type": type}, automated_create_params.AutomatedCreateParams), + body=await async_maybe_transform( + { + "type": type, + "individual_id": individual_id, + }, + automated_create_params.AutomatedCreateParams, + ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/finch/types/jobs/automated_create_params.py b/src/finch/types/jobs/automated_create_params.py index d00c77ee..baa97c11 100644 --- a/src/finch/types/jobs/automated_create_params.py +++ b/src/finch/types/jobs/automated_create_params.py @@ -2,11 +2,23 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing import Union +from typing_extensions import Literal, Required, TypeAlias, TypedDict -__all__ = ["AutomatedCreateParams"] +__all__ = ["AutomatedCreateParams", "DataSyncAll", "W4DataSync"] -class AutomatedCreateParams(TypedDict, total=False): +class DataSyncAll(TypedDict, total=False): type: Required[Literal["data_sync_all"]] - """The type of job to start. Currently the only supported type is `data_sync_all`""" + """The type of job to start.""" + + +class W4DataSync(TypedDict, total=False): + individual_id: Required[str] + """The unique ID of the individual for W-4 data sync.""" + + type: Required[Literal["w4_data_sync"]] + """The type of job to start.""" + + +AutomatedCreateParams: TypeAlias = Union[DataSyncAll, W4DataSync] diff --git a/tests/api_resources/jobs/test_automated.py b/tests/api_resources/jobs/test_automated.py index a56e5d93..2761582d 100644 --- a/tests/api_resources/jobs/test_automated.py +++ b/tests/api_resources/jobs/test_automated.py @@ -19,14 +19,14 @@ class TestAutomated: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) @parametrize - def test_method_create(self, client: Finch) -> None: + def test_method_create_overload_1(self, client: Finch) -> None: automated = client.jobs.automated.create( type="data_sync_all", ) assert_matches_type(AutomatedCreateResponse, automated, path=["response"]) @parametrize - def test_raw_response_create(self, client: Finch) -> None: + def test_raw_response_create_overload_1(self, client: Finch) -> None: response = client.jobs.automated.with_raw_response.create( type="data_sync_all", ) @@ -37,7 +37,7 @@ def test_raw_response_create(self, client: Finch) -> None: assert_matches_type(AutomatedCreateResponse, automated, path=["response"]) @parametrize - def test_streaming_response_create(self, client: Finch) -> None: + def test_streaming_response_create_overload_1(self, client: Finch) -> None: with client.jobs.automated.with_streaming_response.create( type="data_sync_all", ) as response: @@ -49,6 +49,40 @@ def test_streaming_response_create(self, client: Finch) -> None: assert cast(Any, response.is_closed) is True + @parametrize + def test_method_create_overload_2(self, client: Finch) -> None: + automated = client.jobs.automated.create( + individual_id="individual_id", + type="w4_data_sync", + ) + assert_matches_type(AutomatedCreateResponse, automated, path=["response"]) + + @parametrize + def test_raw_response_create_overload_2(self, client: Finch) -> None: + response = client.jobs.automated.with_raw_response.create( + individual_id="individual_id", + type="w4_data_sync", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + automated = response.parse() + assert_matches_type(AutomatedCreateResponse, automated, path=["response"]) + + @parametrize + def test_streaming_response_create_overload_2(self, client: Finch) -> None: + with client.jobs.automated.with_streaming_response.create( + individual_id="individual_id", + type="w4_data_sync", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + automated = response.parse() + assert_matches_type(AutomatedCreateResponse, automated, path=["response"]) + + assert cast(Any, response.is_closed) is True + @parametrize def test_method_retrieve(self, client: Finch) -> None: automated = client.jobs.automated.retrieve( @@ -125,14 +159,14 @@ class TestAsyncAutomated: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @parametrize - async def test_method_create(self, async_client: AsyncFinch) -> None: + async def test_method_create_overload_1(self, async_client: AsyncFinch) -> None: automated = await async_client.jobs.automated.create( type="data_sync_all", ) assert_matches_type(AutomatedCreateResponse, automated, path=["response"]) @parametrize - async def test_raw_response_create(self, async_client: AsyncFinch) -> None: + async def test_raw_response_create_overload_1(self, async_client: AsyncFinch) -> None: response = await async_client.jobs.automated.with_raw_response.create( type="data_sync_all", ) @@ -143,7 +177,7 @@ async def test_raw_response_create(self, async_client: AsyncFinch) -> None: assert_matches_type(AutomatedCreateResponse, automated, path=["response"]) @parametrize - async def test_streaming_response_create(self, async_client: AsyncFinch) -> None: + async def test_streaming_response_create_overload_1(self, async_client: AsyncFinch) -> None: async with async_client.jobs.automated.with_streaming_response.create( type="data_sync_all", ) as response: @@ -155,6 +189,40 @@ async def test_streaming_response_create(self, async_client: AsyncFinch) -> None assert cast(Any, response.is_closed) is True + @parametrize + async def test_method_create_overload_2(self, async_client: AsyncFinch) -> None: + automated = await async_client.jobs.automated.create( + individual_id="individual_id", + type="w4_data_sync", + ) + assert_matches_type(AutomatedCreateResponse, automated, path=["response"]) + + @parametrize + async def test_raw_response_create_overload_2(self, async_client: AsyncFinch) -> None: + response = await async_client.jobs.automated.with_raw_response.create( + individual_id="individual_id", + type="w4_data_sync", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + automated = response.parse() + assert_matches_type(AutomatedCreateResponse, automated, path=["response"]) + + @parametrize + async def test_streaming_response_create_overload_2(self, async_client: AsyncFinch) -> None: + async with async_client.jobs.automated.with_streaming_response.create( + individual_id="individual_id", + type="w4_data_sync", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + automated = await response.parse() + assert_matches_type(AutomatedCreateResponse, automated, path=["response"]) + + assert cast(Any, response.is_closed) is True + @parametrize async def test_method_retrieve(self, async_client: AsyncFinch) -> None: automated = await async_client.jobs.automated.retrieve(