Skip to content

Commit

Permalink
feat(api): OpenAPI spec update via Stainless API (#1096)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored Jun 20, 2024
1 parent 24963c4 commit ea4bf22
Show file tree
Hide file tree
Showing 11 changed files with 991 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 1353
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e79cc9a74089de5aec2c720b1e3023ea27869883f43c8b0167198f5967128636.yml
configured_endpoints: 1356
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-62c3b16f6d836d9cc7bca2f54e83f7ed99fbe325b4b6cfec72a71fc7ceee58a6.yml
27 changes: 26 additions & 1 deletion api.md
Original file line number Diff line number Diff line change
Expand Up @@ -7886,12 +7886,37 @@ Methods:
Types:

```python
from cloudflare.types.ai_gateway import LogListResponse
from cloudflare.types.ai_gateway import LogListResponse, LogGetResponse
```

Methods:

- <code title="get /accounts/{account_id}/ai-gateway/gateways/{id}/logs">client.ai_gateway.logs.<a href="./src/cloudflare/resources/ai_gateway/logs/logs.py">list</a>(id, \*, account_id, \*\*<a href="src/cloudflare/types/ai_gateway/log_list_params.py">params</a>) -> <a href="./src/cloudflare/types/ai_gateway/log_list_response.py">SyncV4PagePaginationArray[LogListResponse]</a></code>
- <code title="get /accounts/{account_id}/ai-gateway/gateways/{id}/logs/{logId}">client.ai_gateway.logs.<a href="./src/cloudflare/resources/ai_gateway/logs/logs.py">get</a>(log_id, \*, account_id, id) -> <a href="./src/cloudflare/types/ai_gateway/log_get_response.py">LogGetResponse</a></code>

### Request

Types:

```python
from cloudflare.types.ai_gateway.logs import RequestGetResponse
```

Methods:

- <code title="get /accounts/{account_id}/ai-gateway/gateways/{id}/logs/{logId}/request">client.ai_gateway.logs.request.<a href="./src/cloudflare/resources/ai_gateway/logs/request.py">get</a>(log_id, \*, account_id, id) -> <a href="./src/cloudflare/types/ai_gateway/logs/request_get_response.py">object</a></code>

### Response

Types:

```python
from cloudflare.types.ai_gateway.logs import ResponseGetResponse
```

Methods:

- <code title="get /accounts/{account_id}/ai-gateway/gateways/{id}/logs/{logId}/response">client.ai_gateway.logs.response.<a href="./src/cloudflare/resources/ai_gateway/logs/response.py">get</a>(log_id, \*, account_id, id) -> <a href="./src/cloudflare/types/ai_gateway/logs/response_get_response.py">object</a></code>

# IAM

Expand Down
28 changes: 28 additions & 0 deletions src/cloudflare/resources/ai_gateway/logs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,36 @@
LogsResourceWithStreamingResponse,
AsyncLogsResourceWithStreamingResponse,
)
from .request import (
RequestResource,
AsyncRequestResource,
RequestResourceWithRawResponse,
AsyncRequestResourceWithRawResponse,
RequestResourceWithStreamingResponse,
AsyncRequestResourceWithStreamingResponse,
)
from .response import (
ResponseResource,
AsyncResponseResource,
ResponseResourceWithRawResponse,
AsyncResponseResourceWithRawResponse,
ResponseResourceWithStreamingResponse,
AsyncResponseResourceWithStreamingResponse,
)

__all__ = [
"RequestResource",
"AsyncRequestResource",
"RequestResourceWithRawResponse",
"AsyncRequestResourceWithRawResponse",
"RequestResourceWithStreamingResponse",
"AsyncRequestResourceWithStreamingResponse",
"ResponseResource",
"AsyncResponseResource",
"ResponseResourceWithRawResponse",
"AsyncResponseResourceWithRawResponse",
"ResponseResourceWithStreamingResponse",
"AsyncResponseResourceWithStreamingResponse",
"LogsResource",
"AsyncLogsResource",
"LogsResourceWithRawResponse",
Expand Down
170 changes: 169 additions & 1 deletion src/cloudflare/resources/ai_gateway/logs/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,28 @@

from __future__ import annotations

from typing import Union
from typing import Type, Union, cast
from datetime import datetime
from typing_extensions import Literal

import httpx

from .request import (
RequestResource,
AsyncRequestResource,
RequestResourceWithRawResponse,
AsyncRequestResourceWithRawResponse,
RequestResourceWithStreamingResponse,
AsyncRequestResourceWithStreamingResponse,
)
from .response import (
ResponseResource,
AsyncResponseResource,
ResponseResourceWithRawResponse,
AsyncResponseResourceWithRawResponse,
ResponseResourceWithStreamingResponse,
AsyncResponseResourceWithStreamingResponse,
)
from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from ...._utils import maybe_transform
from ...._compat import cached_property
Expand All @@ -18,18 +34,28 @@
async_to_raw_response_wrapper,
async_to_streamed_response_wrapper,
)
from ...._wrappers import ResultWrapper
from ....pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray
from ...._base_client import (
AsyncPaginator,
make_request_options,
)
from ....types.ai_gateway import log_list_params
from ....types.ai_gateway.log_get_response import LogGetResponse
from ....types.ai_gateway.log_list_response import LogListResponse

