From cc6768e4ad310b4dcf439cdf6afa647d13d0d5ea Mon Sep 17 00:00:00 2001
From: "stainless-app[bot]"
<142633134+stainless-app[bot]@users.noreply.github.com>
Date: Mon, 6 May 2024 02:06:51 +0000
Subject: [PATCH] feat(api): update via SDK Studio (#456)
---
.stats.yml | 2 +-
api.md | 34 +
src/cloudflare/_client.py | 8 +
src/cloudflare/resources/__init__.py | 14 +
.../resources/ai_gateway/__init__.py | 33 +
.../resources/ai_gateway/ai_gateway.py | 673 ++++++++++++++++++
src/cloudflare/resources/ai_gateway/logs.py | 213 ++++++
src/cloudflare/types/ai_gateway/__init__.py | 14 +
.../ai_gateway/ai_gateway_create_params.py | 25 +
.../ai_gateway/ai_gateway_create_response.py | 36 +
.../ai_gateway/ai_gateway_delete_response.py | 32 +
.../ai_gateway/ai_gateway_get_response.py | 32 +
.../ai_gateway/ai_gateway_list_params.py | 18 +
.../ai_gateway/ai_gateway_list_response.py | 32 +
.../ai_gateway/ai_gateway_update_params.py | 27 +
.../ai_gateway/ai_gateway_update_response.py | 32 +
.../types/ai_gateway/log_get_params.py | 33 +
.../types/ai_gateway/log_get_response.py | 37 +
tests/api_resources/ai_gateway/__init__.py | 1 +
tests/api_resources/ai_gateway/test_logs.py | 153 ++++
tests/api_resources/test_ai_gateway.py | 643 +++++++++++++++++
21 files changed, 2091 insertions(+), 1 deletion(-)
create mode 100644 src/cloudflare/resources/ai_gateway/__init__.py
create mode 100644 src/cloudflare/resources/ai_gateway/ai_gateway.py
create mode 100644 src/cloudflare/resources/ai_gateway/logs.py
create mode 100644 src/cloudflare/types/ai_gateway/__init__.py
create mode 100644 src/cloudflare/types/ai_gateway/ai_gateway_create_params.py
create mode 100644 src/cloudflare/types/ai_gateway/ai_gateway_create_response.py
create mode 100644 src/cloudflare/types/ai_gateway/ai_gateway_delete_response.py
create mode 100644 src/cloudflare/types/ai_gateway/ai_gateway_get_response.py
create mode 100644 src/cloudflare/types/ai_gateway/ai_gateway_list_params.py
create mode 100644 src/cloudflare/types/ai_gateway/ai_gateway_list_response.py
create mode 100644 src/cloudflare/types/ai_gateway/ai_gateway_update_params.py
create mode 100644 src/cloudflare/types/ai_gateway/ai_gateway_update_response.py
create mode 100644 src/cloudflare/types/ai_gateway/log_get_params.py
create mode 100644 src/cloudflare/types/ai_gateway/log_get_response.py
create mode 100644 tests/api_resources/ai_gateway/__init__.py
create mode 100644 tests/api_resources/ai_gateway/test_logs.py
create mode 100644 tests/api_resources/test_ai_gateway.py
diff --git a/.stats.yml b/.stats.yml
index 3f3b1274704..b07651d49ab 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,2 +1,2 @@
-configured_endpoints: 1269
+configured_endpoints: 1275
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ecba01cd225d19e1decd3caa323399e3f580a2abbdd4a756fa536063651facee.yml
diff --git a/api.md b/api.md
index 6a46abc2cbe..190632be589 100644
--- a/api.md
+++ b/api.md
@@ -7435,3 +7435,37 @@ Methods:
- client.event_notifications.r2.configuration.queues.update(queue_id, \*, account_id, bucket_name, \*\*params) -> QueueUpdateResponse
- client.event_notifications.r2.configuration.queues.delete(queue_id, \*, account_id, bucket_name) -> QueueDeleteResponse
+
+# AIGateway
+
+Types:
+
+```python
+from cloudflare.types.ai_gateway import (
+ AIGatewayCreateResponse,
+ AIGatewayUpdateResponse,
+ AIGatewayListResponse,
+ AIGatewayDeleteResponse,
+ AIGatewayGetResponse,
+)
+```
+
+Methods:
+
+- client.ai_gateway.create(account_tag, \*\*params) -> AIGatewayCreateResponse
+- client.ai_gateway.update(id, \*, account_tag, \*\*params) -> AIGatewayUpdateResponse
+- client.ai_gateway.list(account_tag, \*\*params) -> SyncV4PagePaginationArray[AIGatewayListResponse]
+- client.ai_gateway.delete(id, \*, account_tag) -> AIGatewayDeleteResponse
+- client.ai_gateway.get(id, \*, account_tag) -> AIGatewayGetResponse
+
+## Logs
+
+Types:
+
+```python
+from cloudflare.types.ai_gateway import LogGetResponse
+```
+
+Methods:
+
+- client.ai_gateway.logs.get(id, \*, account_tag, \*\*params) -> LogGetResponse
diff --git a/src/cloudflare/_client.py b/src/cloudflare/_client.py
index 41a4fcfac22..529638ece6d 100644
--- a/src/cloudflare/_client.py
+++ b/src/cloudflare/_client.py
@@ -128,6 +128,7 @@ class Cloudflare(SyncAPIClient):
calls: resources.CallsResource
cloudforce_one: resources.CloudforceOneResource
event_notifications: resources.EventNotificationsResource
+ ai_gateway: resources.AIGatewayResource
with_raw_response: CloudflareWithRawResponse
with_streaming_response: CloudflareWithStreamedResponse
@@ -284,6 +285,7 @@ def __init__(
self.calls = resources.CallsResource(self)
self.cloudforce_one = resources.CloudforceOneResource(self)
self.event_notifications = resources.EventNotificationsResource(self)
+ self.ai_gateway = resources.AIGatewayResource(self)
self.with_raw_response = CloudflareWithRawResponse(self)
self.with_streaming_response = CloudflareWithStreamedResponse(self)
@@ -543,6 +545,7 @@ class AsyncCloudflare(AsyncAPIClient):
calls: resources.AsyncCallsResource
cloudforce_one: resources.AsyncCloudforceOneResource
event_notifications: resources.AsyncEventNotificationsResource
+ ai_gateway: resources.AsyncAIGatewayResource
with_raw_response: AsyncCloudflareWithRawResponse
with_streaming_response: AsyncCloudflareWithStreamedResponse
@@ -699,6 +702,7 @@ def __init__(
self.calls = resources.AsyncCallsResource(self)
self.cloudforce_one = resources.AsyncCloudforceOneResource(self)
self.event_notifications = resources.AsyncEventNotificationsResource(self)
+ self.ai_gateway = resources.AsyncAIGatewayResource(self)
self.with_raw_response = AsyncCloudflareWithRawResponse(self)
self.with_streaming_response = AsyncCloudflareWithStreamedResponse(self)
@@ -969,6 +973,7 @@ def __init__(self, client: Cloudflare) -> None:
self.calls = resources.CallsResourceWithRawResponse(client.calls)
self.cloudforce_one = resources.CloudforceOneResourceWithRawResponse(client.cloudforce_one)
self.event_notifications = resources.EventNotificationsResourceWithRawResponse(client.event_notifications)
+ self.ai_gateway = resources.AIGatewayResourceWithRawResponse(client.ai_gateway)
class AsyncCloudflareWithRawResponse:
@@ -1068,6 +1073,7 @@ def __init__(self, client: AsyncCloudflare) -> None:
self.calls = resources.AsyncCallsResourceWithRawResponse(client.calls)
self.cloudforce_one = resources.AsyncCloudforceOneResourceWithRawResponse(client.cloudforce_one)
self.event_notifications = resources.AsyncEventNotificationsResourceWithRawResponse(client.event_notifications)
+ self.ai_gateway = resources.AsyncAIGatewayResourceWithRawResponse(client.ai_gateway)
class CloudflareWithStreamedResponse:
@@ -1167,6 +1173,7 @@ def __init__(self, client: Cloudflare) -> None:
self.calls = resources.CallsResourceWithStreamingResponse(client.calls)
self.cloudforce_one = resources.CloudforceOneResourceWithStreamingResponse(client.cloudforce_one)
self.event_notifications = resources.EventNotificationsResourceWithStreamingResponse(client.event_notifications)
+ self.ai_gateway = resources.AIGatewayResourceWithStreamingResponse(client.ai_gateway)
class AsyncCloudflareWithStreamedResponse:
@@ -1274,6 +1281,7 @@ def __init__(self, client: AsyncCloudflare) -> None:
self.event_notifications = resources.AsyncEventNotificationsResourceWithStreamingResponse(
client.event_notifications
)
+ self.ai_gateway = resources.AsyncAIGatewayResourceWithStreamingResponse(client.ai_gateway)
Client = Cloudflare
diff --git a/src/cloudflare/resources/__init__.py b/src/cloudflare/resources/__init__.py
index e4d0f926f5d..4d7acbc7a4c 100644
--- a/src/cloudflare/resources/__init__.py
+++ b/src/cloudflare/resources/__init__.py
@@ -336,6 +336,14 @@
AddressingResourceWithStreamingResponse,
AsyncAddressingResourceWithStreamingResponse,
)
+from .ai_gateway import (
+ AIGatewayResource,
+ AsyncAIGatewayResource,
+ AIGatewayResourceWithRawResponse,
+ AsyncAIGatewayResourceWithRawResponse,
+ AIGatewayResourceWithStreamingResponse,
+ AsyncAIGatewayResourceWithStreamingResponse,
+)
from .audit_logs import (
AuditLogsResource,
AsyncAuditLogsResource,
@@ -1136,4 +1144,10 @@
"AsyncEventNotificationsResourceWithRawResponse",
"EventNotificationsResourceWithStreamingResponse",
"AsyncEventNotificationsResourceWithStreamingResponse",
+ "AIGatewayResource",
+ "AsyncAIGatewayResource",
+ "AIGatewayResourceWithRawResponse",
+ "AsyncAIGatewayResourceWithRawResponse",
+ "AIGatewayResourceWithStreamingResponse",
+ "AsyncAIGatewayResourceWithStreamingResponse",
]
diff --git a/src/cloudflare/resources/ai_gateway/__init__.py b/src/cloudflare/resources/ai_gateway/__init__.py
new file mode 100644
index 00000000000..95883733129
--- /dev/null
+++ b/src/cloudflare/resources/ai_gateway/__init__.py
@@ -0,0 +1,33 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from .logs import (
+ LogsResource,
+ AsyncLogsResource,
+ LogsResourceWithRawResponse,
+ AsyncLogsResourceWithRawResponse,
+ LogsResourceWithStreamingResponse,
+ AsyncLogsResourceWithStreamingResponse,
+)
+from .ai_gateway import (
+ AIGatewayResource,
+ AsyncAIGatewayResource,
+ AIGatewayResourceWithRawResponse,
+ AsyncAIGatewayResourceWithRawResponse,
+ AIGatewayResourceWithStreamingResponse,
+ AsyncAIGatewayResourceWithStreamingResponse,
+)
+
+__all__ = [
+ "LogsResource",
+ "AsyncLogsResource",
+ "LogsResourceWithRawResponse",
+ "AsyncLogsResourceWithRawResponse",
+ "LogsResourceWithStreamingResponse",
+ "AsyncLogsResourceWithStreamingResponse",
+ "AIGatewayResource",
+ "AsyncAIGatewayResource",
+ "AIGatewayResourceWithRawResponse",
+ "AsyncAIGatewayResourceWithRawResponse",
+ "AIGatewayResourceWithStreamingResponse",
+ "AsyncAIGatewayResourceWithStreamingResponse",
+]
diff --git a/src/cloudflare/resources/ai_gateway/ai_gateway.py b/src/cloudflare/resources/ai_gateway/ai_gateway.py
new file mode 100644
index 00000000000..0c89bf1dbd6
--- /dev/null
+++ b/src/cloudflare/resources/ai_gateway/ai_gateway.py
@@ -0,0 +1,673 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing import Type, cast
+
+import httpx
+
+from .logs import (
+ LogsResource,
+ AsyncLogsResource,
+ LogsResourceWithRawResponse,
+ AsyncLogsResourceWithRawResponse,
+ LogsResourceWithStreamingResponse,
+ AsyncLogsResourceWithStreamingResponse,
+)
+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 (
+ to_raw_response_wrapper,
+ to_streamed_response_wrapper,
+ 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 ai_gateway_list_params, ai_gateway_create_params, ai_gateway_update_params
+from ...types.ai_gateway.ai_gateway_get_response import AIGatewayGetResponse
+from ...types.ai_gateway.ai_gateway_list_response import AIGatewayListResponse
+from ...types.ai_gateway.ai_gateway_create_response import AIGatewayCreateResponse
+from ...types.ai_gateway.ai_gateway_delete_response import AIGatewayDeleteResponse
+from ...types.ai_gateway.ai_gateway_update_response import AIGatewayUpdateResponse
+
+__all__ = ["AIGatewayResource", "AsyncAIGatewayResource"]
+
+
+class AIGatewayResource(SyncAPIResource):
+ @cached_property
+ def logs(self) -> LogsResource:
+ return LogsResource(self._client)
+
+ @cached_property
+ def with_raw_response(self) -> AIGatewayResourceWithRawResponse:
+ return AIGatewayResourceWithRawResponse(self)
+
+ @cached_property
+ def with_streaming_response(self) -> AIGatewayResourceWithStreamingResponse:
+ return AIGatewayResourceWithStreamingResponse(self)
+
+ def create(
+ self,
+ account_tag: str,
+ *,
+ cache_invalidate_on_update: bool,
+ cache_ttl: int,
+ collect_logs: bool,
+ name: str,
+ slug: str,
+ rate_limiting_interval: int | NotGiven = NOT_GIVEN,
+ rate_limiting_limit: int | NotGiven = NOT_GIVEN,
+ rate_limiting_technique: 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,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> AIGatewayCreateResponse:
+ """
+ Create a new Gateway
+
+ 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
+ """
+ if not account_tag:
+ raise ValueError(f"Expected a non-empty value for `account_tag` but received {account_tag!r}")
+ return self._post(
+ f"/accounts/{account_tag}/ai-gateway/gateways",
+ body=maybe_transform(
+ {
+ "cache_invalidate_on_update": cache_invalidate_on_update,
+ "cache_ttl": cache_ttl,
+ "collect_logs": collect_logs,
+ "name": name,
+ "slug": slug,
+ "rate_limiting_interval": rate_limiting_interval,
+ "rate_limiting_limit": rate_limiting_limit,
+ "rate_limiting_technique": rate_limiting_technique,
+ },
+ ai_gateway_create_params.AIGatewayCreateParams,
+ ),
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ post_parser=ResultWrapper[AIGatewayCreateResponse]._unwrapper,
+ ),
+ cast_to=cast(Type[AIGatewayCreateResponse], ResultWrapper[AIGatewayCreateResponse]),
+ )
+
+ def update(
+ self,
+ id: str,
+ *,
+ account_tag: str,
+ cache_invalidate_on_update: bool,
+ cache_ttl: int,
+ collect_logs: bool,
+ name: str,
+ slug: str,
+ rate_limiting_interval: int | NotGiven = NOT_GIVEN,
+ rate_limiting_limit: int | NotGiven = NOT_GIVEN,
+ rate_limiting_technique: 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,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> AIGatewayUpdateResponse:
+ """
+ Update a Gateway
+
+ 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
+ """
+ if not account_tag:
+ raise ValueError(f"Expected a non-empty value for `account_tag` but received {account_tag!r}")
+ if not id:
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
+ return self._put(
+ f"/accounts/{account_tag}/ai-gateway/gateways/{id}",
+ body=maybe_transform(
+ {
+ "cache_invalidate_on_update": cache_invalidate_on_update,
+ "cache_ttl": cache_ttl,
+ "collect_logs": collect_logs,
+ "name": name,
+ "slug": slug,
+ "rate_limiting_interval": rate_limiting_interval,
+ "rate_limiting_limit": rate_limiting_limit,
+ "rate_limiting_technique": rate_limiting_technique,
+ },
+ ai_gateway_update_params.AIGatewayUpdateParams,
+ ),
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ post_parser=ResultWrapper[AIGatewayUpdateResponse]._unwrapper,
+ ),
+ cast_to=cast(Type[AIGatewayUpdateResponse], ResultWrapper[AIGatewayUpdateResponse]),
+ )
+
+ def list(
+ self,
+ account_tag: str,
+ *,
+ id: str | NotGiven = NOT_GIVEN,
+ order_by: str | NotGiven = NOT_GIVEN,
+ page: int | NotGiven = NOT_GIVEN,
+ per_page: int | 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,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> SyncV4PagePaginationArray[AIGatewayListResponse]:
+ """
+ List Gateway's
+
+ Args:
+ order_by: Order By Column Name
+
+ 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_tag:
+ raise ValueError(f"Expected a non-empty value for `account_tag` but received {account_tag!r}")
+ return self._get_api_list(
+ f"/accounts/{account_tag}/ai-gateway/gateways",
+ page=SyncV4PagePaginationArray[AIGatewayListResponse],
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ query=maybe_transform(
+ {
+ "id": id,
+ "order_by": order_by,
+ "page": page,
+ "per_page": per_page,
+ },
+ ai_gateway_list_params.AIGatewayListParams,
+ ),
+ ),
+ model=AIGatewayListResponse,
+ )
+
+ def delete(
+ self,
+ id: str,
+ *,
+ account_tag: 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,
+ ) -> AIGatewayDeleteResponse:
+ """
+ Delete a Gateway
+
+ 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
+ """
+ if not account_tag:
+ raise ValueError(f"Expected a non-empty value for `account_tag` but received {account_tag!r}")
+ if not id:
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
+ return self._delete(
+ f"/accounts/{account_tag}/ai-gateway/gateways/{id}",
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ post_parser=ResultWrapper[AIGatewayDeleteResponse]._unwrapper,
+ ),
+ cast_to=cast(Type[AIGatewayDeleteResponse], ResultWrapper[AIGatewayDeleteResponse]),
+ )
+
+ def get(
+ self,
+ id: str,
+ *,
+ account_tag: 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,
+ ) -> AIGatewayGetResponse:
+ """
+ Fetch a Gateway
+
+ 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
+ """
+ if not account_tag:
+ raise ValueError(f"Expected a non-empty value for `account_tag` but received {account_tag!r}")
+ if not id:
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
+ return self._get(
+ f"/accounts/{account_tag}/ai-gateway/gateways/{id}",
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ post_parser=ResultWrapper[AIGatewayGetResponse]._unwrapper,
+ ),
+ cast_to=cast(Type[AIGatewayGetResponse], ResultWrapper[AIGatewayGetResponse]),
+ )
+
+
+class AsyncAIGatewayResource(AsyncAPIResource):
+ @cached_property
+ def logs(self) -> AsyncLogsResource:
+ return AsyncLogsResource(self._client)
+
+ @cached_property
+ def with_raw_response(self) -> AsyncAIGatewayResourceWithRawResponse:
+ return AsyncAIGatewayResourceWithRawResponse(self)
+
+ @cached_property
+ def with_streaming_response(self) -> AsyncAIGatewayResourceWithStreamingResponse:
+ return AsyncAIGatewayResourceWithStreamingResponse(self)
+
+ async def create(
+ self,
+ account_tag: str,
+ *,
+ cache_invalidate_on_update: bool,
+ cache_ttl: int,
+ collect_logs: bool,
+ name: str,
+ slug: str,
+ rate_limiting_interval: int | NotGiven = NOT_GIVEN,
+ rate_limiting_limit: int | NotGiven = NOT_GIVEN,
+ rate_limiting_technique: 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,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> AIGatewayCreateResponse:
+ """
+ Create a new Gateway
+
+ 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
+ """
+ if not account_tag:
+ raise ValueError(f"Expected a non-empty value for `account_tag` but received {account_tag!r}")
+ return await self._post(
+ f"/accounts/{account_tag}/ai-gateway/gateways",
+ body=await async_maybe_transform(
+ {
+ "cache_invalidate_on_update": cache_invalidate_on_update,
+ "cache_ttl": cache_ttl,
+ "collect_logs": collect_logs,
+ "name": name,
+ "slug": slug,
+ "rate_limiting_interval": rate_limiting_interval,
+ "rate_limiting_limit": rate_limiting_limit,
+ "rate_limiting_technique": rate_limiting_technique,
+ },
+ ai_gateway_create_params.AIGatewayCreateParams,
+ ),
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ post_parser=ResultWrapper[AIGatewayCreateResponse]._unwrapper,
+ ),
+ cast_to=cast(Type[AIGatewayCreateResponse], ResultWrapper[AIGatewayCreateResponse]),
+ )
+
+ async def update(
+ self,
+ id: str,
+ *,
+ account_tag: str,
+ cache_invalidate_on_update: bool,
+ cache_ttl: int,
+ collect_logs: bool,
+ name: str,
+ slug: str,
+ rate_limiting_interval: int | NotGiven = NOT_GIVEN,
+ rate_limiting_limit: int | NotGiven = NOT_GIVEN,
+ rate_limiting_technique: 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,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> AIGatewayUpdateResponse:
+ """
+ Update a Gateway
+
+ 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
+ """
+ if not account_tag:
+ raise ValueError(f"Expected a non-empty value for `account_tag` but received {account_tag!r}")
+ if not id:
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
+ return await self._put(
+ f"/accounts/{account_tag}/ai-gateway/gateways/{id}",
+ body=await async_maybe_transform(
+ {
+ "cache_invalidate_on_update": cache_invalidate_on_update,
+ "cache_ttl": cache_ttl,
+ "collect_logs": collect_logs,
+ "name": name,
+ "slug": slug,
+ "rate_limiting_interval": rate_limiting_interval,
+ "rate_limiting_limit": rate_limiting_limit,
+ "rate_limiting_technique": rate_limiting_technique,
+ },
+ ai_gateway_update_params.AIGatewayUpdateParams,
+ ),
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ post_parser=ResultWrapper[AIGatewayUpdateResponse]._unwrapper,
+ ),
+ cast_to=cast(Type[AIGatewayUpdateResponse], ResultWrapper[AIGatewayUpdateResponse]),
+ )
+
+ def list(
+ self,
+ account_tag: str,
+ *,
+ id: str | NotGiven = NOT_GIVEN,
+ order_by: str | NotGiven = NOT_GIVEN,
+ page: int | NotGiven = NOT_GIVEN,
+ per_page: int | 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,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> AsyncPaginator[AIGatewayListResponse, AsyncV4PagePaginationArray[AIGatewayListResponse]]:
+ """
+ List Gateway's
+
+ Args:
+ order_by: Order By Column Name
+
+ 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_tag:
+ raise ValueError(f"Expected a non-empty value for `account_tag` but received {account_tag!r}")
+ return self._get_api_list(
+ f"/accounts/{account_tag}/ai-gateway/gateways",
+ page=AsyncV4PagePaginationArray[AIGatewayListResponse],
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ query=maybe_transform(
+ {
+ "id": id,
+ "order_by": order_by,
+ "page": page,
+ "per_page": per_page,
+ },
+ ai_gateway_list_params.AIGatewayListParams,
+ ),
+ ),
+ model=AIGatewayListResponse,
+ )
+
+ async def delete(
+ self,
+ id: str,
+ *,
+ account_tag: 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,
+ ) -> AIGatewayDeleteResponse:
+ """
+ Delete a Gateway
+
+ 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
+ """
+ if not account_tag:
+ raise ValueError(f"Expected a non-empty value for `account_tag` but received {account_tag!r}")
+ if not id:
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
+ return await self._delete(
+ f"/accounts/{account_tag}/ai-gateway/gateways/{id}",
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ post_parser=ResultWrapper[AIGatewayDeleteResponse]._unwrapper,
+ ),
+ cast_to=cast(Type[AIGatewayDeleteResponse], ResultWrapper[AIGatewayDeleteResponse]),
+ )
+
+ async def get(
+ self,
+ id: str,
+ *,
+ account_tag: 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,
+ ) -> AIGatewayGetResponse:
+ """
+ Fetch a Gateway
+
+ 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
+ """
+ if not account_tag:
+ raise ValueError(f"Expected a non-empty value for `account_tag` but received {account_tag!r}")
+ if not id:
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
+ return await self._get(
+ f"/accounts/{account_tag}/ai-gateway/gateways/{id}",
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ post_parser=ResultWrapper[AIGatewayGetResponse]._unwrapper,
+ ),
+ cast_to=cast(Type[AIGatewayGetResponse], ResultWrapper[AIGatewayGetResponse]),
+ )
+
+
+class AIGatewayResourceWithRawResponse:
+ def __init__(self, ai_gateway: AIGatewayResource) -> None:
+ self._ai_gateway = ai_gateway
+
+ self.create = to_raw_response_wrapper(
+ ai_gateway.create,
+ )
+ self.update = to_raw_response_wrapper(
+ ai_gateway.update,
+ )
+ self.list = to_raw_response_wrapper(
+ ai_gateway.list,
+ )
+ self.delete = to_raw_response_wrapper(
+ ai_gateway.delete,
+ )
+ self.get = to_raw_response_wrapper(
+ ai_gateway.get,
+ )
+
+ @cached_property
+ def logs(self) -> LogsResourceWithRawResponse:
+ return LogsResourceWithRawResponse(self._ai_gateway.logs)
+
+
+class AsyncAIGatewayResourceWithRawResponse:
+ def __init__(self, ai_gateway: AsyncAIGatewayResource) -> None:
+ self._ai_gateway = ai_gateway
+
+ self.create = async_to_raw_response_wrapper(
+ ai_gateway.create,
+ )
+ self.update = async_to_raw_response_wrapper(
+ ai_gateway.update,
+ )
+ self.list = async_to_raw_response_wrapper(
+ ai_gateway.list,
+ )
+ self.delete = async_to_raw_response_wrapper(
+ ai_gateway.delete,
+ )
+ self.get = async_to_raw_response_wrapper(
+ ai_gateway.get,
+ )
+
+ @cached_property
+ def logs(self) -> AsyncLogsResourceWithRawResponse:
+ return AsyncLogsResourceWithRawResponse(self._ai_gateway.logs)
+
+
+class AIGatewayResourceWithStreamingResponse:
+ def __init__(self, ai_gateway: AIGatewayResource) -> None:
+ self._ai_gateway = ai_gateway
+
+ self.create = to_streamed_response_wrapper(
+ ai_gateway.create,
+ )
+ self.update = to_streamed_response_wrapper(
+ ai_gateway.update,
+ )
+ self.list = to_streamed_response_wrapper(
+ ai_gateway.list,
+ )
+ self.delete = to_streamed_response_wrapper(
+ ai_gateway.delete,
+ )
+ self.get = to_streamed_response_wrapper(
+ ai_gateway.get,
+ )
+
+ @cached_property
+ def logs(self) -> LogsResourceWithStreamingResponse:
+ return LogsResourceWithStreamingResponse(self._ai_gateway.logs)
+
+
+class AsyncAIGatewayResourceWithStreamingResponse:
+ def __init__(self, ai_gateway: AsyncAIGatewayResource) -> None:
+ self._ai_gateway = ai_gateway
+
+ self.create = async_to_streamed_response_wrapper(
+ ai_gateway.create,
+ )
+ self.update = async_to_streamed_response_wrapper(
+ ai_gateway.update,
+ )
+ self.list = async_to_streamed_response_wrapper(
+ ai_gateway.list,
+ )
+ self.delete = async_to_streamed_response_wrapper(
+ ai_gateway.delete,
+ )
+ self.get = async_to_streamed_response_wrapper(
+ ai_gateway.get,
+ )
+
+ @cached_property
+ def logs(self) -> AsyncLogsResourceWithStreamingResponse:
+ return AsyncLogsResourceWithStreamingResponse(self._ai_gateway.logs)
diff --git a/src/cloudflare/resources/ai_gateway/logs.py b/src/cloudflare/resources/ai_gateway/logs.py
new file mode 100644
index 00000000000..bcf3db29492
--- /dev/null
+++ b/src/cloudflare/resources/ai_gateway/logs.py
@@ -0,0 +1,213 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing import Type, Union, cast
+from datetime import datetime
+from typing_extensions import Literal
+
+import httpx
+
+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 (
+ to_raw_response_wrapper,
+ to_streamed_response_wrapper,
+ async_to_raw_response_wrapper,
+ async_to_streamed_response_wrapper,
+)
+from ..._wrappers import ResultWrapper
+from ..._base_client import (
+ make_request_options,
+)
+from ...types.ai_gateway import log_get_params
+from ...types.ai_gateway.log_get_response import LogGetResponse
+
+__all__ = ["LogsResource", "AsyncLogsResource"]
+
+
+class LogsResource(SyncAPIResource):
+ @cached_property
+ def with_raw_response(self) -> LogsResourceWithRawResponse:
+ return LogsResourceWithRawResponse(self)
+
+ @cached_property
+ def with_streaming_response(self) -> LogsResourceWithStreamingResponse:
+ return LogsResourceWithStreamingResponse(self)
+
+ def get(
+ self,
+ id: str,
+ *,
+ account_tag: str,
+ cached: bool | NotGiven = NOT_GIVEN,
+ direction: Literal["asc", "desc"] | NotGiven = NOT_GIVEN,
+ end_date: Union[str, datetime] | NotGiven = NOT_GIVEN,
+ order_by: Literal["created_at", "provider"] | NotGiven = NOT_GIVEN,
+ page: int | NotGiven = NOT_GIVEN,
+ per_page: int | NotGiven = NOT_GIVEN,
+ search: str | NotGiven = NOT_GIVEN,
+ start_date: Union[str, datetime] | NotGiven = NOT_GIVEN,
+ success: bool | 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,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> LogGetResponse:
+ """
+ List Gateway Logs
+
+ 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
+ """
+ if not account_tag:
+ raise ValueError(f"Expected a non-empty value for `account_tag` but received {account_tag!r}")
+ if not id:
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
+ return self._get(
+ f"/accounts/{account_tag}/ai-gateway/gateways/{id}/logs",
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ query=maybe_transform(
+ {
+ "cached": cached,
+ "direction": direction,
+ "end_date": end_date,
+ "order_by": order_by,
+ "page": page,
+ "per_page": per_page,
+ "search": search,
+ "start_date": start_date,
+ "success": success,
+ },
+ log_get_params.LogGetParams,
+ ),
+ post_parser=ResultWrapper[LogGetResponse]._unwrapper,
+ ),
+ cast_to=cast(Type[LogGetResponse], ResultWrapper[LogGetResponse]),
+ )
+
+
+class AsyncLogsResource(AsyncAPIResource):
+ @cached_property
+ def with_raw_response(self) -> AsyncLogsResourceWithRawResponse:
+ return AsyncLogsResourceWithRawResponse(self)
+
+ @cached_property
+ def with_streaming_response(self) -> AsyncLogsResourceWithStreamingResponse:
+ return AsyncLogsResourceWithStreamingResponse(self)
+
+ async def get(
+ self,
+ id: str,
+ *,
+ account_tag: str,
+ cached: bool | NotGiven = NOT_GIVEN,
+ direction: Literal["asc", "desc"] | NotGiven = NOT_GIVEN,
+ end_date: Union[str, datetime] | NotGiven = NOT_GIVEN,
+ order_by: Literal["created_at", "provider"] | NotGiven = NOT_GIVEN,
+ page: int | NotGiven = NOT_GIVEN,
+ per_page: int | NotGiven = NOT_GIVEN,
+ search: str | NotGiven = NOT_GIVEN,
+ start_date: Union[str, datetime] | NotGiven = NOT_GIVEN,
+ success: bool | 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,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> LogGetResponse:
+ """
+ List Gateway Logs
+
+ 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
+ """
+ if not account_tag:
+ raise ValueError(f"Expected a non-empty value for `account_tag` but received {account_tag!r}")
+ if not id:
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
+ return await self._get(
+ f"/accounts/{account_tag}/ai-gateway/gateways/{id}/logs",
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ query=await async_maybe_transform(
+ {
+ "cached": cached,
+ "direction": direction,
+ "end_date": end_date,
+ "order_by": order_by,
+ "page": page,
+ "per_page": per_page,
+ "search": search,
+ "start_date": start_date,
+ "success": success,
+ },
+ log_get_params.LogGetParams,
+ ),
+ post_parser=ResultWrapper[LogGetResponse]._unwrapper,
+ ),
+ cast_to=cast(Type[LogGetResponse], ResultWrapper[LogGetResponse]),
+ )
+
+
+class LogsResourceWithRawResponse:
+ def __init__(self, logs: LogsResource) -> None:
+ self._logs = logs
+
+ self.get = to_raw_response_wrapper(
+ logs.get,
+ )
+
+
+class AsyncLogsResourceWithRawResponse:
+ def __init__(self, logs: AsyncLogsResource) -> None:
+ self._logs = logs
+
+ self.get = async_to_raw_response_wrapper(
+ logs.get,
+ )
+
+
+class LogsResourceWithStreamingResponse:
+ def __init__(self, logs: LogsResource) -> None:
+ self._logs = logs
+
+ self.get = to_streamed_response_wrapper(
+ logs.get,
+ )
+
+
+class AsyncLogsResourceWithStreamingResponse:
+ def __init__(self, logs: AsyncLogsResource) -> None:
+ self._logs = logs
+
+ self.get = async_to_streamed_response_wrapper(
+ logs.get,
+ )
diff --git a/src/cloudflare/types/ai_gateway/__init__.py b/src/cloudflare/types/ai_gateway/__init__.py
new file mode 100644
index 00000000000..e34365f10eb
--- /dev/null
+++ b/src/cloudflare/types/ai_gateway/__init__.py
@@ -0,0 +1,14 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from .log_get_params import LogGetParams as LogGetParams
+from .log_get_response import LogGetResponse as LogGetResponse
+from .ai_gateway_list_params import AIGatewayListParams as AIGatewayListParams
+from .ai_gateway_get_response import AIGatewayGetResponse as AIGatewayGetResponse
+from .ai_gateway_create_params import AIGatewayCreateParams as AIGatewayCreateParams
+from .ai_gateway_list_response import AIGatewayListResponse as AIGatewayListResponse
+from .ai_gateway_update_params import AIGatewayUpdateParams as AIGatewayUpdateParams
+from .ai_gateway_create_response import AIGatewayCreateResponse as AIGatewayCreateResponse
+from .ai_gateway_delete_response import AIGatewayDeleteResponse as AIGatewayDeleteResponse
+from .ai_gateway_update_response import AIGatewayUpdateResponse as AIGatewayUpdateResponse
diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_create_params.py b/src/cloudflare/types/ai_gateway/ai_gateway_create_params.py
new file mode 100644
index 00000000000..b285a5317c5
--- /dev/null
+++ b/src/cloudflare/types/ai_gateway/ai_gateway_create_params.py
@@ -0,0 +1,25 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing_extensions import Required, TypedDict
+
+__all__ = ["AIGatewayCreateParams"]
+
+
+class AIGatewayCreateParams(TypedDict, total=False):
+ cache_invalidate_on_update: Required[bool]
+
+ cache_ttl: Required[int]
+
+ collect_logs: Required[bool]
+
+ name: Required[str]
+
+ slug: Required[str]
+
+ rate_limiting_interval: int
+
+ rate_limiting_limit: int
+
+ rate_limiting_technique: str
diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_create_response.py b/src/cloudflare/types/ai_gateway/ai_gateway_create_response.py
new file mode 100644
index 00000000000..d64bb08d610
--- /dev/null
+++ b/src/cloudflare/types/ai_gateway/ai_gateway_create_response.py
@@ -0,0 +1,36 @@
+# 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__ = ["AIGatewayCreateResponse", "Task"]
+
+
+class Task(BaseModel):
+ id: str
+
+ cache_invalidate_on_update: bool
+
+ cache_ttl: int
+
+ collect_logs: bool
+
+ created_at: datetime
+
+ modified_at: datetime
+
+ name: str
+
+ slug: str
+
+ rate_limiting_interval: Optional[int] = None
+
+ rate_limiting_limit: Optional[int] = None
+
+ rate_limiting_technique: Optional[str] = None
+
+
+class AIGatewayCreateResponse(BaseModel):
+ task: Task
diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_delete_response.py b/src/cloudflare/types/ai_gateway/ai_gateway_delete_response.py
new file mode 100644
index 00000000000..ded796d9e59
--- /dev/null
+++ b/src/cloudflare/types/ai_gateway/ai_gateway_delete_response.py
@@ -0,0 +1,32 @@
+# 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__ = ["AIGatewayDeleteResponse"]
+
+
+class AIGatewayDeleteResponse(BaseModel):
+ id: str
+
+ cache_invalidate_on_update: bool
+
+ cache_ttl: int
+
+ collect_logs: bool
+
+ created_at: datetime
+
+ modified_at: datetime
+
+ name: str
+
+ slug: str
+
+ rate_limiting_interval: Optional[int] = None
+
+ rate_limiting_limit: Optional[int] = None
+
+ rate_limiting_technique: Optional[str] = None
diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_get_response.py b/src/cloudflare/types/ai_gateway/ai_gateway_get_response.py
new file mode 100644
index 00000000000..e8a52224fee
--- /dev/null
+++ b/src/cloudflare/types/ai_gateway/ai_gateway_get_response.py
@@ -0,0 +1,32 @@
+# 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__ = ["AIGatewayGetResponse"]
+
+
+class AIGatewayGetResponse(BaseModel):
+ id: str
+
+ cache_invalidate_on_update: bool
+
+ cache_ttl: int
+
+ collect_logs: bool
+
+ created_at: datetime
+
+ modified_at: datetime
+
+ name: str
+
+ slug: str
+
+ rate_limiting_interval: Optional[int] = None
+
+ rate_limiting_limit: Optional[int] = None
+
+ rate_limiting_technique: Optional[str] = None
diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_list_params.py b/src/cloudflare/types/ai_gateway/ai_gateway_list_params.py
new file mode 100644
index 00000000000..f798abdc0e7
--- /dev/null
+++ b/src/cloudflare/types/ai_gateway/ai_gateway_list_params.py
@@ -0,0 +1,18 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing_extensions import TypedDict
+
+__all__ = ["AIGatewayListParams"]
+
+
+class AIGatewayListParams(TypedDict, total=False):
+ id: str
+
+ order_by: str
+ """Order By Column Name"""
+
+ page: int
+
+ per_page: int
diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_list_response.py b/src/cloudflare/types/ai_gateway/ai_gateway_list_response.py
new file mode 100644
index 00000000000..701d72dd550
--- /dev/null
+++ b/src/cloudflare/types/ai_gateway/ai_gateway_list_response.py
@@ -0,0 +1,32 @@
+# 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__ = ["AIGatewayListResponse"]
+
+
+class AIGatewayListResponse(BaseModel):
+ id: str
+
+ cache_invalidate_on_update: bool
+
+ cache_ttl: int
+
+ collect_logs: bool
+
+ created_at: datetime
+
+ modified_at: datetime
+
+ name: str
+
+ slug: str
+
+ rate_limiting_interval: Optional[int] = None
+
+ rate_limiting_limit: Optional[int] = None
+
+ rate_limiting_technique: Optional[str] = None
diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_update_params.py b/src/cloudflare/types/ai_gateway/ai_gateway_update_params.py
new file mode 100644
index 00000000000..817d534c65f
--- /dev/null
+++ b/src/cloudflare/types/ai_gateway/ai_gateway_update_params.py
@@ -0,0 +1,27 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing_extensions import Required, TypedDict
+
+__all__ = ["AIGatewayUpdateParams"]
+
+
+class AIGatewayUpdateParams(TypedDict, total=False):
+ account_tag: Required[str]
+
+ cache_invalidate_on_update: Required[bool]
+
+ cache_ttl: Required[int]
+
+ collect_logs: Required[bool]
+
+ name: Required[str]
+
+ slug: Required[str]
+
+ rate_limiting_interval: int
+
+ rate_limiting_limit: int
+
+ rate_limiting_technique: str
diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_update_response.py b/src/cloudflare/types/ai_gateway/ai_gateway_update_response.py
new file mode 100644
index 00000000000..89e6238af2d
--- /dev/null
+++ b/src/cloudflare/types/ai_gateway/ai_gateway_update_response.py
@@ -0,0 +1,32 @@
+# 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__ = ["AIGatewayUpdateResponse"]
+
+
+class AIGatewayUpdateResponse(BaseModel):
+ id: str
+
+ cache_invalidate_on_update: bool
+
+ cache_ttl: int
+
+ collect_logs: bool
+
+ created_at: datetime
+
+ modified_at: datetime
+
+ name: str
+
+ slug: str
+
+ rate_limiting_interval: Optional[int] = None
+
+ rate_limiting_limit: Optional[int] = None
+
+ rate_limiting_technique: Optional[str] = None
diff --git a/src/cloudflare/types/ai_gateway/log_get_params.py b/src/cloudflare/types/ai_gateway/log_get_params.py
new file mode 100644
index 00000000000..f13afa638f6
--- /dev/null
+++ b/src/cloudflare/types/ai_gateway/log_get_params.py
@@ -0,0 +1,33 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing import Union
+from datetime import datetime
+from typing_extensions import Literal, Required, Annotated, TypedDict
+
+from ..._utils import PropertyInfo
+
+__all__ = ["LogGetParams"]
+
+
+class LogGetParams(TypedDict, total=False):
+ account_tag: Required[str]
+
+ cached: bool
+
+ direction: Literal["asc", "desc"]
+
+ end_date: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")]
+
+ order_by: Literal["created_at", "provider"]
+
+ page: int
+
+ per_page: int
+
+ search: str
+
+ start_date: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")]
+
+ success: bool
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..052d5d9d921
--- /dev/null
+++ b/src/cloudflare/types/ai_gateway/log_get_response.py
@@ -0,0 +1,37 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from typing import List
+from datetime import datetime
+
+from ..._models import BaseModel
+
+__all__ = ["LogGetResponse", "LogGetResponseItem"]
+
+
+class LogGetResponseItem(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
+
+
+LogGetResponse = List[LogGetResponseItem]
diff --git a/tests/api_resources/ai_gateway/__init__.py b/tests/api_resources/ai_gateway/__init__.py
new file mode 100644
index 00000000000..fd8019a9a1a
--- /dev/null
+++ b/tests/api_resources/ai_gateway/__init__.py
@@ -0,0 +1 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
diff --git a/tests/api_resources/ai_gateway/test_logs.py b/tests/api_resources/ai_gateway/test_logs.py
new file mode 100644
index 00000000000..c55b2e3f78a
--- /dev/null
+++ b/tests/api_resources/ai_gateway/test_logs.py
@@ -0,0 +1,153 @@
+# 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
+from cloudflare._utils import parse_datetime
+from cloudflare.types.ai_gateway import LogGetResponse
+
+base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
+
+
+class TestLogs:
+ parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
+
+ @parametrize
+ def test_method_get(self, client: Cloudflare) -> None:
+ log = client.ai_gateway.logs.get(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ account_tag="0d37909e38d3e99c29fa2cd343ac421a",
+ )
+ assert_matches_type(LogGetResponse, log, path=["response"])
+
+ @parametrize
+ def test_method_get_with_all_params(self, client: Cloudflare) -> None:
+ log = client.ai_gateway.logs.get(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ account_tag="0d37909e38d3e99c29fa2cd343ac421a",
+ cached=True,
+ direction="asc",
+ end_date=parse_datetime("2019-12-27T18:11:19.117Z"),
+ order_by="created_at",
+ page=1,
+ per_page=5,
+ search="string",
+ start_date=parse_datetime("2019-12-27T18:11:19.117Z"),
+ success=True,
+ )
+ 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(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ account_tag="0d37909e38d3e99c29fa2cd343ac421a",
+ )
+
+ 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(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ account_tag="0d37909e38d3e99c29fa2cd343ac421a",
+ ) 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_tag` but received ''"):
+ client.ai_gateway.logs.with_raw_response.get(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ account_tag="",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
+ client.ai_gateway.logs.with_raw_response.get(
+ "",
+ account_tag="0d37909e38d3e99c29fa2cd343ac421a",
+ )
+
+
+class TestAsyncLogs:
+ parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
+
+ @parametrize
+ async def test_method_get(self, async_client: AsyncCloudflare) -> None:
+ log = await async_client.ai_gateway.logs.get(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ account_tag="0d37909e38d3e99c29fa2cd343ac421a",
+ )
+ assert_matches_type(LogGetResponse, log, path=["response"])
+
+ @parametrize
+ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None:
+ log = await async_client.ai_gateway.logs.get(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ account_tag="0d37909e38d3e99c29fa2cd343ac421a",
+ cached=True,
+ direction="asc",
+ end_date=parse_datetime("2019-12-27T18:11:19.117Z"),
+ order_by="created_at",
+ page=1,
+ per_page=5,
+ search="string",
+ start_date=parse_datetime("2019-12-27T18:11:19.117Z"),
+ success=True,
+ )
+ 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(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ account_tag="0d37909e38d3e99c29fa2cd343ac421a",
+ )
+
+ 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(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ account_tag="0d37909e38d3e99c29fa2cd343ac421a",
+ ) 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_tag` but received ''"):
+ await async_client.ai_gateway.logs.with_raw_response.get(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ account_tag="",
+ )
+
+ 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(
+ "",
+ account_tag="0d37909e38d3e99c29fa2cd343ac421a",
+ )
diff --git a/tests/api_resources/test_ai_gateway.py b/tests/api_resources/test_ai_gateway.py
new file mode 100644
index 00000000000..a288f8db897
--- /dev/null
+++ b/tests/api_resources/test_ai_gateway.py
@@ -0,0 +1,643 @@
+# 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
+from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray
+from cloudflare.types.ai_gateway import (
+ AIGatewayGetResponse,
+ AIGatewayListResponse,
+ AIGatewayCreateResponse,
+ AIGatewayDeleteResponse,
+ AIGatewayUpdateResponse,
+)
+
+base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
+
+
+class TestAIGateway:
+ parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
+
+ @parametrize
+ def test_method_create(self, client: Cloudflare) -> None:
+ ai_gateway = client.ai_gateway.create(
+ "0d37909e38d3e99c29fa2cd343ac421a",
+ cache_invalidate_on_update=True,
+ cache_ttl=0,
+ collect_logs=True,
+ name="string",
+ slug="string",
+ )
+ assert_matches_type(AIGatewayCreateResponse, ai_gateway, path=["response"])
+
+ @parametrize
+ def test_method_create_with_all_params(self, client: Cloudflare) -> None:
+ ai_gateway = client.ai_gateway.create(
+ "0d37909e38d3e99c29fa2cd343ac421a",
+ cache_invalidate_on_update=True,
+ cache_ttl=0,
+ collect_logs=True,
+ name="string",
+ slug="string",
+ rate_limiting_interval=0,
+ rate_limiting_limit=0,
+ rate_limiting_technique="string",
+ )
+ assert_matches_type(AIGatewayCreateResponse, ai_gateway, path=["response"])
+
+ @parametrize
+ def test_raw_response_create(self, client: Cloudflare) -> None:
+ response = client.ai_gateway.with_raw_response.create(
+ "0d37909e38d3e99c29fa2cd343ac421a",
+ cache_invalidate_on_update=True,
+ cache_ttl=0,
+ collect_logs=True,
+ name="string",
+ slug="string",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ ai_gateway = response.parse()
+ assert_matches_type(AIGatewayCreateResponse, ai_gateway, path=["response"])
+
+ @parametrize
+ def test_streaming_response_create(self, client: Cloudflare) -> None:
+ with client.ai_gateway.with_streaming_response.create(
+ "0d37909e38d3e99c29fa2cd343ac421a",
+ cache_invalidate_on_update=True,
+ cache_ttl=0,
+ collect_logs=True,
+ name="string",
+ slug="string",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ ai_gateway = response.parse()
+ assert_matches_type(AIGatewayCreateResponse, ai_gateway, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ def test_path_params_create(self, client: Cloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_tag` but received ''"):
+ client.ai_gateway.with_raw_response.create(
+ "",
+ cache_invalidate_on_update=True,
+ cache_ttl=0,
+ collect_logs=True,
+ name="string",
+ slug="string",
+ )
+
+ @parametrize
+ def test_method_update(self, client: Cloudflare) -> None:
+ ai_gateway = client.ai_gateway.update(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ account_tag="0d37909e38d3e99c29fa2cd343ac421a",
+ cache_invalidate_on_update=True,
+ cache_ttl=0,
+ collect_logs=True,
+ name="string",
+ slug="string",
+ )
+ assert_matches_type(AIGatewayUpdateResponse, ai_gateway, path=["response"])
+
+ @parametrize
+ def test_method_update_with_all_params(self, client: Cloudflare) -> None:
+ ai_gateway = client.ai_gateway.update(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ account_tag="0d37909e38d3e99c29fa2cd343ac421a",
+ cache_invalidate_on_update=True,
+ cache_ttl=0,
+ collect_logs=True,
+ name="string",
+ slug="string",
+ rate_limiting_interval=0,
+ rate_limiting_limit=0,
+ rate_limiting_technique="string",
+ )
+ assert_matches_type(AIGatewayUpdateResponse, ai_gateway, path=["response"])
+
+ @parametrize
+ def test_raw_response_update(self, client: Cloudflare) -> None:
+ response = client.ai_gateway.with_raw_response.update(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ account_tag="0d37909e38d3e99c29fa2cd343ac421a",
+ cache_invalidate_on_update=True,
+ cache_ttl=0,
+ collect_logs=True,
+ name="string",
+ slug="string",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ ai_gateway = response.parse()
+ assert_matches_type(AIGatewayUpdateResponse, ai_gateway, path=["response"])
+
+ @parametrize
+ def test_streaming_response_update(self, client: Cloudflare) -> None:
+ with client.ai_gateway.with_streaming_response.update(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ account_tag="0d37909e38d3e99c29fa2cd343ac421a",
+ cache_invalidate_on_update=True,
+ cache_ttl=0,
+ collect_logs=True,
+ name="string",
+ slug="string",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ ai_gateway = response.parse()
+ assert_matches_type(AIGatewayUpdateResponse, ai_gateway, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ def test_path_params_update(self, client: Cloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_tag` but received ''"):
+ client.ai_gateway.with_raw_response.update(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ account_tag="",
+ cache_invalidate_on_update=True,
+ cache_ttl=0,
+ collect_logs=True,
+ name="string",
+ slug="string",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
+ client.ai_gateway.with_raw_response.update(
+ "",
+ account_tag="0d37909e38d3e99c29fa2cd343ac421a",
+ cache_invalidate_on_update=True,
+ cache_ttl=0,
+ collect_logs=True,
+ name="string",
+ slug="string",
+ )
+
+ @parametrize
+ def test_method_list(self, client: Cloudflare) -> None:
+ ai_gateway = client.ai_gateway.list(
+ "0d37909e38d3e99c29fa2cd343ac421a",
+ )
+ assert_matches_type(SyncV4PagePaginationArray[AIGatewayListResponse], ai_gateway, path=["response"])
+
+ @parametrize
+ def test_method_list_with_all_params(self, client: Cloudflare) -> None:
+ ai_gateway = client.ai_gateway.list(
+ "0d37909e38d3e99c29fa2cd343ac421a",
+ id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ order_by="string",
+ page=1,
+ per_page=5,
+ )
+ assert_matches_type(SyncV4PagePaginationArray[AIGatewayListResponse], ai_gateway, path=["response"])
+
+ @parametrize
+ def test_raw_response_list(self, client: Cloudflare) -> None:
+ response = client.ai_gateway.with_raw_response.list(
+ "0d37909e38d3e99c29fa2cd343ac421a",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ ai_gateway = response.parse()
+ assert_matches_type(SyncV4PagePaginationArray[AIGatewayListResponse], ai_gateway, path=["response"])
+
+ @parametrize
+ def test_streaming_response_list(self, client: Cloudflare) -> None:
+ with client.ai_gateway.with_streaming_response.list(
+ "0d37909e38d3e99c29fa2cd343ac421a",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ ai_gateway = response.parse()
+ assert_matches_type(SyncV4PagePaginationArray[AIGatewayListResponse], ai_gateway, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ def test_path_params_list(self, client: Cloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_tag` but received ''"):
+ client.ai_gateway.with_raw_response.list(
+ "",
+ )
+
+ @parametrize
+ def test_method_delete(self, client: Cloudflare) -> None:
+ ai_gateway = client.ai_gateway.delete(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ account_tag="0d37909e38d3e99c29fa2cd343ac421a",
+ )
+ assert_matches_type(AIGatewayDeleteResponse, ai_gateway, path=["response"])
+
+ @parametrize
+ def test_raw_response_delete(self, client: Cloudflare) -> None:
+ response = client.ai_gateway.with_raw_response.delete(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ account_tag="0d37909e38d3e99c29fa2cd343ac421a",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ ai_gateway = response.parse()
+ assert_matches_type(AIGatewayDeleteResponse, ai_gateway, path=["response"])
+
+ @parametrize
+ def test_streaming_response_delete(self, client: Cloudflare) -> None:
+ with client.ai_gateway.with_streaming_response.delete(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ account_tag="0d37909e38d3e99c29fa2cd343ac421a",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ ai_gateway = response.parse()
+ assert_matches_type(AIGatewayDeleteResponse, ai_gateway, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ def test_path_params_delete(self, client: Cloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_tag` but received ''"):
+ client.ai_gateway.with_raw_response.delete(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ account_tag="",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
+ client.ai_gateway.with_raw_response.delete(
+ "",
+ account_tag="0d37909e38d3e99c29fa2cd343ac421a",
+ )
+
+ @parametrize
+ def test_method_get(self, client: Cloudflare) -> None:
+ ai_gateway = client.ai_gateway.get(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ account_tag="0d37909e38d3e99c29fa2cd343ac421a",
+ )
+ assert_matches_type(AIGatewayGetResponse, ai_gateway, path=["response"])
+
+ @parametrize
+ def test_raw_response_get(self, client: Cloudflare) -> None:
+ response = client.ai_gateway.with_raw_response.get(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ account_tag="0d37909e38d3e99c29fa2cd343ac421a",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ ai_gateway = response.parse()
+ assert_matches_type(AIGatewayGetResponse, ai_gateway, path=["response"])
+
+ @parametrize
+ def test_streaming_response_get(self, client: Cloudflare) -> None:
+ with client.ai_gateway.with_streaming_response.get(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ account_tag="0d37909e38d3e99c29fa2cd343ac421a",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ ai_gateway = response.parse()
+ assert_matches_type(AIGatewayGetResponse, ai_gateway, 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_tag` but received ''"):
+ client.ai_gateway.with_raw_response.get(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ account_tag="",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
+ client.ai_gateway.with_raw_response.get(
+ "",
+ account_tag="0d37909e38d3e99c29fa2cd343ac421a",
+ )
+
+
+class TestAsyncAIGateway:
+ parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
+
+ @parametrize
+ async def test_method_create(self, async_client: AsyncCloudflare) -> None:
+ ai_gateway = await async_client.ai_gateway.create(
+ "0d37909e38d3e99c29fa2cd343ac421a",
+ cache_invalidate_on_update=True,
+ cache_ttl=0,
+ collect_logs=True,
+ name="string",
+ slug="string",
+ )
+ assert_matches_type(AIGatewayCreateResponse, ai_gateway, path=["response"])
+
+ @parametrize
+ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None:
+ ai_gateway = await async_client.ai_gateway.create(
+ "0d37909e38d3e99c29fa2cd343ac421a",
+ cache_invalidate_on_update=True,
+ cache_ttl=0,
+ collect_logs=True,
+ name="string",
+ slug="string",
+ rate_limiting_interval=0,
+ rate_limiting_limit=0,
+ rate_limiting_technique="string",
+ )
+ assert_matches_type(AIGatewayCreateResponse, ai_gateway, path=["response"])
+
+ @parametrize
+ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None:
+ response = await async_client.ai_gateway.with_raw_response.create(
+ "0d37909e38d3e99c29fa2cd343ac421a",
+ cache_invalidate_on_update=True,
+ cache_ttl=0,
+ collect_logs=True,
+ name="string",
+ slug="string",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ ai_gateway = await response.parse()
+ assert_matches_type(AIGatewayCreateResponse, ai_gateway, path=["response"])
+
+ @parametrize
+ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None:
+ async with async_client.ai_gateway.with_streaming_response.create(
+ "0d37909e38d3e99c29fa2cd343ac421a",
+ cache_invalidate_on_update=True,
+ cache_ttl=0,
+ collect_logs=True,
+ name="string",
+ slug="string",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ ai_gateway = await response.parse()
+ assert_matches_type(AIGatewayCreateResponse, ai_gateway, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_tag` but received ''"):
+ await async_client.ai_gateway.with_raw_response.create(
+ "",
+ cache_invalidate_on_update=True,
+ cache_ttl=0,
+ collect_logs=True,
+ name="string",
+ slug="string",
+ )
+
+ @parametrize
+ async def test_method_update(self, async_client: AsyncCloudflare) -> None:
+ ai_gateway = await async_client.ai_gateway.update(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ account_tag="0d37909e38d3e99c29fa2cd343ac421a",
+ cache_invalidate_on_update=True,
+ cache_ttl=0,
+ collect_logs=True,
+ name="string",
+ slug="string",
+ )
+ assert_matches_type(AIGatewayUpdateResponse, ai_gateway, path=["response"])
+
+ @parametrize
+ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None:
+ ai_gateway = await async_client.ai_gateway.update(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ account_tag="0d37909e38d3e99c29fa2cd343ac421a",
+ cache_invalidate_on_update=True,
+ cache_ttl=0,
+ collect_logs=True,
+ name="string",
+ slug="string",
+ rate_limiting_interval=0,
+ rate_limiting_limit=0,
+ rate_limiting_technique="string",
+ )
+ assert_matches_type(AIGatewayUpdateResponse, ai_gateway, path=["response"])
+
+ @parametrize
+ async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None:
+ response = await async_client.ai_gateway.with_raw_response.update(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ account_tag="0d37909e38d3e99c29fa2cd343ac421a",
+ cache_invalidate_on_update=True,
+ cache_ttl=0,
+ collect_logs=True,
+ name="string",
+ slug="string",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ ai_gateway = await response.parse()
+ assert_matches_type(AIGatewayUpdateResponse, ai_gateway, path=["response"])
+
+ @parametrize
+ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None:
+ async with async_client.ai_gateway.with_streaming_response.update(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ account_tag="0d37909e38d3e99c29fa2cd343ac421a",
+ cache_invalidate_on_update=True,
+ cache_ttl=0,
+ collect_logs=True,
+ name="string",
+ slug="string",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ ai_gateway = await response.parse()
+ assert_matches_type(AIGatewayUpdateResponse, ai_gateway, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_tag` but received ''"):
+ await async_client.ai_gateway.with_raw_response.update(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ account_tag="",
+ cache_invalidate_on_update=True,
+ cache_ttl=0,
+ collect_logs=True,
+ name="string",
+ slug="string",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
+ await async_client.ai_gateway.with_raw_response.update(
+ "",
+ account_tag="0d37909e38d3e99c29fa2cd343ac421a",
+ cache_invalidate_on_update=True,
+ cache_ttl=0,
+ collect_logs=True,
+ name="string",
+ slug="string",
+ )
+
+ @parametrize
+ async def test_method_list(self, async_client: AsyncCloudflare) -> None:
+ ai_gateway = await async_client.ai_gateway.list(
+ "0d37909e38d3e99c29fa2cd343ac421a",
+ )
+ assert_matches_type(AsyncV4PagePaginationArray[AIGatewayListResponse], ai_gateway, path=["response"])
+
+ @parametrize
+ async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None:
+ ai_gateway = await async_client.ai_gateway.list(
+ "0d37909e38d3e99c29fa2cd343ac421a",
+ id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ order_by="string",
+ page=1,
+ per_page=5,
+ )
+ assert_matches_type(AsyncV4PagePaginationArray[AIGatewayListResponse], ai_gateway, path=["response"])
+
+ @parametrize
+ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None:
+ response = await async_client.ai_gateway.with_raw_response.list(
+ "0d37909e38d3e99c29fa2cd343ac421a",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ ai_gateway = await response.parse()
+ assert_matches_type(AsyncV4PagePaginationArray[AIGatewayListResponse], ai_gateway, path=["response"])
+
+ @parametrize
+ async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None:
+ async with async_client.ai_gateway.with_streaming_response.list(
+ "0d37909e38d3e99c29fa2cd343ac421a",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ ai_gateway = await response.parse()
+ assert_matches_type(AsyncV4PagePaginationArray[AIGatewayListResponse], ai_gateway, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_tag` but received ''"):
+ await async_client.ai_gateway.with_raw_response.list(
+ "",
+ )
+
+ @parametrize
+ async def test_method_delete(self, async_client: AsyncCloudflare) -> None:
+ ai_gateway = await async_client.ai_gateway.delete(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ account_tag="0d37909e38d3e99c29fa2cd343ac421a",
+ )
+ assert_matches_type(AIGatewayDeleteResponse, ai_gateway, path=["response"])
+
+ @parametrize
+ async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None:
+ response = await async_client.ai_gateway.with_raw_response.delete(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ account_tag="0d37909e38d3e99c29fa2cd343ac421a",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ ai_gateway = await response.parse()
+ assert_matches_type(AIGatewayDeleteResponse, ai_gateway, path=["response"])
+
+ @parametrize
+ async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None:
+ async with async_client.ai_gateway.with_streaming_response.delete(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ account_tag="0d37909e38d3e99c29fa2cd343ac421a",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ ai_gateway = await response.parse()
+ assert_matches_type(AIGatewayDeleteResponse, ai_gateway, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_tag` but received ''"):
+ await async_client.ai_gateway.with_raw_response.delete(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ account_tag="",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
+ await async_client.ai_gateway.with_raw_response.delete(
+ "",
+ account_tag="0d37909e38d3e99c29fa2cd343ac421a",
+ )
+
+ @parametrize
+ async def test_method_get(self, async_client: AsyncCloudflare) -> None:
+ ai_gateway = await async_client.ai_gateway.get(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ account_tag="0d37909e38d3e99c29fa2cd343ac421a",
+ )
+ assert_matches_type(AIGatewayGetResponse, ai_gateway, path=["response"])
+
+ @parametrize
+ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None:
+ response = await async_client.ai_gateway.with_raw_response.get(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ account_tag="0d37909e38d3e99c29fa2cd343ac421a",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ ai_gateway = await response.parse()
+ assert_matches_type(AIGatewayGetResponse, ai_gateway, path=["response"])
+
+ @parametrize
+ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None:
+ async with async_client.ai_gateway.with_streaming_response.get(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ account_tag="0d37909e38d3e99c29fa2cd343ac421a",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ ai_gateway = await response.parse()
+ assert_matches_type(AIGatewayGetResponse, ai_gateway, 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_tag` but received ''"):
+ await async_client.ai_gateway.with_raw_response.get(
+ "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
+ account_tag="",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
+ await async_client.ai_gateway.with_raw_response.get(
+ "",
+ account_tag="0d37909e38d3e99c29fa2cd343ac421a",
+ )