From b8df10863e947363a911582eeee371f67db20ca0 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 18 Apr 2024 20:32:14 +0000 Subject: [PATCH 1/2] feat(api): update via SDK Studio (#13) --- README.md | 22 +++--- api.md | 6 +- src/rizaio/_client.py | 16 ++--- src/rizaio/resources/__init__.py | 26 +++---- src/rizaio/resources/{code.py => sandbox.py} | 68 +++++++++---------- src/rizaio/types/__init__.py | 4 +- ...te_params.py => sandbox_execute_params.py} | 4 +- ...esponse.py => sandbox_execute_response.py} | 4 +- .../{test_code.py => test_sandbox.py} | 46 ++++++------- 9 files changed, 98 insertions(+), 98 deletions(-) rename src/rizaio/resources/{code.py => sandbox.py} (73%) rename src/rizaio/types/{code_execute_params.py => sandbox_execute_params.py} (81%) rename src/rizaio/types/{code_execute_response.py => sandbox_execute_response.py} (76%) rename tests/api_resources/{test_code.py => test_sandbox.py} (62%) diff --git a/README.md b/README.md index ed0157e..cfec542 100644 --- a/README.md +++ b/README.md @@ -32,8 +32,8 @@ client = Riza( api_key=os.environ.get("RIZA_API_KEY"), ) -code_execute_response = client.code.execute() -print(code_execute_response.exit_code) +sandbox_execute_response = client.sandbox.execute() +print(sandbox_execute_response.exit_code) ``` While you can provide an `api_key` keyword argument, @@ -57,8 +57,8 @@ client = AsyncRiza( async def main() -> None: - code_execute_response = await client.code.execute() - print(code_execute_response.exit_code) + sandbox_execute_response = await client.sandbox.execute() + print(sandbox_execute_response.exit_code) asyncio.run(main()) @@ -91,7 +91,7 @@ from rizaio import Riza client = Riza() try: - client.code.execute() + client.sandbox.execute() except rizaio.APIConnectionError as e: print("The server could not be reached") print(e.__cause__) # an underlying Exception, likely raised within httpx. @@ -134,7 +134,7 @@ client = Riza( ) # Or, configure per-request: -client.with_options(max_retries=5).code.execute() +client.with_options(max_retries=5).sandbox.execute() ``` ### Timeouts @@ -157,7 +157,7 @@ client = Riza( ) # Override per-request: -client.with_options(timeout=5 * 1000).code.execute() +client.with_options(timeout=5 * 1000).sandbox.execute() ``` On timeout, an `APITimeoutError` is thrown. @@ -196,11 +196,11 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to from rizaio import Riza client = Riza() -response = client.code.with_raw_response.execute() +response = client.sandbox.with_raw_response.execute() print(response.headers.get('X-My-Header')) -code = response.parse() # get the object that `code.execute()` would have returned -print(code.exit_code) +sandbox = response.parse() # get the object that `sandbox.execute()` would have returned +print(sandbox.exit_code) ``` These methods return an [`APIResponse`](https://github.com/riza-io/riza-api-python/tree/main/src/rizaio/_response.py) object. @@ -214,7 +214,7 @@ The above interface eagerly reads the full response body when you make the reque To stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods. ```python -with client.code.with_streaming_response.execute() as response: +with client.sandbox.with_streaming_response.execute() as response: print(response.headers.get("X-My-Header")) for line in response.iter_lines(): diff --git a/api.md b/api.md index e4d75df..a554de3 100644 --- a/api.md +++ b/api.md @@ -1,11 +1,11 @@ -# Code +# Sandbox Types: ```python -from rizaio.types import CodeExecuteResponse +from rizaio.types import SandboxExecuteResponse ``` Methods: -- client.code.execute(\*\*params) -> CodeExecuteResponse +- client.sandbox.execute(\*\*params) -> SandboxExecuteResponse diff --git a/src/rizaio/_client.py b/src/rizaio/_client.py index 7f87701..dcddbda 100644 --- a/src/rizaio/_client.py +++ b/src/rizaio/_client.py @@ -46,7 +46,7 @@ class Riza(SyncAPIClient): - code: resources.Code + sandbox: resources.Sandbox with_raw_response: RizaWithRawResponse with_streaming_response: RizaWithStreamedResponse @@ -104,7 +104,7 @@ def __init__( _strict_response_validation=_strict_response_validation, ) - self.code = resources.Code(self) + self.sandbox = resources.Sandbox(self) self.with_raw_response = RizaWithRawResponse(self) self.with_streaming_response = RizaWithStreamedResponse(self) @@ -214,7 +214,7 @@ def _make_status_error( class AsyncRiza(AsyncAPIClient): - code: resources.AsyncCode + sandbox: resources.AsyncSandbox with_raw_response: AsyncRizaWithRawResponse with_streaming_response: AsyncRizaWithStreamedResponse @@ -272,7 +272,7 @@ def __init__( _strict_response_validation=_strict_response_validation, ) - self.code = resources.AsyncCode(self) + self.sandbox = resources.AsyncSandbox(self) self.with_raw_response = AsyncRizaWithRawResponse(self) self.with_streaming_response = AsyncRizaWithStreamedResponse(self) @@ -383,22 +383,22 @@ def _make_status_error( class RizaWithRawResponse: def __init__(self, client: Riza) -> None: - self.code = resources.CodeWithRawResponse(client.code) + self.sandbox = resources.SandboxWithRawResponse(client.sandbox) class AsyncRizaWithRawResponse: def __init__(self, client: AsyncRiza) -> None: - self.code = resources.AsyncCodeWithRawResponse(client.code) + self.sandbox = resources.AsyncSandboxWithRawResponse(client.sandbox) class RizaWithStreamedResponse: def __init__(self, client: Riza) -> None: - self.code = resources.CodeWithStreamingResponse(client.code) + self.sandbox = resources.SandboxWithStreamingResponse(client.sandbox) class AsyncRizaWithStreamedResponse: def __init__(self, client: AsyncRiza) -> None: - self.code = resources.AsyncCodeWithStreamingResponse(client.code) + self.sandbox = resources.AsyncSandboxWithStreamingResponse(client.sandbox) Client = Riza diff --git a/src/rizaio/resources/__init__.py b/src/rizaio/resources/__init__.py index e6facc2..f6e6d7e 100644 --- a/src/rizaio/resources/__init__.py +++ b/src/rizaio/resources/__init__.py @@ -1,19 +1,19 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from .code import ( - Code, - AsyncCode, - CodeWithRawResponse, - AsyncCodeWithRawResponse, - CodeWithStreamingResponse, - AsyncCodeWithStreamingResponse, +from .sandbox import ( + Sandbox, + AsyncSandbox, + SandboxWithRawResponse, + AsyncSandboxWithRawResponse, + SandboxWithStreamingResponse, + AsyncSandboxWithStreamingResponse, ) __all__ = [ - "Code", - "AsyncCode", - "CodeWithRawResponse", - "AsyncCodeWithRawResponse", - "CodeWithStreamingResponse", - "AsyncCodeWithStreamingResponse", + "Sandbox", + "AsyncSandbox", + "SandboxWithRawResponse", + "AsyncSandboxWithRawResponse", + "SandboxWithStreamingResponse", + "AsyncSandboxWithStreamingResponse", ] diff --git a/src/rizaio/resources/code.py b/src/rizaio/resources/sandbox.py similarity index 73% rename from src/rizaio/resources/code.py rename to src/rizaio/resources/sandbox.py index 5c13dec..bc3a32a 100644 --- a/src/rizaio/resources/code.py +++ b/src/rizaio/resources/sandbox.py @@ -7,7 +7,7 @@ import httpx -from ..types import CodeExecuteResponse, code_execute_params +from ..types import SandboxExecuteResponse, sandbox_execute_params from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven from .._utils import ( maybe_transform, @@ -25,17 +25,17 @@ make_request_options, ) -__all__ = ["Code", "AsyncCode"] +__all__ = ["Sandbox", "AsyncSandbox"] -class Code(SyncAPIResource): +class Sandbox(SyncAPIResource): @cached_property - def with_raw_response(self) -> CodeWithRawResponse: - return CodeWithRawResponse(self) + def with_raw_response(self) -> SandboxWithRawResponse: + return SandboxWithRawResponse(self) @cached_property - def with_streaming_response(self) -> CodeWithStreamingResponse: - return CodeWithStreamingResponse(self) + def with_streaming_response(self) -> SandboxWithStreamingResponse: + return SandboxWithStreamingResponse(self) def execute( self, @@ -51,7 +51,7 @@ def execute( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> CodeExecuteResponse: + ) -> SandboxExecuteResponse: """ Args: extra_headers: Send extra headers @@ -72,23 +72,23 @@ def execute( "language": language, "stdin": stdin, }, - code_execute_params.CodeExecuteParams, + sandbox_execute_params.SandboxExecuteParams, ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=CodeExecuteResponse, + cast_to=SandboxExecuteResponse, ) -class AsyncCode(AsyncAPIResource): +class AsyncSandbox(AsyncAPIResource): @cached_property - def with_raw_response(self) -> AsyncCodeWithRawResponse: - return AsyncCodeWithRawResponse(self) + def with_raw_response(self) -> AsyncSandboxWithRawResponse: + return AsyncSandboxWithRawResponse(self) @cached_property - def with_streaming_response(self) -> AsyncCodeWithStreamingResponse: - return AsyncCodeWithStreamingResponse(self) + def with_streaming_response(self) -> AsyncSandboxWithStreamingResponse: + return AsyncSandboxWithStreamingResponse(self) async def execute( self, @@ -104,7 +104,7 @@ async def execute( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> CodeExecuteResponse: + ) -> SandboxExecuteResponse: """ Args: extra_headers: Send extra headers @@ -125,46 +125,46 @@ async def execute( "language": language, "stdin": stdin, }, - code_execute_params.CodeExecuteParams, + sandbox_execute_params.SandboxExecuteParams, ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=CodeExecuteResponse, + cast_to=SandboxExecuteResponse, ) -class CodeWithRawResponse: - def __init__(self, code: Code) -> None: - self._code = code +class SandboxWithRawResponse: + def __init__(self, sandbox: Sandbox) -> None: + self._sandbox = sandbox self.execute = to_raw_response_wrapper( - code.execute, + sandbox.execute, ) -class AsyncCodeWithRawResponse: - def __init__(self, code: AsyncCode) -> None: - self._code = code +class AsyncSandboxWithRawResponse: + def __init__(self, sandbox: AsyncSandbox) -> None: + self._sandbox = sandbox self.execute = async_to_raw_response_wrapper( - code.execute, + sandbox.execute, ) -class CodeWithStreamingResponse: - def __init__(self, code: Code) -> None: - self._code = code +class SandboxWithStreamingResponse: + def __init__(self, sandbox: Sandbox) -> None: + self._sandbox = sandbox self.execute = to_streamed_response_wrapper( - code.execute, + sandbox.execute, ) -class AsyncCodeWithStreamingResponse: - def __init__(self, code: AsyncCode) -> None: - self._code = code +class AsyncSandboxWithStreamingResponse: + def __init__(self, sandbox: AsyncSandbox) -> None: + self._sandbox = sandbox self.execute = async_to_streamed_response_wrapper( - code.execute, + sandbox.execute, ) diff --git a/src/rizaio/types/__init__.py b/src/rizaio/types/__init__.py index f962f3a..c64b119 100644 --- a/src/rizaio/types/__init__.py +++ b/src/rizaio/types/__init__.py @@ -2,5 +2,5 @@ from __future__ import annotations -from .code_execute_params import CodeExecuteParams as CodeExecuteParams -from .code_execute_response import CodeExecuteResponse as CodeExecuteResponse +from .sandbox_execute_params import SandboxExecuteParams as SandboxExecuteParams +from .sandbox_execute_response import SandboxExecuteResponse as SandboxExecuteResponse diff --git a/src/rizaio/types/code_execute_params.py b/src/rizaio/types/sandbox_execute_params.py similarity index 81% rename from src/rizaio/types/code_execute_params.py rename to src/rizaio/types/sandbox_execute_params.py index 82c07aa..13cc482 100644 --- a/src/rizaio/types/code_execute_params.py +++ b/src/rizaio/types/sandbox_execute_params.py @@ -5,10 +5,10 @@ from typing import Dict, List from typing_extensions import Literal, TypedDict -__all__ = ["CodeExecuteParams"] +__all__ = ["SandboxExecuteParams"] -class CodeExecuteParams(TypedDict, total=False): +class SandboxExecuteParams(TypedDict, total=False): args: List[str] code: str diff --git a/src/rizaio/types/code_execute_response.py b/src/rizaio/types/sandbox_execute_response.py similarity index 76% rename from src/rizaio/types/code_execute_response.py rename to src/rizaio/types/sandbox_execute_response.py index e05aa21..b9af54e 100644 --- a/src/rizaio/types/code_execute_response.py +++ b/src/rizaio/types/sandbox_execute_response.py @@ -4,10 +4,10 @@ from .._models import BaseModel -__all__ = ["CodeExecuteResponse"] +__all__ = ["SandboxExecuteResponse"] -class CodeExecuteResponse(BaseModel): +class SandboxExecuteResponse(BaseModel): exit_code: Optional[int] = None stderr: Optional[str] = None diff --git a/tests/api_resources/test_code.py b/tests/api_resources/test_sandbox.py similarity index 62% rename from tests/api_resources/test_code.py rename to tests/api_resources/test_sandbox.py index 9d4ecba..646ecf0 100644 --- a/tests/api_resources/test_code.py +++ b/tests/api_resources/test_sandbox.py @@ -9,86 +9,86 @@ from rizaio import Riza, AsyncRiza from tests.utils import assert_matches_type -from rizaio.types import CodeExecuteResponse +from rizaio.types import SandboxExecuteResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -class TestCode: +class TestSandbox: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) @parametrize def test_method_execute(self, client: Riza) -> None: - code = client.code.execute() - assert_matches_type(CodeExecuteResponse, code, path=["response"]) + sandbox = client.sandbox.execute() + assert_matches_type(SandboxExecuteResponse, sandbox, path=["response"]) @parametrize def test_method_execute_with_all_params(self, client: Riza) -> None: - code = client.code.execute( + sandbox = client.sandbox.execute( args=["string", "string", "string"], code="string", env={"foo": "string"}, language="UNSPECIFIED", stdin="string", ) - assert_matches_type(CodeExecuteResponse, code, path=["response"]) + assert_matches_type(SandboxExecuteResponse, sandbox, path=["response"]) @parametrize def test_raw_response_execute(self, client: Riza) -> None: - response = client.code.with_raw_response.execute() + response = client.sandbox.with_raw_response.execute() assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - code = response.parse() - assert_matches_type(CodeExecuteResponse, code, path=["response"]) + sandbox = response.parse() + assert_matches_type(SandboxExecuteResponse, sandbox, path=["response"]) @parametrize def test_streaming_response_execute(self, client: Riza) -> None: - with client.code.with_streaming_response.execute() as response: + with client.sandbox.with_streaming_response.execute() as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - code = response.parse() - assert_matches_type(CodeExecuteResponse, code, path=["response"]) + sandbox = response.parse() + assert_matches_type(SandboxExecuteResponse, sandbox, path=["response"]) assert cast(Any, response.is_closed) is True -class TestAsyncCode: +class TestAsyncSandbox: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @parametrize async def test_method_execute(self, async_client: AsyncRiza) -> None: - code = await async_client.code.execute() - assert_matches_type(CodeExecuteResponse, code, path=["response"]) + sandbox = await async_client.sandbox.execute() + assert_matches_type(SandboxExecuteResponse, sandbox, path=["response"]) @parametrize async def test_method_execute_with_all_params(self, async_client: AsyncRiza) -> None: - code = await async_client.code.execute( + sandbox = await async_client.sandbox.execute( args=["string", "string", "string"], code="string", env={"foo": "string"}, language="UNSPECIFIED", stdin="string", ) - assert_matches_type(CodeExecuteResponse, code, path=["response"]) + assert_matches_type(SandboxExecuteResponse, sandbox, path=["response"]) @parametrize async def test_raw_response_execute(self, async_client: AsyncRiza) -> None: - response = await async_client.code.with_raw_response.execute() + response = await async_client.sandbox.with_raw_response.execute() assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - code = await response.parse() - assert_matches_type(CodeExecuteResponse, code, path=["response"]) + sandbox = await response.parse() + assert_matches_type(SandboxExecuteResponse, sandbox, path=["response"]) @parametrize async def test_streaming_response_execute(self, async_client: AsyncRiza) -> None: - async with async_client.code.with_streaming_response.execute() as response: + async with async_client.sandbox.with_streaming_response.execute() as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - code = await response.parse() - assert_matches_type(CodeExecuteResponse, code, path=["response"]) + sandbox = await response.parse() + assert_matches_type(SandboxExecuteResponse, sandbox, path=["response"]) assert cast(Any, response.is_closed) is True From fb698ad71f85402d589278add45cbb05e4462eeb Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 18 Apr 2024 20:32:25 +0000 Subject: [PATCH 2/2] release: 0.1.0-alpha.4 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 8 ++++++++ pyproject.toml | 2 +- src/rizaio/_version.py | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index aaf968a..b56c3d0 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.3" + ".": "0.1.0-alpha.4" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a8cece..7ddca00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.1.0-alpha.4 (2024-04-18) + +Full Changelog: [v0.1.0-alpha.3...v0.1.0-alpha.4](https://github.com/riza-io/riza-api-python/compare/v0.1.0-alpha.3...v0.1.0-alpha.4) + +### Features + +* **api:** update via SDK Studio ([#13](https://github.com/riza-io/riza-api-python/issues/13)) ([b8df108](https://github.com/riza-io/riza-api-python/commit/b8df10863e947363a911582eeee371f67db20ca0)) + ## 0.1.0-alpha.3 (2024-04-18) Full Changelog: [v0.1.0-alpha.2...v0.1.0-alpha.3](https://github.com/riza-io/riza-api-python/compare/v0.1.0-alpha.2...v0.1.0-alpha.3) diff --git a/pyproject.toml b/pyproject.toml index 1a892bc..f7e57af 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "rizaio" -version = "0.1.0-alpha.3" +version = "0.1.0-alpha.4" description = "The official Python library for the riza API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/rizaio/_version.py b/src/rizaio/_version.py index 97a33dd..aef7326 100644 --- a/src/rizaio/_version.py +++ b/src/rizaio/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "rizaio" -__version__ = "0.1.0-alpha.3" # x-release-please-version +__version__ = "0.1.0-alpha.4" # x-release-please-version