Skip to content

Commit

Permalink
feat(api): OpenAPI spec update via Stainless API (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Jul 31, 2024
1 parent f3e9cb4 commit f626a2c
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 79 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: 38
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/plastic-labs%2Fhoncho-7967581df14089cda98ce7bd258102d5da5ec541dc5b17aa918f96be11a2bde8.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/plastic-labs%2FHoncho-9de9efee1447340a4b99258885f8c5472ee853fa3bc7327fd632be3c5f23f161.yml
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Honcho API library
# honcho-ai API library

[![PyPI version](https://img.shields.io/pypi/v/honcho-ai.svg)](https://pypi.org/project/honcho-ai/)

The Honcho library provides convenient access to the Honcho REST API from any Python 3.7+
The honcho-ai library provides convenient access to the Honcho REST API from any Python 3.7+
application. The library includes type definitions for all request params and response fields,
and offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx).

Expand Down
8 changes: 4 additions & 4 deletions src/honcho/resources/apps/users/collections/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ def update(
*,
app_id: str,
user_id: str,
name: str,
metadata: Optional[Dict[str, object]] | NotGiven = NOT_GIVEN,
name: Optional[str] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down Expand Up @@ -136,8 +136,8 @@ def update(
f"/apps/{app_id}/users/{user_id}/collections/{collection_id}",
body=maybe_transform(
{
"name": name,
"metadata": metadata,
"name": name,
},
collection_update_params.CollectionUpdateParams,
),
Expand Down Expand Up @@ -445,8 +445,8 @@ async def update(
*,
app_id: str,
user_id: str,
name: str,
metadata: Optional[Dict[str, object]] | NotGiven = NOT_GIVEN,
name: Optional[str] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down Expand Up @@ -476,8 +476,8 @@ async def update(
f"/apps/{app_id}/users/{user_id}/collections/{collection_id}",
body=await async_maybe_transform(
{
"name": name,
"metadata": metadata,
"name": name,
},
collection_update_params.CollectionUpdateParams,
),
Expand Down
20 changes: 10 additions & 10 deletions src/honcho/resources/apps/users/sessions/metamessages.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ def create(
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Metamessage:
"""
Adds a message to a session
Adds a metamessage to a session
Args: app_id (uuid.UUID): The ID of the app representing the client application
using honcho user_id (str): The User ID representing the user, managed by the
user session_id (int): The ID of the Session to add the message to message
(schemas.MessageCreate): The Message object to add containing the message
content and type
user session_id (int): The ID of the Session to add the metamessage to
metamessage (schemas.MetamessageCreate): The Metamessage object to add
containing the metamessage content and type
Returns: schemas.Message: The Message object of the added message
Returns: schemas.Metamessage: The Metamessage object of the added metamessage
Raises: HTTPException: If the session is not found
Expand Down Expand Up @@ -312,15 +312,15 @@ async def create(
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Metamessage:
"""
Adds a message to a session
Adds a metamessage to a session
Args: app_id (uuid.UUID): The ID of the app representing the client application
using honcho user_id (str): The User ID representing the user, managed by the
user session_id (int): The ID of the Session to add the message to message
(schemas.MessageCreate): The Message object to add containing the message
content and type
user session_id (int): The ID of the Session to add the metamessage to
metamessage (schemas.MetamessageCreate): The Metamessage object to add
containing the metamessage content and type
Returns: schemas.Message: The Message object of the added message
Returns: schemas.Metamessage: The Metamessage object of the added metamessage
Raises: HTTPException: If the session is not found
Expand Down
32 changes: 6 additions & 26 deletions src/honcho/resources/apps/users/sessions/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ def create(
user_id: str,
*,
app_id: str,
location_id: str,
metadata: Optional[Dict[str, object]] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
Expand All @@ -87,7 +86,7 @@ def create(
Args: app_id (uuid.UUID): The ID of the app representing the client application
using honcho user_id (uuid.UUID): The User ID representing the user, managed by
the user session (schemas.SessionCreate): The Session object containing any
metadata and a location ID
metadata
Returns: schemas.Session: The Session object of the new Session
Expand All @@ -106,13 +105,7 @@ def create(
raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}")
return self._post(
f"/apps/{app_id}/users/{user_id}/sessions",
body=maybe_transform(
{
"location_id": location_id,
"metadata": metadata,
},
session_create_params.SessionCreateParams,
),
body=maybe_transform({"metadata": metadata}, session_create_params.SessionCreateParams),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
Expand Down Expand Up @@ -174,7 +167,6 @@ def list(
app_id: str,
filter: Optional[str] | NotGiven = NOT_GIVEN,
is_active: Optional[bool] | NotGiven = NOT_GIVEN,
location_id: Optional[str] | NotGiven = NOT_GIVEN,
page: int | NotGiven = NOT_GIVEN,
reverse: Optional[bool] | NotGiven = NOT_GIVEN,
size: int | NotGiven = NOT_GIVEN,
Expand All @@ -190,8 +182,7 @@ def list(
Args: app_id (uuid.UUID): The ID of the app representing the client application
using honcho user_id (uuid.UUID): The User ID representing the user, managed by
the user location_id (str, optional): Optional Location ID representing the
location of a session
the user
Returns: list[schemas.Session]: List of Session objects
Expand Down Expand Up @@ -224,7 +215,6 @@ def list(
{
"filter": filter,
"is_active": is_active,
"location_id": location_id,
"page": page,
"reverse": reverse,
"size": size,
Expand Down Expand Up @@ -440,7 +430,6 @@ async def create(
user_id: str,
*,
app_id: str,
location_id: str,
metadata: Optional[Dict[str, object]] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
Expand All @@ -455,7 +444,7 @@ async def create(
Args: app_id (uuid.UUID): The ID of the app representing the client application
using honcho user_id (uuid.UUID): The User ID representing the user, managed by
the user session (schemas.SessionCreate): The Session object containing any
metadata and a location ID
metadata
Returns: schemas.Session: The Session object of the new Session
Expand All @@ -474,13 +463,7 @@ async def create(
raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}")
return await self._post(
f"/apps/{app_id}/users/{user_id}/sessions",
body=await async_maybe_transform(
{
"location_id": location_id,
"metadata": metadata,
},
session_create_params.SessionCreateParams,
),
body=await async_maybe_transform({"metadata": metadata}, session_create_params.SessionCreateParams),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
Expand Down Expand Up @@ -542,7 +525,6 @@ def list(
app_id: str,
filter: Optional[str] | NotGiven = NOT_GIVEN,
is_active: Optional[bool] | NotGiven = NOT_GIVEN,
location_id: Optional[str] | NotGiven = NOT_GIVEN,
page: int | NotGiven = NOT_GIVEN,
reverse: Optional[bool] | NotGiven = NOT_GIVEN,
size: int | NotGiven = NOT_GIVEN,
Expand All @@ -558,8 +540,7 @@ def list(
Args: app_id (uuid.UUID): The ID of the app representing the client application
using honcho user_id (uuid.UUID): The User ID representing the user, managed by
the user location_id (str, optional): Optional Location ID representing the
location of a session
the user
Returns: list[schemas.Session]: List of Session objects
Expand Down Expand Up @@ -592,7 +573,6 @@ def list(
{
"filter": filter,
"is_active": is_active,
"location_id": location_id,
"page": page,
"reverse": reverse,
"size": size,
Expand Down
4 changes: 2 additions & 2 deletions src/honcho/types/apps/users/collection_update_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ class CollectionUpdateParams(TypedDict, total=False):

user_id: Required[str]

name: Required[str]

metadata: Optional[Dict[str, object]]

name: Optional[str]
2 changes: 0 additions & 2 deletions src/honcho/types/apps/users/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ class Session(BaseModel):

is_active: bool

location_id: str

metadata: Dict[str, object]

user_id: str
2 changes: 0 additions & 2 deletions src/honcho/types/apps/users/session_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,4 @@
class SessionCreateParams(TypedDict, total=False):
app_id: Required[str]

location_id: Required[str]

metadata: Optional[Dict[str, object]]
2 changes: 0 additions & 2 deletions src/honcho/types/apps/users/session_list_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ class SessionListParams(TypedDict, total=False):

is_active: Optional[bool]

location_id: Optional[str]

page: int
"""Page number"""

Expand Down
16 changes: 2 additions & 14 deletions tests/api_resources/apps/users/test_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ def test_method_update(self, client: Honcho) -> None:
collection_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
app_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
user_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
name="name",
)
assert_matches_type(Collection, collection, path=["response"])

Expand All @@ -100,8 +99,8 @@ def test_method_update_with_all_params(self, client: Honcho) -> None:
collection_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
app_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
user_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
name="name",
metadata={"foo": "bar"},
name="name",
)
assert_matches_type(Collection, collection, path=["response"])

Expand All @@ -111,7 +110,6 @@ def test_raw_response_update(self, client: Honcho) -> None:
collection_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
app_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
user_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
name="name",
)

assert response.is_closed is True
Expand All @@ -125,7 +123,6 @@ def test_streaming_response_update(self, client: Honcho) -> None:
collection_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
app_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
user_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
name="name",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
Expand All @@ -142,23 +139,20 @@ def test_path_params_update(self, client: Honcho) -> None:
collection_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
app_id="",
user_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
name="name",
)

with pytest.raises(ValueError, match=r"Expected a non-empty value for `user_id` but received ''"):
client.apps.users.collections.with_raw_response.update(
collection_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
app_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
user_id="",
name="name",
)

with pytest.raises(ValueError, match=r"Expected a non-empty value for `collection_id` but received ''"):
client.apps.users.collections.with_raw_response.update(
collection_id="",
app_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
user_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
name="name",
)

@parametrize
Expand Down Expand Up @@ -552,7 +546,6 @@ async def test_method_update(self, async_client: AsyncHoncho) -> None:
collection_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
app_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
user_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
name="name",
)
assert_matches_type(Collection, collection, path=["response"])

Expand All @@ -562,8 +555,8 @@ async def test_method_update_with_all_params(self, async_client: AsyncHoncho) ->
collection_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
app_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
user_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
name="name",
metadata={"foo": "bar"},
name="name",
)
assert_matches_type(Collection, collection, path=["response"])

Expand All @@ -573,7 +566,6 @@ async def test_raw_response_update(self, async_client: AsyncHoncho) -> None:
collection_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
app_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
user_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
name="name",
)

assert response.is_closed is True
Expand All @@ -587,7 +579,6 @@ async def test_streaming_response_update(self, async_client: AsyncHoncho) -> Non
collection_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
app_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
user_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
name="name",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
Expand All @@ -604,23 +595,20 @@ async def test_path_params_update(self, async_client: AsyncHoncho) -> None:
collection_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
app_id="",
user_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
name="name",
)

with pytest.raises(ValueError, match=r"Expected a non-empty value for `user_id` but received ''"):
await async_client.apps.users.collections.with_raw_response.update(
collection_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
app_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
user_id="",
name="name",
)

with pytest.raises(ValueError, match=r"Expected a non-empty value for `collection_id` but received ''"):
await async_client.apps.users.collections.with_raw_response.update(
collection_id="",
app_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
user_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
name="name",
)

@parametrize
Expand Down
Loading

0 comments on commit f626a2c

Please sign in to comment.