diff --git a/README.md b/README.md
index 74b195f..8751603 100644
--- a/README.md
+++ b/README.md
@@ -32,8 +32,8 @@ client = Riza(
auth_token=os.environ.get("RIZA_AUTH_TOKEN"),
)
-top_level_execute_response = client.top_level.execute()
-print(top_level_execute_response.exit_code)
+code_execute_response = client.code.execute()
+print(code_execute_response.exit_code)
```
While you can provide a `auth_token` keyword argument,
@@ -57,8 +57,8 @@ client = AsyncRiza(
async def main() -> None:
- top_level_execute_response = await client.top_level.execute()
- print(top_level_execute_response.exit_code)
+ code_execute_response = await client.code.execute()
+ print(code_execute_response.exit_code)
asyncio.run(main())
@@ -91,7 +91,7 @@ from rizaio import Riza
client = Riza()
try:
- client.top_level.execute()
+ client.code.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).top_level.execute()
+client.with_options(max_retries=5).code.execute()
```
### Timeouts
@@ -157,7 +157,7 @@ client = Riza(
)
# Override per-request:
-client.with_options(timeout=5 * 1000).top_level.execute()
+client.with_options(timeout=5 * 1000).code.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.top_level.with_raw_response.execute()
+response = client.code.with_raw_response.execute()
print(response.headers.get('X-My-Header'))
-top_level = response.parse() # get the object that `top_level.execute()` would have returned
-print(top_level.exit_code)
+code = response.parse() # get the object that `code.execute()` would have returned
+print(code.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.top_level.with_streaming_response.execute() as response:
+with client.code.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 1996130..e4d75df 100644
--- a/api.md
+++ b/api.md
@@ -1,11 +1,11 @@
-# TopLevel
+# Code
Types:
```python
-from rizaio.types import TopLevelExecuteResponse
+from rizaio.types import CodeExecuteResponse
```
Methods:
-- client.top_level.execute(\*\*params) -> TopLevelExecuteResponse
+- client.code.execute(\*\*params) -> CodeExecuteResponse
diff --git a/src/rizaio/_client.py b/src/rizaio/_client.py
index 0bcfe99..0e7d40f 100644
--- a/src/rizaio/_client.py
+++ b/src/rizaio/_client.py
@@ -46,7 +46,7 @@
class Riza(SyncAPIClient):
- top_level: resources.TopLevel
+ code: resources.Code
with_raw_response: RizaWithRawResponse
with_streaming_response: RizaWithStreamedResponse
@@ -104,7 +104,7 @@ def __init__(
_strict_response_validation=_strict_response_validation,
)
- self.top_level = resources.TopLevel(self)
+ self.code = resources.Code(self)
self.with_raw_response = RizaWithRawResponse(self)
self.with_streaming_response = RizaWithStreamedResponse(self)
@@ -214,7 +214,7 @@ def _make_status_error(
class AsyncRiza(AsyncAPIClient):
- top_level: resources.AsyncTopLevel
+ code: resources.AsyncCode
with_raw_response: AsyncRizaWithRawResponse
with_streaming_response: AsyncRizaWithStreamedResponse
@@ -272,7 +272,7 @@ def __init__(
_strict_response_validation=_strict_response_validation,
)
- self.top_level = resources.AsyncTopLevel(self)
+ self.code = resources.AsyncCode(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.top_level = resources.TopLevelWithRawResponse(client.top_level)
+ self.code = resources.CodeWithRawResponse(client.code)
class AsyncRizaWithRawResponse:
def __init__(self, client: AsyncRiza) -> None:
- self.top_level = resources.AsyncTopLevelWithRawResponse(client.top_level)
+ self.code = resources.AsyncCodeWithRawResponse(client.code)
class RizaWithStreamedResponse:
def __init__(self, client: Riza) -> None:
- self.top_level = resources.TopLevelWithStreamingResponse(client.top_level)
+ self.code = resources.CodeWithStreamingResponse(client.code)
class AsyncRizaWithStreamedResponse:
def __init__(self, client: AsyncRiza) -> None:
- self.top_level = resources.AsyncTopLevelWithStreamingResponse(client.top_level)
+ self.code = resources.AsyncCodeWithStreamingResponse(client.code)
Client = Riza
diff --git a/src/rizaio/resources/__init__.py b/src/rizaio/resources/__init__.py
index 3106430..e6facc2 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 .top_level import (
- TopLevel,
- AsyncTopLevel,
- TopLevelWithRawResponse,
- AsyncTopLevelWithRawResponse,
- TopLevelWithStreamingResponse,
- AsyncTopLevelWithStreamingResponse,
+from .code import (
+ Code,
+ AsyncCode,
+ CodeWithRawResponse,
+ AsyncCodeWithRawResponse,
+ CodeWithStreamingResponse,
+ AsyncCodeWithStreamingResponse,
)
__all__ = [
- "TopLevel",
- "AsyncTopLevel",
- "TopLevelWithRawResponse",
- "AsyncTopLevelWithRawResponse",
- "TopLevelWithStreamingResponse",
- "AsyncTopLevelWithStreamingResponse",
+ "Code",
+ "AsyncCode",
+ "CodeWithRawResponse",
+ "AsyncCodeWithRawResponse",
+ "CodeWithStreamingResponse",
+ "AsyncCodeWithStreamingResponse",
]
diff --git a/src/rizaio/resources/top_level.py b/src/rizaio/resources/code.py
similarity index 72%
rename from src/rizaio/resources/top_level.py
rename to src/rizaio/resources/code.py
index ced7c7c..5c13dec 100644
--- a/src/rizaio/resources/top_level.py
+++ b/src/rizaio/resources/code.py
@@ -7,7 +7,7 @@
import httpx
-from ..types import TopLevelExecuteResponse, top_level_execute_params
+from ..types import CodeExecuteResponse, code_execute_params
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from .._utils import (
maybe_transform,
@@ -25,17 +25,17 @@
make_request_options,
)
-__all__ = ["TopLevel", "AsyncTopLevel"]
+__all__ = ["Code", "AsyncCode"]
-class TopLevel(SyncAPIResource):
+class Code(SyncAPIResource):
@cached_property
- def with_raw_response(self) -> TopLevelWithRawResponse:
- return TopLevelWithRawResponse(self)
+ def with_raw_response(self) -> CodeWithRawResponse:
+ return CodeWithRawResponse(self)
@cached_property
- def with_streaming_response(self) -> TopLevelWithStreamingResponse:
- return TopLevelWithStreamingResponse(self)
+ def with_streaming_response(self) -> CodeWithStreamingResponse:
+ return CodeWithStreamingResponse(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,
- ) -> TopLevelExecuteResponse:
+ ) -> CodeExecuteResponse:
"""
Args:
extra_headers: Send extra headers
@@ -72,23 +72,23 @@ def execute(
"language": language,
"stdin": stdin,
},
- top_level_execute_params.TopLevelExecuteParams,
+ code_execute_params.CodeExecuteParams,
),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
- cast_to=TopLevelExecuteResponse,
+ cast_to=CodeExecuteResponse,
)
-class AsyncTopLevel(AsyncAPIResource):
+class AsyncCode(AsyncAPIResource):
@cached_property
- def with_raw_response(self) -> AsyncTopLevelWithRawResponse:
- return AsyncTopLevelWithRawResponse(self)
+ def with_raw_response(self) -> AsyncCodeWithRawResponse:
+ return AsyncCodeWithRawResponse(self)
@cached_property
- def with_streaming_response(self) -> AsyncTopLevelWithStreamingResponse:
- return AsyncTopLevelWithStreamingResponse(self)
+ def with_streaming_response(self) -> AsyncCodeWithStreamingResponse:
+ return AsyncCodeWithStreamingResponse(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,
- ) -> TopLevelExecuteResponse:
+ ) -> CodeExecuteResponse:
"""
Args:
extra_headers: Send extra headers
@@ -125,46 +125,46 @@ async def execute(
"language": language,
"stdin": stdin,
},
- top_level_execute_params.TopLevelExecuteParams,
+ code_execute_params.CodeExecuteParams,
),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
- cast_to=TopLevelExecuteResponse,
+ cast_to=CodeExecuteResponse,
)
-class TopLevelWithRawResponse:
- def __init__(self, top_level: TopLevel) -> None:
- self._top_level = top_level
+class CodeWithRawResponse:
+ def __init__(self, code: Code) -> None:
+ self._code = code
self.execute = to_raw_response_wrapper(
- top_level.execute,
+ code.execute,
)
-class AsyncTopLevelWithRawResponse:
- def __init__(self, top_level: AsyncTopLevel) -> None:
- self._top_level = top_level
+class AsyncCodeWithRawResponse:
+ def __init__(self, code: AsyncCode) -> None:
+ self._code = code
self.execute = async_to_raw_response_wrapper(
- top_level.execute,
+ code.execute,
)
-class TopLevelWithStreamingResponse:
- def __init__(self, top_level: TopLevel) -> None:
- self._top_level = top_level
+class CodeWithStreamingResponse:
+ def __init__(self, code: Code) -> None:
+ self._code = code
self.execute = to_streamed_response_wrapper(
- top_level.execute,
+ code.execute,
)
-class AsyncTopLevelWithStreamingResponse:
- def __init__(self, top_level: AsyncTopLevel) -> None:
- self._top_level = top_level
+class AsyncCodeWithStreamingResponse:
+ def __init__(self, code: AsyncCode) -> None:
+ self._code = code
self.execute = async_to_streamed_response_wrapper(
- top_level.execute,
+ code.execute,
)
diff --git a/src/rizaio/types/__init__.py b/src/rizaio/types/__init__.py
index da8cde5..f962f3a 100644
--- a/src/rizaio/types/__init__.py
+++ b/src/rizaio/types/__init__.py
@@ -2,5 +2,5 @@
from __future__ import annotations
-from .top_level_execute_params import TopLevelExecuteParams as TopLevelExecuteParams
-from .top_level_execute_response import TopLevelExecuteResponse as TopLevelExecuteResponse
+from .code_execute_params import CodeExecuteParams as CodeExecuteParams
+from .code_execute_response import CodeExecuteResponse as CodeExecuteResponse
diff --git a/src/rizaio/types/top_level_execute_params.py b/src/rizaio/types/code_execute_params.py
similarity index 80%
rename from src/rizaio/types/top_level_execute_params.py
rename to src/rizaio/types/code_execute_params.py
index 63ee781..82c07aa 100644
--- a/src/rizaio/types/top_level_execute_params.py
+++ b/src/rizaio/types/code_execute_params.py
@@ -5,10 +5,10 @@
from typing import Dict, List
from typing_extensions import Literal, TypedDict
-__all__ = ["TopLevelExecuteParams"]
+__all__ = ["CodeExecuteParams"]
-class TopLevelExecuteParams(TypedDict, total=False):
+class CodeExecuteParams(TypedDict, total=False):
args: List[str]
code: str
diff --git a/src/rizaio/types/top_level_execute_response.py b/src/rizaio/types/code_execute_response.py
similarity index 80%
rename from src/rizaio/types/top_level_execute_response.py
rename to src/rizaio/types/code_execute_response.py
index 14afbe4..3df11fc 100644
--- a/src/rizaio/types/top_level_execute_response.py
+++ b/src/rizaio/types/code_execute_response.py
@@ -6,10 +6,10 @@
from .._models import BaseModel
-__all__ = ["TopLevelExecuteResponse"]
+__all__ = ["CodeExecuteResponse"]
-class TopLevelExecuteResponse(BaseModel):
+class CodeExecuteResponse(BaseModel):
exit_code: Optional[str] = FieldInfo(alias="exitCode", default=None)
stderr: Optional[str] = None
diff --git a/tests/api_resources/test_top_level.py b/tests/api_resources/test_code.py
similarity index 61%
rename from tests/api_resources/test_top_level.py
rename to tests/api_resources/test_code.py
index c2e2ed5..9d4ecba 100644
--- a/tests/api_resources/test_top_level.py
+++ b/tests/api_resources/test_code.py
@@ -9,86 +9,86 @@
from rizaio import Riza, AsyncRiza
from tests.utils import assert_matches_type
-from rizaio.types import TopLevelExecuteResponse
+from rizaio.types import CodeExecuteResponse
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
-class TestTopLevel:
+class TestCode:
parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
@parametrize
def test_method_execute(self, client: Riza) -> None:
- top_level = client.top_level.execute()
- assert_matches_type(TopLevelExecuteResponse, top_level, path=["response"])
+ code = client.code.execute()
+ assert_matches_type(CodeExecuteResponse, code, path=["response"])
@parametrize
def test_method_execute_with_all_params(self, client: Riza) -> None:
- top_level = client.top_level.execute(
+ code = client.code.execute(
args=["string", "string", "string"],
code="string",
env={"foo": "string"},
language="UNSPECIFIED",
stdin="string",
)
- assert_matches_type(TopLevelExecuteResponse, top_level, path=["response"])
+ assert_matches_type(CodeExecuteResponse, code, path=["response"])
@parametrize
def test_raw_response_execute(self, client: Riza) -> None:
- response = client.top_level.with_raw_response.execute()
+ response = client.code.with_raw_response.execute()
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
- top_level = response.parse()
- assert_matches_type(TopLevelExecuteResponse, top_level, path=["response"])
+ code = response.parse()
+ assert_matches_type(CodeExecuteResponse, code, path=["response"])
@parametrize
def test_streaming_response_execute(self, client: Riza) -> None:
- with client.top_level.with_streaming_response.execute() as response:
+ with client.code.with_streaming_response.execute() as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
- top_level = response.parse()
- assert_matches_type(TopLevelExecuteResponse, top_level, path=["response"])
+ code = response.parse()
+ assert_matches_type(CodeExecuteResponse, code, path=["response"])
assert cast(Any, response.is_closed) is True
-class TestAsyncTopLevel:
+class TestAsyncCode:
parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
@parametrize
async def test_method_execute(self, async_client: AsyncRiza) -> None:
- top_level = await async_client.top_level.execute()
- assert_matches_type(TopLevelExecuteResponse, top_level, path=["response"])
+ code = await async_client.code.execute()
+ assert_matches_type(CodeExecuteResponse, code, path=["response"])
@parametrize
async def test_method_execute_with_all_params(self, async_client: AsyncRiza) -> None:
- top_level = await async_client.top_level.execute(
+ code = await async_client.code.execute(
args=["string", "string", "string"],
code="string",
env={"foo": "string"},
language="UNSPECIFIED",
stdin="string",
)
- assert_matches_type(TopLevelExecuteResponse, top_level, path=["response"])
+ assert_matches_type(CodeExecuteResponse, code, path=["response"])
@parametrize
async def test_raw_response_execute(self, async_client: AsyncRiza) -> None:
- response = await async_client.top_level.with_raw_response.execute()
+ response = await async_client.code.with_raw_response.execute()
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
- top_level = await response.parse()
- assert_matches_type(TopLevelExecuteResponse, top_level, path=["response"])
+ code = await response.parse()
+ assert_matches_type(CodeExecuteResponse, code, path=["response"])
@parametrize
async def test_streaming_response_execute(self, async_client: AsyncRiza) -> None:
- async with async_client.top_level.with_streaming_response.execute() as response:
+ async with async_client.code.with_streaming_response.execute() as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
- top_level = await response.parse()
- assert_matches_type(TopLevelExecuteResponse, top_level, path=["response"])
+ code = await response.parse()
+ assert_matches_type(CodeExecuteResponse, code, path=["response"])
assert cast(Any, response.is_closed) is True