From 6f642627ebf32e1c9ab48e202dc4ce4c99ed7059 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 6 May 2024 10:34:16 +0000 Subject: [PATCH] feat(api): OpenAPI spec update via Stainless API (#458) --- .stats.yml | 4 +- api.md | 62 +- 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 ------ .../cloudforce_one/requests/message.py | 76 +- .../cloudforce_one/requests/priority.py | 88 +-- .../cloudforce_one/requests/requests.py | 112 ++- src/cloudflare/resources/intel/whois.py | 14 +- src/cloudflare/types/ai_gateway/__init__.py | 11 - .../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 - .../cloudforce_one/request_delete_response.py | 15 +- .../requests/message_delete_response.py | 15 +- .../requests/priority_delete_response.py | 15 +- tests/api_resources/ai_gateway/__init__.py | 1 - tests/api_resources/ai_gateway/test_logs.py | 153 ---- .../cloudforce_one/requests/test_message.py | 50 +- .../cloudforce_one/requests/test_priority.py | 50 +- .../cloudforce_one/test_requests.py | 82 +-- tests/api_resources/intel/test_whois.py | 18 +- tests/api_resources/test_ai_gateway.py | 643 ----------------- 32 files changed, 273 insertions(+), 2381 deletions(-) delete mode 100644 src/cloudflare/resources/ai_gateway/__init__.py delete mode 100644 src/cloudflare/resources/ai_gateway/ai_gateway.py delete mode 100644 src/cloudflare/resources/ai_gateway/logs.py delete mode 100644 src/cloudflare/types/ai_gateway/ai_gateway_create_params.py delete mode 100644 src/cloudflare/types/ai_gateway/ai_gateway_create_response.py delete mode 100644 src/cloudflare/types/ai_gateway/ai_gateway_delete_response.py delete mode 100644 src/cloudflare/types/ai_gateway/ai_gateway_get_response.py delete mode 100644 src/cloudflare/types/ai_gateway/ai_gateway_list_params.py delete mode 100644 src/cloudflare/types/ai_gateway/ai_gateway_list_response.py delete mode 100644 src/cloudflare/types/ai_gateway/ai_gateway_update_params.py delete mode 100644 src/cloudflare/types/ai_gateway/ai_gateway_update_response.py delete mode 100644 src/cloudflare/types/ai_gateway/log_get_params.py delete mode 100644 src/cloudflare/types/ai_gateway/log_get_response.py delete mode 100644 tests/api_resources/ai_gateway/__init__.py delete mode 100644 tests/api_resources/ai_gateway/test_logs.py delete mode 100644 tests/api_resources/test_ai_gateway.py diff --git a/.stats.yml b/.stats.yml index 0a8ec994c15..48dcd917500 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 1275 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e0f14b3972aa9a5ae69697fce41ee4de0f7c39ead64f2b6c27434037717a30e5.yml +configured_endpoints: 1269 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-66b404214530cc73c44f34f297dad6bc8da0645b63e61d9d4fcbeb301e127e65.yml diff --git a/api.md b/api.md index 71c8bd4ea95..6a46abc2cbe 100644 --- a/api.md +++ b/api.md @@ -3636,7 +3636,7 @@ from cloudflare.types.intel import Whois, WhoisGetResponse Methods: -- client.intel.whois.get(\*, account_id, \*\*params) -> WhoisGetResponse +- client.intel.whois.get(\*, account_id, \*\*params) -> Optional ## IndicatorFeeds @@ -7355,14 +7355,14 @@ from cloudflare.types.cloudforce_one import ( Methods: -- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Item -- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.update(request_identifier, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.list(account_identifier, \*\*params) -> SyncV4PagePaginationArray[ListItem] - client.cloudforce_one.requests.delete(request_identifier, \*, account_identifier) -> RequestDeleteResponse -- client.cloudforce_one.requests.constants(account_identifier) -> RequestConstants -- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Item -- client.cloudforce_one.requests.quota(account_identifier) -> Quota -- client.cloudforce_one.requests.types(account_identifier) -> RequestTypes +- client.cloudforce_one.requests.constants(account_identifier) -> Optional +- client.cloudforce_one.requests.get(request_identifier, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.quota(account_identifier) -> Optional +- client.cloudforce_one.requests.types(account_identifier) -> Optional ### Message @@ -7378,10 +7378,10 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Message -- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Message +- client.cloudforce_one.requests.message.create(request_identifier, \*, account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.message.update(message_identifer, \*, account_identifier, request_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.message.delete(message_identifer, \*, account_identifier, request_identifier) -> MessageDeleteResponse -- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> MessageGetResponse +- client.cloudforce_one.requests.message.get(request_identifier, \*, account_identifier, \*\*params) -> Optional ### Priority @@ -7398,11 +7398,11 @@ from cloudflare.types.cloudforce_one.requests import ( Methods: -- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Priority -- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Item +- client.cloudforce_one.requests.priority.create(account_identifier, \*\*params) -> Optional +- client.cloudforce_one.requests.priority.update(priority_identifer, \*, account_identifier, \*\*params) -> Optional - client.cloudforce_one.requests.priority.delete(priority_identifer, \*, account_identifier) -> PriorityDeleteResponse -- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Item -- client.cloudforce_one.requests.priority.quota(account_identifier) -> Quota +- client.cloudforce_one.requests.priority.get(priority_identifer, \*, account_identifier) -> Optional +- client.cloudforce_one.requests.priority.quota(account_identifier) -> Optional # EventNotifications @@ -7435,37 +7435,3 @@ 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 529638ece6d..41a4fcfac22 100644 --- a/src/cloudflare/_client.py +++ b/src/cloudflare/_client.py @@ -128,7 +128,6 @@ 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 @@ -285,7 +284,6 @@ 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) @@ -545,7 +543,6 @@ 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 @@ -702,7 +699,6 @@ 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) @@ -973,7 +969,6 @@ 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: @@ -1073,7 +1068,6 @@ 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: @@ -1173,7 +1167,6 @@ 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: @@ -1281,7 +1274,6 @@ 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 4d7acbc7a4c..e4d0f926f5d 100644 --- a/src/cloudflare/resources/__init__.py +++ b/src/cloudflare/resources/__init__.py @@ -336,14 +336,6 @@ AddressingResourceWithStreamingResponse, AsyncAddressingResourceWithStreamingResponse, ) -from .ai_gateway import ( - AIGatewayResource, - AsyncAIGatewayResource, - AIGatewayResourceWithRawResponse, - AsyncAIGatewayResourceWithRawResponse, - AIGatewayResourceWithStreamingResponse, - AsyncAIGatewayResourceWithStreamingResponse, -) from .audit_logs import ( AuditLogsResource, AsyncAuditLogsResource, @@ -1144,10 +1136,4 @@ "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 deleted file mode 100644 index 95883733129..00000000000 --- a/src/cloudflare/resources/ai_gateway/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -# 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 deleted file mode 100644 index 0c89bf1dbd6..00000000000 --- a/src/cloudflare/resources/ai_gateway/ai_gateway.py +++ /dev/null @@ -1,673 +0,0 @@ -# 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 deleted file mode 100644 index bcf3db29492..00000000000 --- a/src/cloudflare/resources/ai_gateway/logs.py +++ /dev/null @@ -1,213 +0,0 @@ -# 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/resources/cloudforce_one/requests/message.py b/src/cloudflare/resources/cloudforce_one/requests/message.py index eaea1a987b6..177e2c5b099 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/message.py +++ b/src/cloudflare/resources/cloudforce_one/requests/message.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -54,7 +54,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -87,9 +87,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def update( @@ -109,7 +109,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -157,9 +157,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) def delete( @@ -195,21 +195,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) def get( @@ -229,7 +220,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -280,9 +271,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) @@ -307,7 +298,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -340,9 +331,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def update( @@ -362,7 +353,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Message: + ) -> Optional[Message]: """ Update a Request Message @@ -410,9 +401,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Message]._unwrapper, + post_parser=ResultWrapper[Optional[Message]]._unwrapper, ), - cast_to=cast(Type[Message], ResultWrapper[Message]), + cast_to=cast(Type[Optional[Message]], ResultWrapper[Message]), ) async def delete( @@ -448,21 +439,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - MessageDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[MessageDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[MessageDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}/message/{message_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=MessageDeleteResponse, ) async def get( @@ -482,7 +464,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> MessageGetResponse: + ) -> Optional[MessageGetResponse]: """ List Request Messages @@ -533,9 +515,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[MessageGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[MessageGetResponse]]._unwrapper, ), - cast_to=cast(Type[MessageGetResponse], ResultWrapper[MessageGetResponse]), + cast_to=cast(Type[Optional[MessageGetResponse]], ResultWrapper[MessageGetResponse]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/priority.py b/src/cloudflare/resources/cloudforce_one/requests/priority.py index 0f1d6795a40..243e43f789b 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/priority.py +++ b/src/cloudflare/resources/cloudforce_one/requests/priority.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, List, Type, cast +from typing import List, Type, Optional, cast from typing_extensions import Literal import httpx @@ -57,7 +57,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -98,9 +98,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) def update( @@ -118,7 +118,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -163,9 +163,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def delete( @@ -200,21 +200,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) def get( @@ -228,7 +219,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -256,9 +247,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -271,7 +262,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -295,9 +286,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) @@ -324,7 +315,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Priority: + ) -> Optional[Priority]: """ Create a New Priority Requirement @@ -365,9 +356,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Priority]._unwrapper, + post_parser=ResultWrapper[Optional[Priority]]._unwrapper, ), - cast_to=cast(Type[Priority], ResultWrapper[Priority]), + cast_to=cast(Type[Optional[Priority]], ResultWrapper[Priority]), ) async def update( @@ -385,7 +376,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Update a Priority Intelligence Requirement @@ -430,9 +421,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def delete( @@ -467,21 +458,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not priority_identifer: raise ValueError(f"Expected a non-empty value for `priority_identifer` but received {priority_identifer!r}") - return cast( - PriorityDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[PriorityDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[PriorityDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/priority/{priority_identifer}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=PriorityDeleteResponse, ) async def get( @@ -495,7 +477,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Priority Intelligence Requirement @@ -523,9 +505,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -538,7 +520,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Priority Intelligence Requirement Quota @@ -562,9 +544,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) diff --git a/src/cloudflare/resources/cloudforce_one/requests/requests.py b/src/cloudflare/resources/cloudforce_one/requests/requests.py index 61a739aaa7c..267e04595d6 100644 --- a/src/cloudflare/resources/cloudforce_one/requests/requests.py +++ b/src/cloudflare/resources/cloudforce_one/requests/requests.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Any, Type, Union, cast +from typing import Type, Union, Optional, cast from datetime import datetime from typing_extensions import Literal @@ -86,7 +86,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -132,9 +132,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def update( @@ -153,7 +153,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -204,9 +204,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -323,21 +323,12 @@ def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) def constants( @@ -350,7 +341,7 @@ def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -374,9 +365,9 @@ def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) def get( @@ -390,7 +381,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -418,9 +409,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def quota( @@ -433,7 +424,7 @@ def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -457,9 +448,9 @@ def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) def types( @@ -472,7 +463,7 @@ def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -496,9 +487,9 @@ def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) @@ -534,7 +525,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Creating a request adds the request into the Cloudforce One queue for analysis. In addition to the content, a short title, type, priority, and releasability @@ -580,9 +571,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def update( @@ -601,7 +592,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """Updating a request alters the request in the Cloudforce One queue. This API may @@ -652,9 +643,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) def list( @@ -771,21 +762,12 @@ async def delete( raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") if not request_identifier: raise ValueError(f"Expected a non-empty value for `request_identifier` but received {request_identifier!r}") - return cast( - RequestDeleteResponse, - await self._delete( - f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RequestDeleteResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[RequestDeleteResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._delete( + f"/accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=RequestDeleteResponse, ) async def constants( @@ -798,7 +780,7 @@ async def constants( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestConstants: + ) -> Optional[RequestConstants]: """ Get Request Priority, Status, and TLP constants @@ -822,9 +804,9 @@ async def constants( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestConstants]._unwrapper, + post_parser=ResultWrapper[Optional[RequestConstants]]._unwrapper, ), - cast_to=cast(Type[RequestConstants], ResultWrapper[RequestConstants]), + cast_to=cast(Type[Optional[RequestConstants]], ResultWrapper[RequestConstants]), ) async def get( @@ -838,7 +820,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Item: + ) -> Optional[Item]: """ Get a Request @@ -866,9 +848,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Item]._unwrapper, + post_parser=ResultWrapper[Optional[Item]]._unwrapper, ), - cast_to=cast(Type[Item], ResultWrapper[Item]), + cast_to=cast(Type[Optional[Item]], ResultWrapper[Item]), ) async def quota( @@ -881,7 +863,7 @@ async def quota( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Quota: + ) -> Optional[Quota]: """ Get Request Quota @@ -905,9 +887,9 @@ async def quota( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Quota]._unwrapper, + post_parser=ResultWrapper[Optional[Quota]]._unwrapper, ), - cast_to=cast(Type[Quota], ResultWrapper[Quota]), + cast_to=cast(Type[Optional[Quota]], ResultWrapper[Quota]), ) async def types( @@ -920,7 +902,7 @@ async def types( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RequestTypes: + ) -> Optional[RequestTypes]: """ Get Request Types @@ -944,9 +926,9 @@ async def types( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[RequestTypes]._unwrapper, + post_parser=ResultWrapper[Optional[RequestTypes]]._unwrapper, ), - cast_to=cast(Type[RequestTypes], ResultWrapper[RequestTypes]), + cast_to=cast(Type[Optional[RequestTypes]], ResultWrapper[RequestTypes]), ) diff --git a/src/cloudflare/resources/intel/whois.py b/src/cloudflare/resources/intel/whois.py index 050da13d396..d8f2efe389c 100644 --- a/src/cloudflare/resources/intel/whois.py +++ b/src/cloudflare/resources/intel/whois.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, cast +from typing import Type, Optional, cast import httpx @@ -49,7 +49,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -74,9 +74,9 @@ def get( extra_body=extra_body, timeout=timeout, query=maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) @@ -100,7 +100,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> WhoisGetResponse: + ) -> Optional[WhoisGetResponse]: """ Get WHOIS Record @@ -125,9 +125,9 @@ async def get( extra_body=extra_body, timeout=timeout, query=await async_maybe_transform({"domain": domain}, whois_get_params.WhoisGetParams), - post_parser=ResultWrapper[WhoisGetResponse]._unwrapper, + post_parser=ResultWrapper[Optional[WhoisGetResponse]]._unwrapper, ), - cast_to=cast(Type[WhoisGetResponse], ResultWrapper[WhoisGetResponse]), + cast_to=cast(Type[Optional[WhoisGetResponse]], ResultWrapper[WhoisGetResponse]), ) diff --git a/src/cloudflare/types/ai_gateway/__init__.py b/src/cloudflare/types/ai_gateway/__init__.py index e34365f10eb..f8ee8b14b1c 100644 --- a/src/cloudflare/types/ai_gateway/__init__.py +++ b/src/cloudflare/types/ai_gateway/__init__.py @@ -1,14 +1,3 @@ # 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 deleted file mode 100644 index b285a5317c5..00000000000 --- a/src/cloudflare/types/ai_gateway/ai_gateway_create_params.py +++ /dev/null @@ -1,25 +0,0 @@ -# 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 deleted file mode 100644 index d64bb08d610..00000000000 --- a/src/cloudflare/types/ai_gateway/ai_gateway_create_response.py +++ /dev/null @@ -1,36 +0,0 @@ -# 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 deleted file mode 100644 index ded796d9e59..00000000000 --- a/src/cloudflare/types/ai_gateway/ai_gateway_delete_response.py +++ /dev/null @@ -1,32 +0,0 @@ -# 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 deleted file mode 100644 index e8a52224fee..00000000000 --- a/src/cloudflare/types/ai_gateway/ai_gateway_get_response.py +++ /dev/null @@ -1,32 +0,0 @@ -# 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 deleted file mode 100644 index f798abdc0e7..00000000000 --- a/src/cloudflare/types/ai_gateway/ai_gateway_list_params.py +++ /dev/null @@ -1,18 +0,0 @@ -# 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 deleted file mode 100644 index 701d72dd550..00000000000 --- a/src/cloudflare/types/ai_gateway/ai_gateway_list_response.py +++ /dev/null @@ -1,32 +0,0 @@ -# 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 deleted file mode 100644 index 817d534c65f..00000000000 --- a/src/cloudflare/types/ai_gateway/ai_gateway_update_params.py +++ /dev/null @@ -1,27 +0,0 @@ -# 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 deleted file mode 100644 index 89e6238af2d..00000000000 --- a/src/cloudflare/types/ai_gateway/ai_gateway_update_response.py +++ /dev/null @@ -1,32 +0,0 @@ -# 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 deleted file mode 100644 index f13afa638f6..00000000000 --- a/src/cloudflare/types/ai_gateway/log_get_params.py +++ /dev/null @@ -1,33 +0,0 @@ -# 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 deleted file mode 100644 index 052d5d9d921..00000000000 --- a/src/cloudflare/types/ai_gateway/log_get_response.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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/src/cloudflare/types/cloudforce_one/request_delete_response.py b/src/cloudflare/types/cloudforce_one/request_delete_response.py index f6dca1edb3f..b7ed5ffbe10 100644 --- a/src/cloudflare/types/cloudforce_one/request_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/request_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.response_info import ResponseInfo __all__ = ["RequestDeleteResponse"] -RequestDeleteResponse = Union[List[object], str, object] + +class RequestDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py index eaadbea2ab5..a0d45a64036 100644 --- a/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/message_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["MessageDeleteResponse"] -MessageDeleteResponse = Union[List[object], str, object] + +class MessageDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py index 60bd9aae8bd..ee172239bfe 100644 --- a/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py +++ b/src/cloudflare/types/cloudforce_one/requests/priority_delete_response.py @@ -1,7 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel +from ...shared.response_info import ResponseInfo __all__ = ["PriorityDeleteResponse"] -PriorityDeleteResponse = Union[List[object], str, object] + +class PriorityDeleteResponse(BaseModel): + errors: List[ResponseInfo] + + messages: List[ResponseInfo] + + success: Literal[True] + """Whether the API call was successful""" diff --git a/tests/api_resources/ai_gateway/__init__.py b/tests/api_resources/ai_gateway/__init__.py deleted file mode 100644 index fd8019a9a1a..00000000000 --- a/tests/api_resources/ai_gateway/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# 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 deleted file mode 100644 index c55b2e3f78a..00000000000 --- a/tests/api_resources/ai_gateway/test_logs.py +++ /dev/null @@ -1,153 +0,0 @@ -# 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/cloudforce_one/requests/test_message.py b/tests/api_resources/cloudforce_one/requests/test_message.py index cae9250892e..e804d3ab846 100644 --- a/tests/api_resources/cloudforce_one/requests/test_message.py +++ b/tests/api_resources/cloudforce_one/requests/test_message.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -28,7 +28,7 @@ def test_method_create(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -37,7 +37,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -49,7 +49,7 @@ def test_raw_response_create(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -61,7 +61,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -86,7 +86,7 @@ def test_method_update(self, client: Cloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -100,7 +100,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -113,7 +113,7 @@ def test_raw_response_update(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -126,7 +126,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -207,7 +207,7 @@ def test_method_get(self, client: Cloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -235,7 +235,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -249,7 +249,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -281,7 +281,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -290,7 +290,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_identifier="023e105f4ecef8ad9ca31a8372d0c353", content="Can you elaborate on the type of DoS that occurred?", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -302,7 +302,7 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -314,7 +314,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: account_identifier="023e105f4ecef8ad9ca31a8372d0c353", request_identifier="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -353,7 +353,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -366,7 +366,7 @@ async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -379,7 +379,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(Message, message, path=["response"]) + assert_matches_type(Optional[Message], message, path=["response"]) assert cast(Any, response.is_closed) is True @@ -460,7 +460,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: page=0, per_page=10, ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -474,7 +474,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - sort_by="created", sort_order="asc", ) - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -488,7 +488,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -502,7 +502,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" message = await response.parse() - assert_matches_type(MessageGetResponse, message, path=["response"]) + assert_matches_type(Optional[MessageGetResponse], message, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/requests/test_priority.py b/tests/api_resources/cloudforce_one/requests/test_priority.py index 46276ab9dcf..012e01b34cf 100644 --- a/tests/api_resources/cloudforce_one/requests/test_priority.py +++ b/tests/api_resources/cloudforce_one/requests/test_priority.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -30,7 +30,7 @@ def test_method_create(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -45,7 +45,7 @@ def test_raw_response_create(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -60,7 +60,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ def test_method_update(self, client: Cloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -101,7 +101,7 @@ def test_raw_response_update(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -117,7 +117,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -197,7 +197,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -209,7 +209,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -221,7 +221,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -244,7 +244,7 @@ def test_method_quota(self, client: Cloudflare) -> None: priority = client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -255,7 +255,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -266,7 +266,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -290,7 +290,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -305,7 +305,7 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -320,7 +320,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Priority, priority, path=["response"]) + assert_matches_type(Optional[Priority], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -345,7 +345,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: requirement="DoS attacks carried out by CVEs", tlp="clear", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -361,7 +361,7 @@ async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -377,7 +377,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -457,7 +457,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -469,7 +469,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -481,7 +481,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Item, priority, path=["response"]) + assert_matches_type(Optional[Item], priority, path=["response"]) assert cast(Any, response.is_closed) is True @@ -504,7 +504,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: priority = await async_client.cloudforce_one.requests.priority.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -515,7 +515,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -526,7 +526,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" priority = await response.parse() - assert_matches_type(Quota, priority, path=["response"]) + assert_matches_type(Optional[Quota], priority, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/cloudforce_one/test_requests.py b/tests/api_resources/cloudforce_one/test_requests.py index 327ae61c1bb..9e43e1a22b2 100644 --- a/tests/api_resources/cloudforce_one/test_requests.py +++ b/tests/api_resources/cloudforce_one/test_requests.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -31,7 +31,7 @@ def test_method_create(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -43,7 +43,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -54,7 +54,7 @@ def test_raw_response_create(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -65,7 +65,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ def test_method_update(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -95,7 +95,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -107,7 +107,7 @@ def test_raw_response_update(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -119,7 +119,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -253,7 +253,7 @@ def test_method_constants(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_raw_response_constants(self, client: Cloudflare) -> None: @@ -264,7 +264,7 @@ def test_raw_response_constants(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize def test_streaming_response_constants(self, client: Cloudflare) -> None: @@ -275,7 +275,7 @@ def test_streaming_response_constants(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -292,7 +292,7 @@ def test_method_get(self, client: Cloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -304,7 +304,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -316,7 +316,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -339,7 +339,7 @@ def test_method_quota(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_raw_response_quota(self, client: Cloudflare) -> None: @@ -350,7 +350,7 @@ def test_raw_response_quota(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize def test_streaming_response_quota(self, client: Cloudflare) -> None: @@ -361,7 +361,7 @@ def test_streaming_response_quota(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -377,7 +377,7 @@ def test_method_types(self, client: Cloudflare) -> None: request = client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_raw_response_types(self, client: Cloudflare) -> None: @@ -388,7 +388,7 @@ def test_raw_response_types(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize def test_streaming_response_types(self, client: Cloudflare) -> None: @@ -399,7 +399,7 @@ def test_streaming_response_types(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -419,7 +419,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.create( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -431,7 +431,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -442,7 +442,7 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -453,7 +453,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -470,7 +470,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -483,7 +483,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare summary="DoS attack", tlp="clear", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -495,7 +495,7 @@ async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -507,7 +507,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -641,7 +641,7 @@ async def test_method_constants(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.constants( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -652,7 +652,7 @@ async def test_raw_response_constants(self, async_client: AsyncCloudflare) -> No assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) @parametrize async def test_streaming_response_constants(self, async_client: AsyncCloudflare) -> None: @@ -663,7 +663,7 @@ async def test_streaming_response_constants(self, async_client: AsyncCloudflare) assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestConstants, request, path=["response"]) + assert_matches_type(Optional[RequestConstants], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -680,7 +680,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_identifier="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -692,7 +692,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -704,7 +704,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Item, request, path=["response"]) + assert_matches_type(Optional[Item], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -727,7 +727,7 @@ async def test_method_quota(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.quota( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -738,7 +738,7 @@ async def test_raw_response_quota(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) @parametrize async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> None: @@ -749,7 +749,7 @@ async def test_streaming_response_quota(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(Quota, request, path=["response"]) + assert_matches_type(Optional[Quota], request, path=["response"]) assert cast(Any, response.is_closed) is True @@ -765,7 +765,7 @@ async def test_method_types(self, async_client: AsyncCloudflare) -> None: request = await async_client.cloudforce_one.requests.types( "023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: @@ -776,7 +776,7 @@ async def test_raw_response_types(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) @parametrize async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> None: @@ -787,7 +787,7 @@ async def test_streaming_response_types(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" request = await response.parse() - assert_matches_type(RequestTypes, request, path=["response"]) + assert_matches_type(Optional[RequestTypes], request, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/intel/test_whois.py b/tests/api_resources/intel/test_whois.py index 215bb9b2e3f..c8f0f4035df 100644 --- a/tests/api_resources/intel/test_whois.py +++ b/tests/api_resources/intel/test_whois.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, cast +from typing import Any, Optional, cast import pytest @@ -22,7 +22,7 @@ def test_method_get(self, client: Cloudflare) -> None: whois = client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_method_get_with_all_params(self, client: Cloudflare) -> None: @@ -30,7 +30,7 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True @@ -72,7 +72,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: whois = await async_client.intel.whois.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -80,7 +80,7 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="string", ) - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -91,7 +91,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -102,7 +102,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" whois = await response.parse() - assert_matches_type(WhoisGetResponse, whois, path=["response"]) + assert_matches_type(Optional[WhoisGetResponse], whois, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/test_ai_gateway.py b/tests/api_resources/test_ai_gateway.py deleted file mode 100644 index a288f8db897..00000000000 --- a/tests/api_resources/test_ai_gateway.py +++ /dev/null @@ -1,643 +0,0 @@ -# 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", - )