From 97a4a6ecfb9a6dbf281956c39ee8c3f4add0b4b3 Mon Sep 17 00:00:00 2001
From: "stainless-app[bot]"
<142633134+stainless-app[bot]@users.noreply.github.com>
Date: Thu, 20 Jun 2024 09:02:10 +0000
Subject: [PATCH] feat(api): OpenAPI spec update via Stainless API (#1096)
---
.stats.yml | 4 +-
api.md | 27 ++-
.../resources/ai_gateway/logs/__init__.py | 28 +++
.../resources/ai_gateway/logs/logs.py | 170 +++++++++++++++++-
.../resources/ai_gateway/logs/request.py | 158 ++++++++++++++++
.../resources/ai_gateway/logs/response.py | 158 ++++++++++++++++
src/cloudflare/types/ai_gateway/__init__.py | 1 +
.../types/ai_gateway/log_get_response.py | 46 +++++
.../ai_gateway/logs/test_request.py | 141 +++++++++++++++
.../ai_gateway/logs/test_response.py | 141 +++++++++++++++
tests/api_resources/ai_gateway/test_logs.py | 122 ++++++++++++-
11 files changed, 991 insertions(+), 5 deletions(-)
create mode 100644 src/cloudflare/resources/ai_gateway/logs/request.py
create mode 100644 src/cloudflare/resources/ai_gateway/logs/response.py
create mode 100644 src/cloudflare/types/ai_gateway/log_get_response.py
create mode 100644 tests/api_resources/ai_gateway/logs/test_request.py
create mode 100644 tests/api_resources/ai_gateway/logs/test_response.py
diff --git a/.stats.yml b/.stats.yml
index 691540b5bcf..4933477825d 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -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
diff --git a/api.md b/api.md
index 8f8c1cbf597..fa00c410812 100644
--- a/api.md
+++ b/api.md
@@ -7886,12 +7886,37 @@ Methods:
Types:
```python
-from cloudflare.types.ai_gateway import LogListResponse
+from cloudflare.types.ai_gateway import LogListResponse, LogGetResponse
```
Methods:
- client.ai_gateway.logs.list(id, \*, account_id, \*\*params) -> SyncV4PagePaginationArray[LogListResponse]
+- client.ai_gateway.logs.get(log_id, \*, account_id, id) -> LogGetResponse
+
+### Request
+
+Types:
+
+```python
+from cloudflare.types.ai_gateway.logs import RequestGetResponse
+```
+
+Methods:
+
+- client.ai_gateway.logs.request.get(log_id, \*, account_id, id) -> object
+
+### Response
+
+Types:
+
+```python
+from cloudflare.types.ai_gateway.logs import ResponseGetResponse
+```
+
+Methods:
+
+- client.ai_gateway.logs.response.get(log_id, \*, account_id, id) -> object
# IAM
diff --git a/src/cloudflare/resources/ai_gateway/logs/__init__.py b/src/cloudflare/resources/ai_gateway/logs/__init__.py
index 30876fab694..cd50acd99fc 100644
--- a/src/cloudflare/resources/ai_gateway/logs/__init__.py
+++ b/src/cloudflare/resources/ai_gateway/logs/__init__.py
@@ -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",
diff --git a/src/cloudflare/resources/ai_gateway/logs/logs.py b/src/cloudflare/resources/ai_gateway/logs/logs.py
index d640bb36e6a..2176d77bef7 100644
--- a/src/cloudflare/resources/ai_gateway/logs/logs.py
+++ b/src/cloudflare/resources/ai_gateway/logs/logs.py
@@ -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
@@ -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)
@@ -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)
@@ -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:
@@ -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:
@@ -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:
@@ -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:
@@ -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)
diff --git a/src/cloudflare/resources/ai_gateway/logs/request.py b/src/cloudflare/resources/ai_gateway/logs/request.py
new file mode 100644
index 00000000000..05a85c72ef3
--- /dev/null
+++ b/src/cloudflare/resources/ai_gateway/logs/request.py
@@ -0,0 +1,158 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+import httpx
+
+from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
+from ...._compat import cached_property
+from ...._resource import SyncAPIResource, AsyncAPIResource
+from ...._response import (
+ to_raw_response_wrapper,
+ to_streamed_response_wrapper,
+ async_to_raw_response_wrapper,
+ async_to_streamed_response_wrapper,
+)
+from ...._base_client import (
+ make_request_options,
+)
+
+__all__ = ["RequestResource", "AsyncRequestResource"]
+
+
+class RequestResource(SyncAPIResource):
+ @cached_property
+ def with_raw_response(self) -> RequestResourceWithRawResponse:
+ return RequestResourceWithRawResponse(self)
+
+ @cached_property
+ def with_streaming_response(self) -> RequestResourceWithStreamingResponse:
+ return RequestResourceWithStreamingResponse(self)
+
+ 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,
+ ) -> object:
+ """
+ Get Gateway Log Request
+
+ 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}/request",
+ options=make_request_options(
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
+ ),
+ cast_to=object,
+ )
+
+
+class AsyncRequestResource(AsyncAPIResource):
+ @cached_property
+ def with_raw_response(self) -> AsyncRequestResourceWithRawResponse:
+ return AsyncRequestResourceWithRawResponse(self)
+
+ @cached_property
+ def with_streaming_response(self) -> AsyncRequestResourceWithStreamingResponse:
+ return AsyncRequestResourceWithStreamingResponse(self)
+
+ 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,
+ ) -> object:
+ """
+ Get Gateway Log Request
+
+ 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}/request",
+ options=make_request_options(
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
+ ),
+ cast_to=object,
+ )
+
+
+class RequestResourceWithRawResponse:
+ def __init__(self, request: RequestResource) -> None:
+ self._request = request
+
+ self.get = to_raw_response_wrapper(
+ request.get,
+ )
+
+
+class AsyncRequestResourceWithRawResponse:
+ def __init__(self, request: AsyncRequestResource) -> None:
+ self._request = request
+
+ self.get = async_to_raw_response_wrapper(
+ request.get,
+ )
+
+
+class RequestResourceWithStreamingResponse:
+ def __init__(self, request: RequestResource) -> None:
+ self._request = request
+
+ self.get = to_streamed_response_wrapper(
+ request.get,
+ )
+
+
+class AsyncRequestResourceWithStreamingResponse:
+ def __init__(self, request: AsyncRequestResource) -> None:
+ self._request = request
+
+ self.get = async_to_streamed_response_wrapper(
+ request.get,
+ )
diff --git a/src/cloudflare/resources/ai_gateway/logs/response.py b/src/cloudflare/resources/ai_gateway/logs/response.py
new file mode 100644
index 00000000000..e70ec94a87b
--- /dev/null
+++ b/src/cloudflare/resources/ai_gateway/logs/response.py
@@ -0,0 +1,158 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+import httpx
+
+from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
+from ...._compat import cached_property
+from ...._resource import SyncAPIResource, AsyncAPIResource
+from ...._response import (
+ to_raw_response_wrapper,
+ to_streamed_response_wrapper,
+ async_to_raw_response_wrapper,
+ async_to_streamed_response_wrapper,
+)
+from ...._base_client import (
+ make_request_options,
+)
+
+__all__ = ["ResponseResource", "AsyncResponseResource"]
+
+
+class ResponseResource(SyncAPIResource):
+ @cached_property
+ def with_raw_response(self) -> ResponseResourceWithRawResponse:
+ return ResponseResourceWithRawResponse(self)
+
+ @cached_property
+ def with_streaming_response(self) -> ResponseResourceWithStreamingResponse:
+ return ResponseResourceWithStreamingResponse(self)
+
+ 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,
+ ) -> object:
+ """
+ Get Gateway Log Response
+
+ 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}/response",
+ options=make_request_options(
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
+ ),
+ cast_to=object,
+ )
+
+
+class AsyncResponseResource(AsyncAPIResource):
+ @cached_property
+ def with_raw_response(self) -> AsyncResponseResourceWithRawResponse:
+ return AsyncResponseResourceWithRawResponse(self)
+
+ @cached_property
+ def with_streaming_response(self) -> AsyncResponseResourceWithStreamingResponse:
+ return AsyncResponseResourceWithStreamingResponse(self)
+
+ 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,
+ ) -> object:
+ """
+ Get Gateway Log Response
+
+ 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}/response",
+ options=make_request_options(
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
+ ),
+ cast_to=object,
+ )
+
+
+class ResponseResourceWithRawResponse:
+ def __init__(self, response: ResponseResource) -> None:
+ self._response = response
+
+ self.get = to_raw_response_wrapper(
+ response.get,
+ )
+
+
+class AsyncResponseResourceWithRawResponse:
+ def __init__(self, response: AsyncResponseResource) -> None:
+ self._response = response
+
+ self.get = async_to_raw_response_wrapper(
+ response.get,
+ )
+
+
+class ResponseResourceWithStreamingResponse:
+ def __init__(self, response: ResponseResource) -> None:
+ self._response = response
+
+ self.get = to_streamed_response_wrapper(
+ response.get,
+ )
+
+
+class AsyncResponseResourceWithStreamingResponse:
+ def __init__(self, response: AsyncResponseResource) -> None:
+ self._response = response
+
+ self.get = async_to_streamed_response_wrapper(
+ response.get,
+ )
diff --git a/src/cloudflare/types/ai_gateway/__init__.py b/src/cloudflare/types/ai_gateway/__init__.py
index 8a4216b8edb..afc8501bed2 100644
--- a/src/cloudflare/types/ai_gateway/__init__.py
+++ b/src/cloudflare/types/ai_gateway/__init__.py
@@ -3,6 +3,7 @@
from __future__ import annotations
from .log_list_params import LogListParams as LogListParams
+from .log_get_response import LogGetResponse as LogGetResponse
from .log_list_response import LogListResponse as LogListResponse
from .ai_gateway_list_params import AIGatewayListParams as AIGatewayListParams
from .ai_gateway_get_response import AIGatewayGetResponse as AIGatewayGetResponse
diff --git a/src/cloudflare/types/ai_gateway/log_get_response.py b/src/cloudflare/types/ai_gateway/log_get_response.py
new file mode 100644
index 00000000000..ff80ce3414d
--- /dev/null
+++ b/src/cloudflare/types/ai_gateway/log_get_response.py
@@ -0,0 +1,46 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from typing import Optional
+from datetime import datetime
+
+from ..._models import BaseModel
+
+__all__ = ["LogGetResponse"]
+
+
+class LogGetResponse(BaseModel):
+ id: str
+
+ cached: bool
+
+ created_at: datetime
+
+ duration: int
+
+ model: str
+
+ path: str
+
+ provider: str
+
+ request: str
+
+ response: str
+
+ success: bool
+
+ tokens_in: int
+
+ tokens_out: int
+
+ metadata: Optional[str] = None
+
+ request_content_type: Optional[str] = None
+
+ request_type: Optional[str] = None
+
+ response_content_type: Optional[str] = None
+
+ status_code: Optional[int] = None
+
+ step: Optional[int] = None
diff --git a/tests/api_resources/ai_gateway/logs/test_request.py b/tests/api_resources/ai_gateway/logs/test_request.py
new file mode 100644
index 00000000000..d7a2c3da764
--- /dev/null
+++ b/tests/api_resources/ai_gateway/logs/test_request.py
@@ -0,0 +1,141 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+import os
+from typing import Any, cast
+
+import pytest
+
+from cloudflare import Cloudflare, AsyncCloudflare
+from tests.utils import assert_matches_type
+
+base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
+
+
+class TestRequest:
+ parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
+
+ @parametrize
+ def test_method_get(self, client: Cloudflare) -> None:
+ request = client.ai_gateway.logs.request.get(
+ "string",
+ account_id="0d37909e38d3e99c29fa2cd343ac421a",
+ id="my-gateway",
+ )
+ assert_matches_type(object, request, path=["response"])
+
+ @parametrize
+ def test_raw_response_get(self, client: Cloudflare) -> None:
+ response = client.ai_gateway.logs.request.with_raw_response.get(
+ "string",
+ account_id="0d37909e38d3e99c29fa2cd343ac421a",
+ id="my-gateway",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ request = response.parse()
+ assert_matches_type(object, request, path=["response"])
+
+ @parametrize
+ def test_streaming_response_get(self, client: Cloudflare) -> None:
+ with client.ai_gateway.logs.request.with_streaming_response.get(
+ "string",
+ account_id="0d37909e38d3e99c29fa2cd343ac421a",
+ id="my-gateway",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ request = response.parse()
+ assert_matches_type(object, request, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ def test_path_params_get(self, client: Cloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
+ client.ai_gateway.logs.request.with_raw_response.get(
+ "string",
+ account_id="",
+ id="my-gateway",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
+ client.ai_gateway.logs.request.with_raw_response.get(
+ "string",
+ account_id="0d37909e38d3e99c29fa2cd343ac421a",
+ id="",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `log_id` but received ''"):
+ client.ai_gateway.logs.request.with_raw_response.get(
+ "",
+ account_id="0d37909e38d3e99c29fa2cd343ac421a",
+ id="my-gateway",
+ )
+
+
+class TestAsyncRequest:
+ parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
+
+ @parametrize
+ async def test_method_get(self, async_client: AsyncCloudflare) -> None:
+ request = await async_client.ai_gateway.logs.request.get(
+ "string",
+ account_id="0d37909e38d3e99c29fa2cd343ac421a",
+ id="my-gateway",
+ )
+ assert_matches_type(object, request, path=["response"])
+
+ @parametrize
+ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None:
+ response = await async_client.ai_gateway.logs.request.with_raw_response.get(
+ "string",
+ account_id="0d37909e38d3e99c29fa2cd343ac421a",
+ id="my-gateway",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ request = await response.parse()
+ assert_matches_type(object, request, path=["response"])
+
+ @parametrize
+ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None:
+ async with async_client.ai_gateway.logs.request.with_streaming_response.get(
+ "string",
+ account_id="0d37909e38d3e99c29fa2cd343ac421a",
+ id="my-gateway",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ request = await response.parse()
+ assert_matches_type(object, request, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ async def test_path_params_get(self, async_client: AsyncCloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
+ await async_client.ai_gateway.logs.request.with_raw_response.get(
+ "string",
+ account_id="",
+ id="my-gateway",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
+ await async_client.ai_gateway.logs.request.with_raw_response.get(
+ "string",
+ account_id="0d37909e38d3e99c29fa2cd343ac421a",
+ id="",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `log_id` but received ''"):
+ await async_client.ai_gateway.logs.request.with_raw_response.get(
+ "",
+ account_id="0d37909e38d3e99c29fa2cd343ac421a",
+ id="my-gateway",
+ )
diff --git a/tests/api_resources/ai_gateway/logs/test_response.py b/tests/api_resources/ai_gateway/logs/test_response.py
new file mode 100644
index 00000000000..f66bf7c2449
--- /dev/null
+++ b/tests/api_resources/ai_gateway/logs/test_response.py
@@ -0,0 +1,141 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+import os
+from typing import Any, cast
+
+import pytest
+
+from cloudflare import Cloudflare, AsyncCloudflare
+from tests.utils import assert_matches_type
+
+base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
+
+
+class TestResponse:
+ parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
+
+ @parametrize
+ def test_method_get(self, client: Cloudflare) -> None:
+ response = client.ai_gateway.logs.response.get(
+ "string",
+ account_id="0d37909e38d3e99c29fa2cd343ac421a",
+ id="my-gateway",
+ )
+ assert_matches_type(object, response, path=["response"])
+
+ @parametrize
+ def test_raw_response_get(self, client: Cloudflare) -> None:
+ http_response = client.ai_gateway.logs.response.with_raw_response.get(
+ "string",
+ account_id="0d37909e38d3e99c29fa2cd343ac421a",
+ id="my-gateway",
+ )
+
+ assert http_response.is_closed is True
+ assert http_response.http_request.headers.get("X-Stainless-Lang") == "python"
+ response = http_response.parse()
+ assert_matches_type(object, response, path=["response"])
+
+ @parametrize
+ def test_streaming_response_get(self, client: Cloudflare) -> None:
+ with client.ai_gateway.logs.response.with_streaming_response.get(
+ "string",
+ account_id="0d37909e38d3e99c29fa2cd343ac421a",
+ id="my-gateway",
+ ) as http_response:
+ assert not http_response.is_closed
+ assert http_response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ response = http_response.parse()
+ assert_matches_type(object, response, path=["response"])
+
+ assert cast(Any, http_response.is_closed) is True
+
+ @parametrize
+ def test_path_params_get(self, client: Cloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
+ client.ai_gateway.logs.response.with_raw_response.get(
+ "string",
+ account_id="",
+ id="my-gateway",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
+ client.ai_gateway.logs.response.with_raw_response.get(
+ "string",
+ account_id="0d37909e38d3e99c29fa2cd343ac421a",
+ id="",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `log_id` but received ''"):
+ client.ai_gateway.logs.response.with_raw_response.get(
+ "",
+ account_id="0d37909e38d3e99c29fa2cd343ac421a",
+ id="my-gateway",
+ )
+
+
+class TestAsyncResponse:
+ parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
+
+ @parametrize
+ async def test_method_get(self, async_client: AsyncCloudflare) -> None:
+ response = await async_client.ai_gateway.logs.response.get(
+ "string",
+ account_id="0d37909e38d3e99c29fa2cd343ac421a",
+ id="my-gateway",
+ )
+ assert_matches_type(object, response, path=["response"])
+
+ @parametrize
+ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None:
+ http_response = await async_client.ai_gateway.logs.response.with_raw_response.get(
+ "string",
+ account_id="0d37909e38d3e99c29fa2cd343ac421a",
+ id="my-gateway",
+ )
+
+ assert http_response.is_closed is True
+ assert http_response.http_request.headers.get("X-Stainless-Lang") == "python"
+ response = await http_response.parse()
+ assert_matches_type(object, response, path=["response"])
+
+ @parametrize
+ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None:
+ async with async_client.ai_gateway.logs.response.with_streaming_response.get(
+ "string",
+ account_id="0d37909e38d3e99c29fa2cd343ac421a",
+ id="my-gateway",
+ ) as http_response:
+ assert not http_response.is_closed
+ assert http_response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ response = await http_response.parse()
+ assert_matches_type(object, response, path=["response"])
+
+ assert cast(Any, http_response.is_closed) is True
+
+ @parametrize
+ async def test_path_params_get(self, async_client: AsyncCloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
+ await async_client.ai_gateway.logs.response.with_raw_response.get(
+ "string",
+ account_id="",
+ id="my-gateway",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
+ await async_client.ai_gateway.logs.response.with_raw_response.get(
+ "string",
+ account_id="0d37909e38d3e99c29fa2cd343ac421a",
+ id="",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `log_id` but received ''"):
+ await async_client.ai_gateway.logs.response.with_raw_response.get(
+ "",
+ account_id="0d37909e38d3e99c29fa2cd343ac421a",
+ id="my-gateway",
+ )
diff --git a/tests/api_resources/ai_gateway/test_logs.py b/tests/api_resources/ai_gateway/test_logs.py
index 79fbfbf7ca0..485dc79d148 100644
--- a/tests/api_resources/ai_gateway/test_logs.py
+++ b/tests/api_resources/ai_gateway/test_logs.py
@@ -11,7 +11,7 @@
from tests.utils import assert_matches_type
from cloudflare._utils import parse_datetime
from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray
-from cloudflare.types.ai_gateway import LogListResponse
+from cloudflare.types.ai_gateway import LogGetResponse, LogListResponse
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
@@ -84,6 +84,66 @@ def test_path_params_list(self, client: Cloudflare) -> None:
account_id="0d37909e38d3e99c29fa2cd343ac421a",
)
+ @parametrize
+ def test_method_get(self, client: Cloudflare) -> None:
+ log = client.ai_gateway.logs.get(
+ "string",
+ account_id="0d37909e38d3e99c29fa2cd343ac421a",
+ id="my-gateway",
+ )
+ assert_matches_type(LogGetResponse, log, path=["response"])
+
+ @parametrize
+ def test_raw_response_get(self, client: Cloudflare) -> None:
+ response = client.ai_gateway.logs.with_raw_response.get(
+ "string",
+ account_id="0d37909e38d3e99c29fa2cd343ac421a",
+ id="my-gateway",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ log = response.parse()
+ assert_matches_type(LogGetResponse, log, path=["response"])
+
+ @parametrize
+ def test_streaming_response_get(self, client: Cloudflare) -> None:
+ with client.ai_gateway.logs.with_streaming_response.get(
+ "string",
+ account_id="0d37909e38d3e99c29fa2cd343ac421a",
+ id="my-gateway",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ log = response.parse()
+ assert_matches_type(LogGetResponse, log, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ def test_path_params_get(self, client: Cloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
+ client.ai_gateway.logs.with_raw_response.get(
+ "string",
+ account_id="",
+ id="my-gateway",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
+ client.ai_gateway.logs.with_raw_response.get(
+ "string",
+ account_id="0d37909e38d3e99c29fa2cd343ac421a",
+ id="",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `log_id` but received ''"):
+ client.ai_gateway.logs.with_raw_response.get(
+ "",
+ account_id="0d37909e38d3e99c29fa2cd343ac421a",
+ id="my-gateway",
+ )
+
class TestAsyncLogs:
parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
@@ -152,3 +212,63 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None:
"",
account_id="0d37909e38d3e99c29fa2cd343ac421a",
)
+
+ @parametrize
+ async def test_method_get(self, async_client: AsyncCloudflare) -> None:
+ log = await async_client.ai_gateway.logs.get(
+ "string",
+ account_id="0d37909e38d3e99c29fa2cd343ac421a",
+ id="my-gateway",
+ )
+ assert_matches_type(LogGetResponse, log, path=["response"])
+
+ @parametrize
+ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None:
+ response = await async_client.ai_gateway.logs.with_raw_response.get(
+ "string",
+ account_id="0d37909e38d3e99c29fa2cd343ac421a",
+ id="my-gateway",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ log = await response.parse()
+ assert_matches_type(LogGetResponse, log, path=["response"])
+
+ @parametrize
+ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None:
+ async with async_client.ai_gateway.logs.with_streaming_response.get(
+ "string",
+ account_id="0d37909e38d3e99c29fa2cd343ac421a",
+ id="my-gateway",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ log = await response.parse()
+ assert_matches_type(LogGetResponse, log, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ async def test_path_params_get(self, async_client: AsyncCloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
+ await async_client.ai_gateway.logs.with_raw_response.get(
+ "string",
+ account_id="",
+ id="my-gateway",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
+ await async_client.ai_gateway.logs.with_raw_response.get(
+ "string",
+ account_id="0d37909e38d3e99c29fa2cd343ac421a",
+ id="",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `log_id` but received ''"):
+ await async_client.ai_gateway.logs.with_raw_response.get(
+ "",
+ account_id="0d37909e38d3e99c29fa2cd343ac421a",
+ id="my-gateway",
+ )