Skip to content

Commit

Permalink
feat(api): api update (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Oct 30, 2024
1 parent 8306dff commit 653755c
Show file tree
Hide file tree
Showing 11 changed files with 115 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 7
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/riza%2Friza-api-40b6a6c688a323536bbba3765b3a6c807ca907253d244f85421fd0a2f3b2409a.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/riza%2Friza-api-333818f2f208fafdae7916ef9d8ad6cf8d717df705e8c7f941b4df9965227345.yml
21 changes: 9 additions & 12 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ anyio==4.4.0
# via rizaio
argcomplete==3.1.2
# via nox
attrs==23.1.0
# via pytest
certifi==2023.7.22
# via httpcore
# via httpx
Expand All @@ -28,8 +26,9 @@ distlib==0.3.7
# via virtualenv
distro==1.8.0
# via rizaio
exceptiongroup==1.1.3
exceptiongroup==1.2.2
# via anyio
# via pytest
filelock==3.12.4
# via virtualenv
h11==0.14.0
Expand Down Expand Up @@ -60,20 +59,18 @@ packaging==23.2
# via pytest
platformdirs==3.11.0
# via virtualenv
pluggy==1.3.0
# via pytest
py==1.11.0
pluggy==1.5.0
# via pytest
pydantic==2.7.1
pydantic==2.9.2
# via rizaio
pydantic-core==2.18.2
pydantic-core==2.23.4
# via pydantic
pygments==2.18.0
# via rich
pyright==1.1.380
pytest==7.1.1
pytest==8.3.3
# via pytest-asyncio
pytest-asyncio==0.21.1
pytest-asyncio==0.24.0
python-dateutil==2.8.2
# via time-machine
pytz==2023.3.post1
Expand All @@ -90,10 +87,10 @@ sniffio==1.3.0
# via httpx
# via rizaio
time-machine==2.9.0
tomli==2.0.1
tomli==2.0.2
# via mypy
# via pytest
typing-extensions==4.8.0
typing-extensions==4.12.2
# via anyio
# via mypy
# via pydantic
Expand Down
8 changes: 4 additions & 4 deletions requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ certifi==2023.7.22
# via httpx
distro==1.8.0
# via rizaio
exceptiongroup==1.1.3
exceptiongroup==1.2.2
# via anyio
h11==0.14.0
# via httpcore
Expand All @@ -30,15 +30,15 @@ httpx==0.25.2
idna==3.4
# via anyio
# via httpx
pydantic==2.7.1
pydantic==2.9.2
# via rizaio
pydantic-core==2.18.2
pydantic-core==2.23.4
# via pydantic
sniffio==1.3.0
# via anyio
# via httpx
# via rizaio
typing-extensions==4.8.0
typing-extensions==4.12.2
# via anyio
# via pydantic
# via pydantic-core
Expand Down
2 changes: 1 addition & 1 deletion src/rizaio/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def model_json(model: pydantic.BaseModel, *, indent: int | None = None) -> str:
def model_dump(
model: pydantic.BaseModel,
*,
exclude: IncEx = None,
exclude: IncEx | None = None,
exclude_unset: bool = False,
exclude_defaults: bool = False,
warnings: bool = True,
Expand Down
10 changes: 5 additions & 5 deletions src/rizaio/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def __str__(self) -> str:
# Based on https://github.com/samuelcolvin/pydantic/issues/1168#issuecomment-817742836.
@classmethod
@override
def construct(
def construct( # pyright: ignore[reportIncompatibleMethodOverride]
cls: Type[ModelT],
_fields_set: set[str] | None = None,
**values: object,
Expand Down Expand Up @@ -248,8 +248,8 @@ def model_dump(
self,
*,
mode: Literal["json", "python"] | str = "python",
include: IncEx = None,
exclude: IncEx = None,
include: IncEx | None = None,
exclude: IncEx | None = None,
by_alias: bool = False,
exclude_unset: bool = False,
exclude_defaults: bool = False,
Expand Down Expand Up @@ -303,8 +303,8 @@ def model_dump_json(
self,
*,
indent: int | None = None,
include: IncEx = None,
exclude: IncEx = None,
include: IncEx | None = None,
exclude: IncEx | None = None,
by_alias: bool = False,
exclude_unset: bool = False,
exclude_defaults: bool = False,
Expand Down
6 changes: 4 additions & 2 deletions src/rizaio/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
Optional,
Sequence,
)
from typing_extensions import Literal, Protocol, TypeAlias, TypedDict, override, runtime_checkable
from typing_extensions import Set, Literal, Protocol, TypeAlias, TypedDict, override, runtime_checkable

import httpx
import pydantic
Expand Down Expand Up @@ -193,7 +193,9 @@ def get(self, __key: str) -> str | None: ...

# Note: copied from Pydantic
# https://github.com/pydantic/pydantic/blob/32ea570bf96e84234d2992e1ddf40ab8a565925a/pydantic/main.py#L49
IncEx: TypeAlias = "set[int] | set[str] | dict[int, Any] | dict[str, Any] | None"
IncEx: TypeAlias = Union[
Set[int], Set[str], Mapping[int, Union["IncEx", Literal[True]]], Mapping[str, Union["IncEx", Literal[True]]]
]

PostParser = Callable[[Any], Any]

Expand Down
9 changes: 9 additions & 0 deletions src/rizaio/types/command_exec_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"HTTPAllowAuth",
"HTTPAllowAuthBasic",
"HTTPAllowAuthBearer",
"HTTPAllowAuthQuery",
"Limits",
]

Expand Down Expand Up @@ -70,12 +71,20 @@ class HTTPAllowAuthBearer(TypedDict, total=False):
"""The token to set, e.g. 'Authorization: Bearer <token>'."""


class HTTPAllowAuthQuery(TypedDict, total=False):
key: str

value: str


class HTTPAllowAuth(TypedDict, total=False):
basic: Optional[HTTPAllowAuthBasic]

bearer: Optional[HTTPAllowAuthBearer]
"""Configuration to add an 'Authorization' header using the 'Bearer' scheme."""

query: Optional[HTTPAllowAuthQuery]


class HTTPAllow(TypedDict, total=False):
auth: HTTPAllowAuth
Expand Down
21 changes: 20 additions & 1 deletion src/rizaio/types/tool_exec_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,16 @@
from typing import Iterable, Optional
from typing_extensions import Required, TypedDict

__all__ = ["ToolExecParams", "Env", "HTTP", "HTTPAllow", "HTTPAllowAuth", "HTTPAllowAuthBasic", "HTTPAllowAuthBearer"]
__all__ = [
"ToolExecParams",
"Env",
"HTTP",
"HTTPAllow",
"HTTPAllowAuth",
"HTTPAllowAuthBasic",
"HTTPAllowAuthBearer",
"HTTPAllowAuthQuery",
]


class ToolExecParams(TypedDict, total=False):
Expand Down Expand Up @@ -41,12 +50,22 @@ class HTTPAllowAuthBearer(TypedDict, total=False):
secret_id: str


class HTTPAllowAuthQuery(TypedDict, total=False):
key: str

secret_id: str

value: str


class HTTPAllowAuth(TypedDict, total=False):
basic: Optional[HTTPAllowAuthBasic]

bearer: Optional[HTTPAllowAuthBearer]
"""Configuration to add an 'Authorization' header using the 'Bearer' scheme."""

query: Optional[HTTPAllowAuthQuery]


class HTTPAllow(TypedDict, total=False):
auth: HTTPAllowAuth
Expand Down
24 changes: 24 additions & 0 deletions tests/api_resources/test_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ def test_method_exec_with_all_params(self, client: Riza) -> None:
"user_id": "user_id",
},
"bearer": {"token": "token"},
"query": {
"key": "key",
"value": "value",
},
},
"host": "host",
},
Expand All @@ -64,6 +68,10 @@ def test_method_exec_with_all_params(self, client: Riza) -> None:
"user_id": "user_id",
},
"bearer": {"token": "token"},
"query": {
"key": "key",
"value": "value",
},
},
"host": "host",
},
Expand All @@ -74,6 +82,10 @@ def test_method_exec_with_all_params(self, client: Riza) -> None:
"user_id": "user_id",
},
"bearer": {"token": "token"},
"query": {
"key": "key",
"value": "value",
},
},
"host": "host",
},
Expand Down Expand Up @@ -155,6 +167,10 @@ async def test_method_exec_with_all_params(self, async_client: AsyncRiza) -> Non
"user_id": "user_id",
},
"bearer": {"token": "token"},
"query": {
"key": "key",
"value": "value",
},
},
"host": "host",
},
Expand All @@ -165,6 +181,10 @@ async def test_method_exec_with_all_params(self, async_client: AsyncRiza) -> Non
"user_id": "user_id",
},
"bearer": {"token": "token"},
"query": {
"key": "key",
"value": "value",
},
},
"host": "host",
},
Expand All @@ -175,6 +195,10 @@ async def test_method_exec_with_all_params(self, async_client: AsyncRiza) -> Non
"user_id": "user_id",
},
"bearer": {"token": "token"},
"query": {
"key": "key",
"value": "value",
},
},
"host": "host",
},
Expand Down
30 changes: 30 additions & 0 deletions tests/api_resources/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@ def test_method_exec_with_all_params(self, client: Riza) -> None:
"token": "token",
"secret_id": "secret_id",
},
"query": {
"key": "key",
"secret_id": "secret_id",
"value": "value",
},
},
"host": "host",
},
Expand All @@ -196,6 +201,11 @@ def test_method_exec_with_all_params(self, client: Riza) -> None:
"token": "token",
"secret_id": "secret_id",
},
"query": {
"key": "key",
"secret_id": "secret_id",
"value": "value",
},
},
"host": "host",
},
Expand All @@ -210,6 +220,11 @@ def test_method_exec_with_all_params(self, client: Riza) -> None:
"token": "token",
"secret_id": "secret_id",
},
"query": {
"key": "key",
"secret_id": "secret_id",
"value": "value",
},
},
"host": "host",
},
Expand Down Expand Up @@ -454,6 +469,11 @@ async def test_method_exec_with_all_params(self, async_client: AsyncRiza) -> Non
"token": "token",
"secret_id": "secret_id",
},
"query": {
"key": "key",
"secret_id": "secret_id",
"value": "value",
},
},
"host": "host",
},
Expand All @@ -468,6 +488,11 @@ async def test_method_exec_with_all_params(self, async_client: AsyncRiza) -> Non
"token": "token",
"secret_id": "secret_id",
},
"query": {
"key": "key",
"secret_id": "secret_id",
"value": "value",
},
},
"host": "host",
},
Expand All @@ -482,6 +507,11 @@ async def test_method_exec_with_all_params(self, async_client: AsyncRiza) -> Non
"token": "token",
"secret_id": "secret_id",
},
"query": {
"key": "key",
"secret_id": "secret_id",
"value": "value",
},
},
"host": "host",
},
Expand Down
14 changes: 8 additions & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from __future__ import annotations

import os
import asyncio
import logging
from typing import TYPE_CHECKING, Iterator, AsyncIterator

import pytest
from pytest_asyncio import is_async_test

from rizaio import Riza, AsyncRiza

Expand All @@ -17,11 +17,13 @@
logging.getLogger("rizaio").setLevel(logging.DEBUG)


@pytest.fixture(scope="session")
def event_loop() -> Iterator[asyncio.AbstractEventLoop]:
loop = asyncio.new_event_loop()
yield loop
loop.close()
# automatically add `pytest.mark.asyncio()` to all of our async tests
# so we don't have to add that boilerplate everywhere
def pytest_collection_modifyitems(items: list[pytest.Function]) -> None:
pytest_asyncio_tests = (item for item in items if is_async_test(item))
session_scope_marker = pytest.mark.asyncio(loop_scope="session")
for async_test in pytest_asyncio_tests:
async_test.add_marker(session_scope_marker, append=False)


base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
Expand Down

0 comments on commit 653755c

Please sign in to comment.