From e4ceb07aeece769c134d4ccb2b8de2a6c8a0ce15 Mon Sep 17 00:00:00 2001 From: stainless-bot Date: Fri, 12 Jul 2024 04:09:59 +0000 Subject: [PATCH] feat(api): OpenAPI spec update via Stainless API --- .stats.yml | 4 +- api.md | 9 +- src/structify/resources/runs.py | 79 ++++++++++++++++++ src/structify/types/__init__.py | 1 + src/structify/types/run_get_steps_response.py | 9 ++ tests/api_resources/test_runs.py | 83 ++++++++++++++++++- 6 files changed, 181 insertions(+), 4 deletions(-) create mode 100644 src/structify/types/run_get_steps_response.py diff --git a/.stats.yml b/.stats.yml index b6a8878f5..cadbd21bd 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 28 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/structify%2Fstructify-647d01f2b9cf0426e628f9049573a48a482b7af7f214df87a1d5ff64e80db2f1.yml +configured_endpoints: 29 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/structify%2Fstructify-5b6afe9b6d45bca4a8fdf73c2a1473465d60df3d67f61b673d0e399ed10d2ce2.yml diff --git a/api.md b/api.md index b330dcff3..cbe635235 100644 --- a/api.md +++ b/api.md @@ -61,7 +61,13 @@ Methods: Types: ```python -from structify.types import RunListResponse, RunDeleteResponse, RunCancelResponse, RunGetResponse +from structify.types import ( + RunListResponse, + RunDeleteResponse, + RunCancelResponse, + RunGetResponse, + RunGetStepsResponse, +) ``` Methods: @@ -70,6 +76,7 @@ Methods: - client.runs.delete(uuid) -> str - client.runs.cancel(uuid) -> RunCancelResponse - client.runs.get(uuid) -> RunGetResponse +- client.runs.get_steps(job_id) -> RunGetStepsResponse - client.runs.schedule() -> None # Server diff --git a/src/structify/resources/runs.py b/src/structify/resources/runs.py index 6c73ab58f..aa2910193 100644 --- a/src/structify/resources/runs.py +++ b/src/structify/resources/runs.py @@ -20,6 +20,7 @@ from ..types.run_get_response import RunGetResponse from ..types.run_list_response import RunListResponse from ..types.run_cancel_response import RunCancelResponse +from ..types.run_get_steps_response import RunGetStepsResponse __all__ = ["RunsResource", "AsyncRunsResource"] @@ -176,6 +177,39 @@ def get( cast_to=RunGetResponse, ) + def get_steps( + self, + job_id: str, + *, + # 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, + ) -> RunGetStepsResponse: + """ + Retrieve a run from structify. + + Args: + 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 + """ + if not job_id: + raise ValueError(f"Expected a non-empty value for `job_id` but received {job_id!r}") + return self._get( + f"/runs/get_steps/{job_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=RunGetStepsResponse, + ) + def schedule( self, *, @@ -352,6 +386,39 @@ async def get( cast_to=RunGetResponse, ) + async def get_steps( + self, + job_id: str, + *, + # 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, + ) -> RunGetStepsResponse: + """ + Retrieve a run from structify. + + Args: + 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 + """ + if not job_id: + raise ValueError(f"Expected a non-empty value for `job_id` but received {job_id!r}") + return await self._get( + f"/runs/get_steps/{job_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=RunGetStepsResponse, + ) + async def schedule( self, *, @@ -392,6 +459,9 @@ def __init__(self, runs: RunsResource) -> None: self.get = to_raw_response_wrapper( runs.get, ) + self.get_steps = to_raw_response_wrapper( + runs.get_steps, + ) self.schedule = to_raw_response_wrapper( runs.schedule, ) @@ -413,6 +483,9 @@ def __init__(self, runs: AsyncRunsResource) -> None: self.get = async_to_raw_response_wrapper( runs.get, ) + self.get_steps = async_to_raw_response_wrapper( + runs.get_steps, + ) self.schedule = async_to_raw_response_wrapper( runs.schedule, ) @@ -434,6 +507,9 @@ def __init__(self, runs: RunsResource) -> None: self.get = to_streamed_response_wrapper( runs.get, ) + self.get_steps = to_streamed_response_wrapper( + runs.get_steps, + ) self.schedule = to_streamed_response_wrapper( runs.schedule, ) @@ -455,6 +531,9 @@ def __init__(self, runs: AsyncRunsResource) -> None: self.get = async_to_streamed_response_wrapper( runs.get, ) + self.get_steps = async_to_streamed_response_wrapper( + runs.get_steps, + ) self.schedule = async_to_streamed_response_wrapper( runs.schedule, ) diff --git a/src/structify/types/__init__.py b/src/structify/types/__init__.py index 9d859d370..76589b7e0 100644 --- a/src/structify/types/__init__.py +++ b/src/structify/types/__init__.py @@ -40,6 +40,7 @@ from .label_update_response import LabelUpdateResponse as LabelUpdateResponse from .document_list_response import DocumentListResponse as DocumentListResponse from .document_upload_params import DocumentUploadParams as DocumentUploadParams +from .run_get_steps_response import RunGetStepsResponse as RunGetStepsResponse from .extraction_criteria_param import ExtractionCriteriaParam as ExtractionCriteriaParam from .label_get_messages_params import LabelGetMessagesParams as LabelGetMessagesParams from .label_llm_assist_response import LabelLlmAssistResponse as LabelLlmAssistResponse diff --git a/src/structify/types/run_get_steps_response.py b/src/structify/types/run_get_steps_response.py new file mode 100644 index 000000000..63ae4dc12 --- /dev/null +++ b/src/structify/types/run_get_steps_response.py @@ -0,0 +1,9 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List + +from .execution_step import ExecutionStep + +__all__ = ["RunGetStepsResponse"] + +RunGetStepsResponse = List[ExecutionStep] diff --git a/tests/api_resources/test_runs.py b/tests/api_resources/test_runs.py index 4b903c666..ac1739f7a 100644 --- a/tests/api_resources/test_runs.py +++ b/tests/api_resources/test_runs.py @@ -9,7 +9,12 @@ from structify import Structify, AsyncStructify from tests.utils import assert_matches_type -from structify.types import RunGetResponse, RunListResponse, RunCancelResponse +from structify.types import ( + RunGetResponse, + RunListResponse, + RunCancelResponse, + RunGetStepsResponse, +) from structify.pagination import SyncRunsList, AsyncRunsList base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -165,6 +170,44 @@ def test_path_params_get(self, client: Structify) -> None: "", ) + @parametrize + def test_method_get_steps(self, client: Structify) -> None: + run = client.runs.get_steps( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(RunGetStepsResponse, run, path=["response"]) + + @parametrize + def test_raw_response_get_steps(self, client: Structify) -> None: + response = client.runs.with_raw_response.get_steps( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + run = response.parse() + assert_matches_type(RunGetStepsResponse, run, path=["response"]) + + @parametrize + def test_streaming_response_get_steps(self, client: Structify) -> None: + with client.runs.with_streaming_response.get_steps( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + run = response.parse() + assert_matches_type(RunGetStepsResponse, run, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_get_steps(self, client: Structify) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `job_id` but received ''"): + client.runs.with_raw_response.get_steps( + "", + ) + @parametrize def test_method_schedule(self, client: Structify) -> None: run = client.runs.schedule() @@ -341,6 +384,44 @@ async def test_path_params_get(self, async_client: AsyncStructify) -> None: "", ) + @parametrize + async def test_method_get_steps(self, async_client: AsyncStructify) -> None: + run = await async_client.runs.get_steps( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + assert_matches_type(RunGetStepsResponse, run, path=["response"]) + + @parametrize + async def test_raw_response_get_steps(self, async_client: AsyncStructify) -> None: + response = await async_client.runs.with_raw_response.get_steps( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + run = await response.parse() + assert_matches_type(RunGetStepsResponse, run, path=["response"]) + + @parametrize + async def test_streaming_response_get_steps(self, async_client: AsyncStructify) -> None: + async with async_client.runs.with_streaming_response.get_steps( + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + run = await response.parse() + assert_matches_type(RunGetStepsResponse, run, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_get_steps(self, async_client: AsyncStructify) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `job_id` but received ''"): + await async_client.runs.with_raw_response.get_steps( + "", + ) + @parametrize async def test_method_schedule(self, async_client: AsyncStructify) -> None: run = await async_client.runs.schedule()