Skip to content

feat(api): api update #523

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -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
161 changes: 150 additions & 11 deletions src/finch/resources/jobs/automated.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down Expand Up @@ -44,6 +45,7 @@ def with_streaming_response(self) -> AutomatedWithStreamingResponse:
"""
return AutomatedWithStreamingResponse(self)

@overload
def create(
self,
*,
Expand All @@ -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

Expand All @@ -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
),
Expand Down Expand Up @@ -192,6 +262,7 @@ def with_streaming_response(self) -> AsyncAutomatedWithStreamingResponse:
"""
return AsyncAutomatedWithStreamingResponse(self)

@overload
async def create(
self,
*,
Expand All @@ -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

Expand All @@ -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
),
Expand Down
20 changes: 16 additions & 4 deletions src/finch/types/jobs/automated_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Loading