__all__ = ["LogsResource", "AsyncLogsResource"]


class LogsResource(SyncAPIResource):
@cached_property
def request(self) -> RequestResource:
return RequestResource(self._client)

@cached_property
def response(self) -> ResponseResource:
return ResponseResource(self._client)

@cached_property
def with_raw_response(self) -> LogsResourceWithRawResponse:
return LogsResourceWithRawResponse(self)
Expand Down Expand Up @@ -103,8 +129,61 @@ def list(
model=LogListResponse,
)

def get(
self,
log_id: str,
*,
account_id: str,
id: 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,
) -> LogGetResponse:
"""
Get Gateway Log Detail
Args:
id: gateway id
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
"""
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
if not id:
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
if not log_id:
raise ValueError(f"Expected a non-empty value for `log_id` but received {log_id!r}")
return self._get(
f"/accounts/{account_id}/ai-gateway/gateways/{id}/logs/{log_id}",
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[LogGetResponse]._unwrapper,
),
cast_to=cast(Type[LogGetResponse], ResultWrapper[LogGetResponse]),
)


class AsyncLogsResource(AsyncAPIResource):
@cached_property
def request(self) -> AsyncRequestResource:
return AsyncRequestResource(self._client)

@cached_property
def response(self) -> AsyncResponseResource:
return AsyncResponseResource(self._client)

@cached_property
def with_raw_response(self) -> AsyncLogsResourceWithRawResponse:
return AsyncLogsResourceWithRawResponse(self)
Expand Down Expand Up @@ -178,6 +257,51 @@ def list(
model=LogListResponse,
)

async def get(
self,
log_id: str,
*,
account_id: str,
id: 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,
) -> LogGetResponse:
"""
Get Gateway Log Detail
Args:
id: gateway id
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
"""
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
if not id:
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
if not log_id:
raise ValueError(f"Expected a non-empty value for `log_id` but received {log_id!r}")
return await self._get(
f"/accounts/{account_id}/ai-gateway/gateways/{id}/logs/{log_id}",
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper[LogGetResponse]._unwrapper,
),
cast_to=cast(Type[LogGetResponse], ResultWrapper[LogGetResponse]),
)


class LogsResourceWithRawResponse:
def __init__(self, logs: LogsResource) -> None:
Expand All @@ -186,6 +310,17 @@ def __init__(self, logs: LogsResource) -> None:
self.list = to_raw_response_wrapper(
logs.list,
)
self.get = to_raw_response_wrapper(
logs.get,
)

@cached_property
def request(self) -> RequestResourceWithRawResponse:
return RequestResourceWithRawResponse(self._logs.request)

@cached_property
def response(self) -> ResponseResourceWithRawResponse:
return ResponseResourceWithRawResponse(self._logs.response)


class AsyncLogsResourceWithRawResponse:
Expand All @@ -195,6 +330,17 @@ def __init__(self, logs: AsyncLogsResource) -> None:
self.list = async_to_raw_response_wrapper(
logs.list,
)
self.get = async_to_raw_response_wrapper(
logs.get,
)

@cached_property
def request(self) -> AsyncRequestResourceWithRawResponse:
return AsyncRequestResourceWithRawResponse(self._logs.request)

@cached_property
def response(self) -> AsyncResponseResourceWithRawResponse:
return AsyncResponseResourceWithRawResponse(self._logs.response)


class LogsResourceWithStreamingResponse:
Expand All @@ -204,6 +350,17 @@ def __init__(self, logs: LogsResource) -> None:
self.list = to_streamed_response_wrapper(
logs.list,
)
self.get = to_streamed_response_wrapper(
logs.get,
)

@cached_property
def request(self) -> RequestResourceWithStreamingResponse:
return RequestResourceWithStreamingResponse(self._logs.request)

@cached_property
def response(self) -> ResponseResourceWithStreamingResponse:
return ResponseResourceWithStreamingResponse(self._logs.response)


class AsyncLogsResourceWithStreamingResponse:
Expand All @@ -213,3 +370,14 @@ def __init__(self, logs: AsyncLogsResource) -> None:
self.list = async_to_streamed_response_wrapper(
logs.list,
)
self.get = async_to_streamed_response_wrapper(
logs.get,
)

@cached_property
def request(self) -> AsyncRequestResourceWithStreamingResponse:
return AsyncRequestResourceWithStreamingResponse(self._logs.request)

@cached_property
def response(self) -> AsyncResponseResourceWithStreamingResponse:
return AsyncResponseResourceWithStreamingResponse(self._logs.response)
Loading

0 comments on commit ea4bf22

Please sign in to comment.