Skip to content

Commit

Permalink
feat(api): update via SDK Studio (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Apr 18, 2024
1 parent 9608f97 commit b1a00ad
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 98 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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())
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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():
Expand Down
6 changes: 3 additions & 3 deletions api.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# TopLevel
# Code

Types:

```python
from rizaio.types import TopLevelExecuteResponse
from rizaio.types import CodeExecuteResponse
```

Methods:

- <code title="post /v1/execute">client.top_level.<a href="./src/rizaio/resources/top_level.py">execute</a>(\*\*<a href="src/rizaio/types/top_level_execute_params.py">params</a>) -> <a href="./src/rizaio/types/top_level_execute_response.py">TopLevelExecuteResponse</a></code>
- <code title="post /v1/execute">client.code.<a href="./src/rizaio/resources/code.py">execute</a>(\*\*<a href="src/rizaio/types/code_execute_params.py">params</a>) -> <a href="./src/rizaio/types/code_execute_response.py">CodeExecuteResponse</a></code>
16 changes: 8 additions & 8 deletions src/rizaio/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@


class Riza(SyncAPIClient):
top_level: resources.TopLevel
code: resources.Code
with_raw_response: RizaWithRawResponse
with_streaming_response: RizaWithStreamedResponse

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down
26 changes: 13 additions & 13 deletions src/rizaio/resources/__init__.py
Original file line number Diff line number Diff line change
@@ -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",
]
68 changes: 34 additions & 34 deletions src/rizaio/resources/top_level.py → src/rizaio/resources/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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
Expand All @@ -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,
Expand All @@ -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
Expand All @@ -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,
)
4 changes: 2 additions & 2 deletions src/rizaio/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit b1a00ad

Please sign in to comment.