Skip to content

Commit

Permalink
feat(api): manual updates (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored Nov 6, 2024
1 parent 0628cb6 commit cf35677
Show file tree
Hide file tree
Showing 6 changed files with 181 additions and 2 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
configured_endpoints: 8
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/riza%2Friza-api-6a6ef20cc3e9d270a1ddd031d63f754cfec74c877c184161a7996249a5cffae6.yml
1 change: 1 addition & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ from rizaio.types import Secret, SecretListResponse

Methods:

- <code title="post /v1/secrets">client.secrets.<a href="./src/rizaio/resources/secrets.py">create</a>(\*\*<a href="src/rizaio/types/secret_create_params.py">params</a>) -> <a href="./src/rizaio/types/secret.py">Secret</a></code>
- <code title="get /v1/secrets">client.secrets.<a href="./src/rizaio/resources/secrets.py">list</a>() -> <a href="./src/rizaio/types/secret_list_response.py">SecretListResponse</a></code>

# Tools
Expand Down
96 changes: 96 additions & 0 deletions src/rizaio/resources/secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@

import httpx

from ..types import secret_create_params
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from .._utils import (
maybe_transform,
async_maybe_transform,
)
from .._compat import cached_property
from .._resource import SyncAPIResource, AsyncAPIResource
from .._response import (
Expand All @@ -14,6 +19,7 @@
async_to_streamed_response_wrapper,
)
from .._base_client import make_request_options
from ..types.secret import Secret
from ..types.secret_list_response import SecretListResponse

__all__ = ["SecretsResource", "AsyncSecretsResource"]
Expand All @@ -39,6 +45,45 @@ def with_streaming_response(self) -> SecretsResourceWithStreamingResponse:
"""
return SecretsResourceWithStreamingResponse(self)

def create(
self,
*,
name: str,
value: str,
# 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,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Secret:
"""
Create a secret in your project.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
return self._post(
"/v1/secrets",
body=maybe_transform(
{
"name": name,
"value": value,
},
secret_create_params.SecretCreateParams,
),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=Secret,
)

def list(
self,
*,
Expand Down Expand Up @@ -79,6 +124,45 @@ def with_streaming_response(self) -> AsyncSecretsResourceWithStreamingResponse:
"""
return AsyncSecretsResourceWithStreamingResponse(self)

async def create(
self,
*,
name: str,
value: str,
# 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,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Secret:
"""
Create a secret in your project.
Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
return await self._post(
"/v1/secrets",
body=await async_maybe_transform(
{
"name": name,
"value": value,
},
secret_create_params.SecretCreateParams,
),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=Secret,
)

async def list(
self,
*,
Expand All @@ -103,6 +187,9 @@ class SecretsResourceWithRawResponse:
def __init__(self, secrets: SecretsResource) -> None:
self._secrets = secrets

self.create = to_raw_response_wrapper(
secrets.create,
)
self.list = to_raw_response_wrapper(
secrets.list,
)
Expand All @@ -112,6 +199,9 @@ class AsyncSecretsResourceWithRawResponse:
def __init__(self, secrets: AsyncSecretsResource) -> None:
self._secrets = secrets

self.create = async_to_raw_response_wrapper(
secrets.create,
)
self.list = async_to_raw_response_wrapper(
secrets.list,
)
Expand All @@ -121,6 +211,9 @@ class SecretsResourceWithStreamingResponse:
def __init__(self, secrets: SecretsResource) -> None:
self._secrets = secrets

self.create = to_streamed_response_wrapper(
secrets.create,
)
self.list = to_streamed_response_wrapper(
secrets.list,
)
Expand All @@ -130,6 +223,9 @@ class AsyncSecretsResourceWithStreamingResponse:
def __init__(self, secrets: AsyncSecretsResource) -> None:
self._secrets = secrets

self.create = async_to_streamed_response_wrapper(
secrets.create,
)
self.list = async_to_streamed_response_wrapper(
secrets.list,
)
1 change: 1 addition & 0 deletions src/rizaio/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
from .tool_list_response import ToolListResponse as ToolListResponse
from .tool_update_params import ToolUpdateParams as ToolUpdateParams
from .command_exec_params import CommandExecParams as CommandExecParams
from .secret_create_params import SecretCreateParams as SecretCreateParams
from .secret_list_response import SecretListResponse as SecretListResponse
from .command_exec_response import CommandExecResponse as CommandExecResponse
13 changes: 13 additions & 0 deletions src/rizaio/types/secret_create_params.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

from typing_extensions import Required, TypedDict

__all__ = ["SecretCreateParams"]


class SecretCreateParams(TypedDict, total=False):
name: Required[str]

value: Required[str]
70 changes: 69 additions & 1 deletion tests/api_resources/test_secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,48 @@

from rizaio import Riza, AsyncRiza
from tests.utils import assert_matches_type
from rizaio.types import SecretListResponse
from rizaio.types import Secret, SecretListResponse

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


class TestSecrets:
parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])

@parametrize
def test_method_create(self, client: Riza) -> None:
secret = client.secrets.create(
name="name",
value="value",
)
assert_matches_type(Secret, secret, path=["response"])

@parametrize
def test_raw_response_create(self, client: Riza) -> None:
response = client.secrets.with_raw_response.create(
name="name",
value="value",
)

assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
secret = response.parse()
assert_matches_type(Secret, secret, path=["response"])

@parametrize
def test_streaming_response_create(self, client: Riza) -> None:
with client.secrets.with_streaming_response.create(
name="name",
value="value",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"

secret = response.parse()
assert_matches_type(Secret, secret, path=["response"])

assert cast(Any, response.is_closed) is True

@parametrize
def test_method_list(self, client: Riza) -> None:
secret = client.secrets.list()
Expand Down Expand Up @@ -46,6 +80,40 @@ def test_streaming_response_list(self, client: Riza) -> None:
class TestAsyncSecrets:
parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])

@parametrize
async def test_method_create(self, async_client: AsyncRiza) -> None:
secret = await async_client.secrets.create(
name="name",
value="value",
)
assert_matches_type(Secret, secret, path=["response"])

@parametrize
async def test_raw_response_create(self, async_client: AsyncRiza) -> None:
response = await async_client.secrets.with_raw_response.create(
name="name",
value="value",
)

assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
secret = await response.parse()
assert_matches_type(Secret, secret, path=["response"])

@parametrize
async def test_streaming_response_create(self, async_client: AsyncRiza) -> None:
async with async_client.secrets.with_streaming_response.create(
name="name",
value="value",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"

secret = await response.parse()
assert_matches_type(Secret, secret, path=["response"])

assert cast(Any, response.is_closed) is True

@parametrize
async def test_method_list(self, async_client: AsyncRiza) -> None:
secret = await async_client.secrets.list()
Expand Down

0 comments on commit cf35677

Please sign in to comment.