From 1cc6f500aeb590cc1523e6f072de0ebe66b8525b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 15 Jan 2025 19:28:08 +0000 Subject: [PATCH] feat(api): api update (#106) --- .stats.yml | 2 +- src/rizaio/resources/command.py | 16 ++++++++-------- src/rizaio/types/command_exec_params.py | 6 +++--- tests/api_resources/test_command.py | 10 ++++++++-- tests/test_client.py | 12 ++++++------ 5 files changed, 26 insertions(+), 20 deletions(-) diff --git a/.stats.yml b/.stats.yml index cdad2d4..20e3e7b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 14 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/riza%2Friza-api-fbf471c508c87d8f33abb016566e4a23c1a188f8097af9bab707cd0f13c0663b.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/riza%2Friza-api-84e9b4b2a2fb6fbedc1e35fc9134949ec5609ae6fb71f1ec1e9818b2bdf7abcc.yml diff --git a/src/rizaio/resources/command.py b/src/rizaio/resources/command.py index b6f21e9..ffc8302 100644 --- a/src/rizaio/resources/command.py +++ b/src/rizaio/resources/command.py @@ -51,12 +51,12 @@ def exec( self, *, code: str, + language: Literal["python", "javascript", "typescript", "ruby", "php"], allow_http_hosts: List[str] | NotGiven = NOT_GIVEN, args: List[str] | NotGiven = NOT_GIVEN, env: Dict[str, str] | NotGiven = NOT_GIVEN, files: Iterable[command_exec_params.File] | NotGiven = NOT_GIVEN, http: Optional[command_exec_params.HTTP] | NotGiven = NOT_GIVEN, - language: Literal["python", "javascript", "typescript", "ruby", "php"] | NotGiven = NOT_GIVEN, limits: Optional[command_exec_params.Limits] | NotGiven = NOT_GIVEN, runtime_revision_id: str | NotGiven = NOT_GIVEN, stdin: str | NotGiven = NOT_GIVEN, @@ -76,6 +76,8 @@ def exec( Args: code: The code to execute. + language: The interpreter to use when executing code. + allow_http_hosts: List of allowed hosts for HTTP requests. args: List of command line arguments to pass to the script. @@ -86,8 +88,6 @@ def exec( http: Configuration for HTTP requests and authentication. - language: The interpreter to use when executing code. - limits: Configuration for execution environment limits. runtime_revision_id: The ID of the runtime revision to use when executing code. @@ -107,12 +107,12 @@ def exec( body=maybe_transform( { "code": code, + "language": language, "allow_http_hosts": allow_http_hosts, "args": args, "env": env, "files": files, "http": http, - "language": language, "limits": limits, "runtime_revision_id": runtime_revision_id, "stdin": stdin, @@ -150,12 +150,12 @@ async def exec( self, *, code: str, + language: Literal["python", "javascript", "typescript", "ruby", "php"], allow_http_hosts: List[str] | NotGiven = NOT_GIVEN, args: List[str] | NotGiven = NOT_GIVEN, env: Dict[str, str] | NotGiven = NOT_GIVEN, files: Iterable[command_exec_params.File] | NotGiven = NOT_GIVEN, http: Optional[command_exec_params.HTTP] | NotGiven = NOT_GIVEN, - language: Literal["python", "javascript", "typescript", "ruby", "php"] | NotGiven = NOT_GIVEN, limits: Optional[command_exec_params.Limits] | NotGiven = NOT_GIVEN, runtime_revision_id: str | NotGiven = NOT_GIVEN, stdin: str | NotGiven = NOT_GIVEN, @@ -175,6 +175,8 @@ async def exec( Args: code: The code to execute. + language: The interpreter to use when executing code. + allow_http_hosts: List of allowed hosts for HTTP requests. args: List of command line arguments to pass to the script. @@ -185,8 +187,6 @@ async def exec( http: Configuration for HTTP requests and authentication. - language: The interpreter to use when executing code. - limits: Configuration for execution environment limits. runtime_revision_id: The ID of the runtime revision to use when executing code. @@ -206,12 +206,12 @@ async def exec( body=await async_maybe_transform( { "code": code, + "language": language, "allow_http_hosts": allow_http_hosts, "args": args, "env": env, "files": files, "http": http, - "language": language, "limits": limits, "runtime_revision_id": runtime_revision_id, "stdin": stdin, diff --git a/src/rizaio/types/command_exec_params.py b/src/rizaio/types/command_exec_params.py index 5d79063..6bf93e9 100644 --- a/src/rizaio/types/command_exec_params.py +++ b/src/rizaio/types/command_exec_params.py @@ -23,6 +23,9 @@ class CommandExecParams(TypedDict, total=False): code: Required[str] """The code to execute.""" + language: Required[Literal["python", "javascript", "typescript", "ruby", "php"]] + """The interpreter to use when executing code.""" + allow_http_hosts: List[str] """List of allowed hosts for HTTP requests.""" @@ -38,9 +41,6 @@ class CommandExecParams(TypedDict, total=False): http: Optional[HTTP] """Configuration for HTTP requests and authentication.""" - language: Literal["python", "javascript", "typescript", "ruby", "php"] - """The interpreter to use when executing code.""" - limits: Optional[Limits] """Configuration for execution environment limits.""" diff --git a/tests/api_resources/test_command.py b/tests/api_resources/test_command.py index d077321..757fc4d 100644 --- a/tests/api_resources/test_command.py +++ b/tests/api_resources/test_command.py @@ -21,6 +21,7 @@ class TestCommand: def test_method_exec(self, client: Riza) -> None: command = client.command.exec( code='print("Hello world!")', + language="python", ) assert_matches_type(CommandExecResponse, command, path=["response"]) @@ -28,6 +29,7 @@ def test_method_exec(self, client: Riza) -> None: def test_method_exec_with_all_params(self, client: Riza) -> None: command = client.command.exec( code='print("Hello world!")', + language="python", allow_http_hosts=["string"], args=["string"], env={"foo": "string"}, @@ -59,7 +61,6 @@ def test_method_exec_with_all_params(self, client: Riza) -> None: } ] }, - language="python", limits={ "execution_timeout": 0, "memory_size": 0, @@ -73,6 +74,7 @@ def test_method_exec_with_all_params(self, client: Riza) -> None: def test_raw_response_exec(self, client: Riza) -> None: response = client.command.with_raw_response.exec( code='print("Hello world!")', + language="python", ) assert response.is_closed is True @@ -84,6 +86,7 @@ def test_raw_response_exec(self, client: Riza) -> None: def test_streaming_response_exec(self, client: Riza) -> None: with client.command.with_streaming_response.exec( code='print("Hello world!")', + language="python", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -101,6 +104,7 @@ class TestAsyncCommand: async def test_method_exec(self, async_client: AsyncRiza) -> None: command = await async_client.command.exec( code='print("Hello world!")', + language="python", ) assert_matches_type(CommandExecResponse, command, path=["response"]) @@ -108,6 +112,7 @@ async def test_method_exec(self, async_client: AsyncRiza) -> None: async def test_method_exec_with_all_params(self, async_client: AsyncRiza) -> None: command = await async_client.command.exec( code='print("Hello world!")', + language="python", allow_http_hosts=["string"], args=["string"], env={"foo": "string"}, @@ -139,7 +144,6 @@ async def test_method_exec_with_all_params(self, async_client: AsyncRiza) -> Non } ] }, - language="python", limits={ "execution_timeout": 0, "memory_size": 0, @@ -153,6 +157,7 @@ async def test_method_exec_with_all_params(self, async_client: AsyncRiza) -> Non async def test_raw_response_exec(self, async_client: AsyncRiza) -> None: response = await async_client.command.with_raw_response.exec( code='print("Hello world!")', + language="python", ) assert response.is_closed is True @@ -164,6 +169,7 @@ async def test_raw_response_exec(self, async_client: AsyncRiza) -> None: async def test_streaming_response_exec(self, async_client: AsyncRiza) -> None: async with async_client.command.with_streaming_response.exec( code='print("Hello world!")', + language="python", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" diff --git a/tests/test_client.py b/tests/test_client.py index 644ce9d..f09f217 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -751,7 +751,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: respx_mock.post("/v1/execute").mock(side_effect=retry_handler) - response = client.command.with_raw_response.exec(code='print("Hello world!")') + response = client.command.with_raw_response.exec(code='print("Hello world!")', language="python") assert response.retries_taken == failures_before_success assert int(response.http_request.headers.get("x-stainless-retry-count")) == failures_before_success @@ -774,7 +774,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: respx_mock.post("/v1/execute").mock(side_effect=retry_handler) response = client.command.with_raw_response.exec( - code='print("Hello world!")', extra_headers={"x-stainless-retry-count": Omit()} + code='print("Hello world!")', language="python", extra_headers={"x-stainless-retry-count": Omit()} ) assert len(response.http_request.headers.get_list("x-stainless-retry-count")) == 0 @@ -799,7 +799,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: respx_mock.post("/v1/execute").mock(side_effect=retry_handler) response = client.command.with_raw_response.exec( - code='print("Hello world!")', extra_headers={"x-stainless-retry-count": "42"} + code='print("Hello world!")', language="python", extra_headers={"x-stainless-retry-count": "42"} ) assert response.http_request.headers.get("x-stainless-retry-count") == "42" @@ -1520,7 +1520,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: respx_mock.post("/v1/execute").mock(side_effect=retry_handler) - response = await client.command.with_raw_response.exec(code='print("Hello world!")') + response = await client.command.with_raw_response.exec(code='print("Hello world!")', language="python") assert response.retries_taken == failures_before_success assert int(response.http_request.headers.get("x-stainless-retry-count")) == failures_before_success @@ -1546,7 +1546,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: respx_mock.post("/v1/execute").mock(side_effect=retry_handler) response = await client.command.with_raw_response.exec( - code='print("Hello world!")', extra_headers={"x-stainless-retry-count": Omit()} + code='print("Hello world!")', language="python", extra_headers={"x-stainless-retry-count": Omit()} ) assert len(response.http_request.headers.get_list("x-stainless-retry-count")) == 0 @@ -1572,7 +1572,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: respx_mock.post("/v1/execute").mock(side_effect=retry_handler) response = await client.command.with_raw_response.exec( - code='print("Hello world!")', extra_headers={"x-stainless-retry-count": "42"} + code='print("Hello world!")', language="python", extra_headers={"x-stainless-retry-count": "42"} ) assert response.http_request.headers.get("x-stainless-retry-count") == "42"