diff --git a/.stats.yml b/.stats.yml index 0df12874625..83a45871666 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 1348 +configured_endpoints: 1356 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-08b201ef13ebb4bdf13a4d2e2165229fc6e5a369c64cf4a108835b65996cd957.yml diff --git a/api.md b/api.md index bc3718ff6b4..fa00c410812 100644 --- a/api.md +++ b/api.md @@ -4637,6 +4637,7 @@ from cloudflare.types.stream.captions import LanguageDeleteResponse Methods: +- client.stream.captions.language.create(language, \*, account_id, identifier) -> Optional - client.stream.captions.language.update(language, \*, account_id, identifier, \*\*params) -> Optional - client.stream.captions.language.delete(language, \*, account_id, identifier) -> str - client.stream.captions.language.get(language, \*, account_id, identifier) -> Optional @@ -6165,6 +6166,26 @@ Methods: - client.zero_trust.gateway.rules.delete(rule_id, \*, account_id) -> Optional - client.zero_trust.gateway.rules.get(rule_id, \*, account_id) -> Optional +### Certificates + +Types: + +```python +from cloudflare.types.zero_trust.gateway import ( + CertificateCreateResponse, + CertificateListResponse, + CertificateDeleteResponse, + CertificateGetResponse, +) +``` + +Methods: + +- client.zero_trust.gateway.certificates.create(\*, account_id, \*\*params) -> Optional +- client.zero_trust.gateway.certificates.list(\*, account_id) -> SyncSinglePage[CertificateListResponse] +- client.zero_trust.gateway.certificates.delete(certificate_id, \*, account_id) -> Optional +- client.zero_trust.gateway.certificates.get(certificate_id, \*, account_id) -> Optional + ## Networks ### Routes @@ -7865,12 +7886,37 @@ Methods: Types: ```python -from cloudflare.types.ai_gateway import LogGetResponse +from cloudflare.types.ai_gateway import LogListResponse, LogGetResponse +``` + +Methods: + +- client.ai_gateway.logs.list(id, \*, account_id, \*\*params) -> SyncV4PagePaginationArray[LogListResponse] +- client.ai_gateway.logs.get(log_id, \*, account_id, id) -> LogGetResponse + +### Request + +Types: + +```python +from cloudflare.types.ai_gateway.logs import RequestGetResponse +``` + +Methods: + +- client.ai_gateway.logs.request.get(log_id, \*, account_id, id) -> object + +### Response + +Types: + +```python +from cloudflare.types.ai_gateway.logs import ResponseGetResponse ``` Methods: -- client.ai_gateway.logs.get(id, \*, account_id, \*\*params) -> LogGetResponse +- client.ai_gateway.logs.response.get(log_id, \*, account_id, id) -> object # IAM diff --git a/src/cloudflare/resources/ai_gateway/ai_gateway.py b/src/cloudflare/resources/ai_gateway/ai_gateway.py index ac5a9237f0b..2d11d809968 100644 --- a/src/cloudflare/resources/ai_gateway/ai_gateway.py +++ b/src/cloudflare/resources/ai_gateway/ai_gateway.py @@ -21,6 +21,7 @@ async_maybe_transform, ) from ..._compat import cached_property +from .logs.logs import LogsResource, AsyncLogsResource from ..._resource import SyncAPIResource, AsyncAPIResource from ..._response import ( to_raw_response_wrapper, diff --git a/src/cloudflare/resources/ai_gateway/logs/__init__.py b/src/cloudflare/resources/ai_gateway/logs/__init__.py new file mode 100644 index 00000000000..cd50acd99fc --- /dev/null +++ b/src/cloudflare/resources/ai_gateway/logs/__init__.py @@ -0,0 +1,47 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .logs import ( + LogsResource, + AsyncLogsResource, + LogsResourceWithRawResponse, + AsyncLogsResourceWithRawResponse, + LogsResourceWithStreamingResponse, + AsyncLogsResourceWithStreamingResponse, +) +from .request import ( + RequestResource, + AsyncRequestResource, + RequestResourceWithRawResponse, + AsyncRequestResourceWithRawResponse, + RequestResourceWithStreamingResponse, + AsyncRequestResourceWithStreamingResponse, +) +from .response import ( + ResponseResource, + AsyncResponseResource, + ResponseResourceWithRawResponse, + AsyncResponseResourceWithRawResponse, + ResponseResourceWithStreamingResponse, + AsyncResponseResourceWithStreamingResponse, +) + +__all__ = [ + "RequestResource", + "AsyncRequestResource", + "RequestResourceWithRawResponse", + "AsyncRequestResourceWithRawResponse", + "RequestResourceWithStreamingResponse", + "AsyncRequestResourceWithStreamingResponse", + "ResponseResource", + "AsyncResponseResource", + "ResponseResourceWithRawResponse", + "AsyncResponseResourceWithRawResponse", + "ResponseResourceWithStreamingResponse", + "AsyncResponseResourceWithStreamingResponse", + "LogsResource", + "AsyncLogsResource", + "LogsResourceWithRawResponse", + "AsyncLogsResourceWithRawResponse", + "LogsResourceWithStreamingResponse", + "AsyncLogsResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/ai_gateway/logs.py b/src/cloudflare/resources/ai_gateway/logs/logs.py similarity index 51% rename from src/cloudflare/resources/ai_gateway/logs.py rename to src/cloudflare/resources/ai_gateway/logs/logs.py index 01650e97aa3..2176d77bef7 100644 --- a/src/cloudflare/resources/ai_gateway/logs.py +++ b/src/cloudflare/resources/ai_gateway/logs/logs.py @@ -8,30 +8,54 @@ import httpx -from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ..._utils import ( - maybe_transform, - async_maybe_transform, +from .request import ( + RequestResource, + AsyncRequestResource, + RequestResourceWithRawResponse, + AsyncRequestResourceWithRawResponse, + RequestResourceWithStreamingResponse, + AsyncRequestResourceWithStreamingResponse, ) -from ..._compat import cached_property -from ..._resource import SyncAPIResource, AsyncAPIResource -from ..._response import ( +from .response import ( + ResponseResource, + AsyncResponseResource, + ResponseResourceWithRawResponse, + AsyncResponseResourceWithRawResponse, + ResponseResourceWithStreamingResponse, + AsyncResponseResourceWithStreamingResponse, +) +from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ...._utils import maybe_transform +from ...._compat import cached_property +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 ( +from ...._wrappers import ResultWrapper +from ....pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray +from ...._base_client import ( + AsyncPaginator, make_request_options, ) -from ...types.ai_gateway import log_get_params -from ...types.ai_gateway.log_get_response import LogGetResponse +from ....types.ai_gateway import log_list_params +from ....types.ai_gateway.log_get_response import LogGetResponse +from ....types.ai_gateway.log_list_response import LogListResponse __all__ = ["LogsResource", "AsyncLogsResource"] class LogsResource(SyncAPIResource): + @cached_property + def request(self) -> RequestResource: + return RequestResource(self._client) + + @cached_property + def response(self) -> ResponseResource: + return ResponseResource(self._client) + @cached_property def with_raw_response(self) -> LogsResourceWithRawResponse: return LogsResourceWithRawResponse(self) @@ -40,7 +64,7 @@ def with_raw_response(self) -> LogsResourceWithRawResponse: def with_streaming_response(self) -> LogsResourceWithStreamingResponse: return LogsResourceWithStreamingResponse(self) - def get( + def list( self, id: str, *, @@ -60,7 +84,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> LogGetResponse: + ) -> SyncV4PagePaginationArray[LogListResponse]: """ List Gateway Logs @@ -79,8 +103,9 @@ def get( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not id: raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") - return self._get( + return self._get_api_list( f"/accounts/{account_id}/ai-gateway/gateways/{id}/logs", + page=SyncV4PagePaginationArray[LogListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -98,8 +123,52 @@ def get( "start_date": start_date, "success": success, }, - log_get_params.LogGetParams, + log_list_params.LogListParams, ), + ), + model=LogListResponse, + ) + + def get( + self, + log_id: str, + *, + account_id: str, + id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> LogGetResponse: + """ + Get Gateway Log Detail + + Args: + id: gateway id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + if not log_id: + raise ValueError(f"Expected a non-empty value for `log_id` but received {log_id!r}") + return self._get( + f"/accounts/{account_id}/ai-gateway/gateways/{id}/logs/{log_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, post_parser=ResultWrapper[LogGetResponse]._unwrapper, ), cast_to=cast(Type[LogGetResponse], ResultWrapper[LogGetResponse]), @@ -107,6 +176,14 @@ def get( class AsyncLogsResource(AsyncAPIResource): + @cached_property + def request(self) -> AsyncRequestResource: + return AsyncRequestResource(self._client) + + @cached_property + def response(self) -> AsyncResponseResource: + return AsyncResponseResource(self._client) + @cached_property def with_raw_response(self) -> AsyncLogsResourceWithRawResponse: return AsyncLogsResourceWithRawResponse(self) @@ -115,7 +192,7 @@ def with_raw_response(self) -> AsyncLogsResourceWithRawResponse: def with_streaming_response(self) -> AsyncLogsResourceWithStreamingResponse: return AsyncLogsResourceWithStreamingResponse(self) - async def get( + def list( self, id: str, *, @@ -135,7 +212,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> LogGetResponse: + ) -> AsyncPaginator[LogListResponse, AsyncV4PagePaginationArray[LogListResponse]]: """ List Gateway Logs @@ -154,14 +231,15 @@ async def get( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not id: raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") - return await self._get( + return self._get_api_list( f"/accounts/{account_id}/ai-gateway/gateways/{id}/logs", + page=AsyncV4PagePaginationArray[LogListResponse], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout, - query=await async_maybe_transform( + query=maybe_transform( { "cached": cached, "direction": direction, @@ -173,8 +251,52 @@ async def get( "start_date": start_date, "success": success, }, - log_get_params.LogGetParams, + log_list_params.LogListParams, ), + ), + model=LogListResponse, + ) + + async def get( + self, + log_id: str, + *, + account_id: str, + id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> LogGetResponse: + """ + Get Gateway Log Detail + + Args: + id: gateway id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + if not log_id: + raise ValueError(f"Expected a non-empty value for `log_id` but received {log_id!r}") + return await self._get( + f"/accounts/{account_id}/ai-gateway/gateways/{id}/logs/{log_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, post_parser=ResultWrapper[LogGetResponse]._unwrapper, ), cast_to=cast(Type[LogGetResponse], ResultWrapper[LogGetResponse]), @@ -185,33 +307,77 @@ class LogsResourceWithRawResponse: def __init__(self, logs: LogsResource) -> None: self._logs = logs + self.list = to_raw_response_wrapper( + logs.list, + ) self.get = to_raw_response_wrapper( logs.get, ) + @cached_property + def request(self) -> RequestResourceWithRawResponse: + return RequestResourceWithRawResponse(self._logs.request) + + @cached_property + def response(self) -> ResponseResourceWithRawResponse: + return ResponseResourceWithRawResponse(self._logs.response) + class AsyncLogsResourceWithRawResponse: def __init__(self, logs: AsyncLogsResource) -> None: self._logs = logs + self.list = async_to_raw_response_wrapper( + logs.list, + ) self.get = async_to_raw_response_wrapper( logs.get, ) + @cached_property + def request(self) -> AsyncRequestResourceWithRawResponse: + return AsyncRequestResourceWithRawResponse(self._logs.request) + + @cached_property + def response(self) -> AsyncResponseResourceWithRawResponse: + return AsyncResponseResourceWithRawResponse(self._logs.response) + class LogsResourceWithStreamingResponse: def __init__(self, logs: LogsResource) -> None: self._logs = logs + self.list = to_streamed_response_wrapper( + logs.list, + ) self.get = to_streamed_response_wrapper( logs.get, ) + @cached_property + def request(self) -> RequestResourceWithStreamingResponse: + return RequestResourceWithStreamingResponse(self._logs.request) + + @cached_property + def response(self) -> ResponseResourceWithStreamingResponse: + return ResponseResourceWithStreamingResponse(self._logs.response) + class AsyncLogsResourceWithStreamingResponse: def __init__(self, logs: AsyncLogsResource) -> None: self._logs = logs + self.list = async_to_streamed_response_wrapper( + logs.list, + ) self.get = async_to_streamed_response_wrapper( logs.get, ) + + @cached_property + def request(self) -> AsyncRequestResourceWithStreamingResponse: + return AsyncRequestResourceWithStreamingResponse(self._logs.request) + + @cached_property + def response(self) -> AsyncResponseResourceWithStreamingResponse: + return AsyncResponseResourceWithStreamingResponse(self._logs.response) diff --git a/src/cloudflare/resources/ai_gateway/logs/request.py b/src/cloudflare/resources/ai_gateway/logs/request.py new file mode 100644 index 00000000000..05a85c72ef3 --- /dev/null +++ b/src/cloudflare/resources/ai_gateway/logs/request.py @@ -0,0 +1,158 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._base_client import ( + make_request_options, +) + +__all__ = ["RequestResource", "AsyncRequestResource"] + + +class RequestResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> RequestResourceWithRawResponse: + return RequestResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> RequestResourceWithStreamingResponse: + return RequestResourceWithStreamingResponse(self) + + def get( + self, + log_id: str, + *, + account_id: str, + id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> object: + """ + Get Gateway Log Request + + Args: + id: gateway id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + if not log_id: + raise ValueError(f"Expected a non-empty value for `log_id` but received {log_id!r}") + return self._get( + f"/accounts/{account_id}/ai-gateway/gateways/{id}/logs/{log_id}/request", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=object, + ) + + +class AsyncRequestResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncRequestResourceWithRawResponse: + return AsyncRequestResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncRequestResourceWithStreamingResponse: + return AsyncRequestResourceWithStreamingResponse(self) + + async def get( + self, + log_id: str, + *, + account_id: str, + id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> object: + """ + Get Gateway Log Request + + Args: + id: gateway id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + if not log_id: + raise ValueError(f"Expected a non-empty value for `log_id` but received {log_id!r}") + return await self._get( + f"/accounts/{account_id}/ai-gateway/gateways/{id}/logs/{log_id}/request", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=object, + ) + + +class RequestResourceWithRawResponse: + def __init__(self, request: RequestResource) -> None: + self._request = request + + self.get = to_raw_response_wrapper( + request.get, + ) + + +class AsyncRequestResourceWithRawResponse: + def __init__(self, request: AsyncRequestResource) -> None: + self._request = request + + self.get = async_to_raw_response_wrapper( + request.get, + ) + + +class RequestResourceWithStreamingResponse: + def __init__(self, request: RequestResource) -> None: + self._request = request + + self.get = to_streamed_response_wrapper( + request.get, + ) + + +class AsyncRequestResourceWithStreamingResponse: + def __init__(self, request: AsyncRequestResource) -> None: + self._request = request + + self.get = async_to_streamed_response_wrapper( + request.get, + ) diff --git a/src/cloudflare/resources/ai_gateway/logs/response.py b/src/cloudflare/resources/ai_gateway/logs/response.py new file mode 100644 index 00000000000..e70ec94a87b --- /dev/null +++ b/src/cloudflare/resources/ai_gateway/logs/response.py @@ -0,0 +1,158 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._base_client import ( + make_request_options, +) + +__all__ = ["ResponseResource", "AsyncResponseResource"] + + +class ResponseResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> ResponseResourceWithRawResponse: + return ResponseResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ResponseResourceWithStreamingResponse: + return ResponseResourceWithStreamingResponse(self) + + def get( + self, + log_id: str, + *, + account_id: str, + id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> object: + """ + Get Gateway Log Response + + Args: + id: gateway id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + if not log_id: + raise ValueError(f"Expected a non-empty value for `log_id` but received {log_id!r}") + return self._get( + f"/accounts/{account_id}/ai-gateway/gateways/{id}/logs/{log_id}/response", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=object, + ) + + +class AsyncResponseResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncResponseResourceWithRawResponse: + return AsyncResponseResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncResponseResourceWithStreamingResponse: + return AsyncResponseResourceWithStreamingResponse(self) + + async def get( + self, + log_id: str, + *, + account_id: str, + id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> object: + """ + Get Gateway Log Response + + Args: + id: gateway id + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + if not log_id: + raise ValueError(f"Expected a non-empty value for `log_id` but received {log_id!r}") + return await self._get( + f"/accounts/{account_id}/ai-gateway/gateways/{id}/logs/{log_id}/response", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=object, + ) + + +class ResponseResourceWithRawResponse: + def __init__(self, response: ResponseResource) -> None: + self._response = response + + self.get = to_raw_response_wrapper( + response.get, + ) + + +class AsyncResponseResourceWithRawResponse: + def __init__(self, response: AsyncResponseResource) -> None: + self._response = response + + self.get = async_to_raw_response_wrapper( + response.get, + ) + + +class ResponseResourceWithStreamingResponse: + def __init__(self, response: ResponseResource) -> None: + self._response = response + + self.get = to_streamed_response_wrapper( + response.get, + ) + + +class AsyncResponseResourceWithStreamingResponse: + def __init__(self, response: AsyncResponseResource) -> None: + self._response = response + + self.get = async_to_streamed_response_wrapper( + response.get, + ) diff --git a/src/cloudflare/resources/stream/captions/language/language.py b/src/cloudflare/resources/stream/captions/language/language.py index 34ca70cdff5..3c1bfec470e 100644 --- a/src/cloudflare/resources/stream/captions/language/language.py +++ b/src/cloudflare/resources/stream/captions/language/language.py @@ -51,6 +51,55 @@ def with_raw_response(self) -> LanguageResourceWithRawResponse: def with_streaming_response(self) -> LanguageResourceWithStreamingResponse: return LanguageResourceWithStreamingResponse(self) + def create( + self, + language: str, + *, + account_id: str, + identifier: 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, + ) -> Optional[Caption]: + """ + Generate captions or subtitles for provided language via AI. + + Args: + account_id: Identifier + + identifier: A Cloudflare-generated unique identifier for a media item. + + language: The language tag in BCP 47 format. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not identifier: + raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") + if not language: + raise ValueError(f"Expected a non-empty value for `language` but received {language!r}") + return self._post( + f"/accounts/{account_id}/stream/{identifier}/captions/{language}/generate", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[Caption]]._unwrapper, + ), + cast_to=cast(Type[Optional[Caption]], ResultWrapper[Caption]), + ) + def update( self, language: str, @@ -217,6 +266,55 @@ def with_raw_response(self) -> AsyncLanguageResourceWithRawResponse: def with_streaming_response(self) -> AsyncLanguageResourceWithStreamingResponse: return AsyncLanguageResourceWithStreamingResponse(self) + async def create( + self, + language: str, + *, + account_id: str, + identifier: 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, + ) -> Optional[Caption]: + """ + Generate captions or subtitles for provided language via AI. + + Args: + account_id: Identifier + + identifier: A Cloudflare-generated unique identifier for a media item. + + language: The language tag in BCP 47 format. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not identifier: + raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") + if not language: + raise ValueError(f"Expected a non-empty value for `language` but received {language!r}") + return await self._post( + f"/accounts/{account_id}/stream/{identifier}/captions/{language}/generate", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[Caption]]._unwrapper, + ), + cast_to=cast(Type[Optional[Caption]], ResultWrapper[Caption]), + ) + async def update( self, language: str, @@ -374,6 +472,9 @@ class LanguageResourceWithRawResponse: def __init__(self, language: LanguageResource) -> None: self._language = language + self.create = to_raw_response_wrapper( + language.create, + ) self.update = to_raw_response_wrapper( language.update, ) @@ -393,6 +494,9 @@ class AsyncLanguageResourceWithRawResponse: def __init__(self, language: AsyncLanguageResource) -> None: self._language = language + self.create = async_to_raw_response_wrapper( + language.create, + ) self.update = async_to_raw_response_wrapper( language.update, ) @@ -412,6 +516,9 @@ class LanguageResourceWithStreamingResponse: def __init__(self, language: LanguageResource) -> None: self._language = language + self.create = to_streamed_response_wrapper( + language.create, + ) self.update = to_streamed_response_wrapper( language.update, ) @@ -431,6 +538,9 @@ class AsyncLanguageResourceWithStreamingResponse: def __init__(self, language: AsyncLanguageResource) -> None: self._language = language + self.create = async_to_streamed_response_wrapper( + language.create, + ) self.update = async_to_streamed_response_wrapper( language.update, ) diff --git a/src/cloudflare/resources/zero_trust/gateway/__init__.py b/src/cloudflare/resources/zero_trust/gateway/__init__.py index e121dd0022f..dd71429636f 100644 --- a/src/cloudflare/resources/zero_trust/gateway/__init__.py +++ b/src/cloudflare/resources/zero_trust/gateway/__init__.py @@ -56,6 +56,14 @@ CategoriesResourceWithStreamingResponse, AsyncCategoriesResourceWithStreamingResponse, ) +from .certificates import ( + CertificatesResource, + AsyncCertificatesResource, + CertificatesResourceWithRawResponse, + AsyncCertificatesResourceWithRawResponse, + CertificatesResourceWithStreamingResponse, + AsyncCertificatesResourceWithStreamingResponse, +) from .configurations import ( ConfigurationsResource, AsyncConfigurationsResource, @@ -136,6 +144,12 @@ "AsyncRulesResourceWithRawResponse", "RulesResourceWithStreamingResponse", "AsyncRulesResourceWithStreamingResponse", + "CertificatesResource", + "AsyncCertificatesResource", + "CertificatesResourceWithRawResponse", + "AsyncCertificatesResourceWithRawResponse", + "CertificatesResourceWithStreamingResponse", + "AsyncCertificatesResourceWithStreamingResponse", "GatewayResource", "AsyncGatewayResource", "GatewayResourceWithRawResponse", diff --git a/src/cloudflare/resources/zero_trust/gateway/certificates.py b/src/cloudflare/resources/zero_trust/gateway/certificates.py new file mode 100644 index 00000000000..8e9b8b954f2 --- /dev/null +++ b/src/cloudflare/resources/zero_trust/gateway/certificates.py @@ -0,0 +1,450 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Optional, cast + +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 ....pagination import SyncSinglePage, AsyncSinglePage +from ...._base_client import ( + AsyncPaginator, + make_request_options, +) +from ....types.zero_trust.gateway import certificate_create_params +from ....types.zero_trust.gateway.certificate_get_response import CertificateGetResponse +from ....types.zero_trust.gateway.certificate_list_response import CertificateListResponse +from ....types.zero_trust.gateway.certificate_create_response import CertificateCreateResponse +from ....types.zero_trust.gateway.certificate_delete_response import CertificateDeleteResponse + +__all__ = ["CertificatesResource", "AsyncCertificatesResource"] + + +class CertificatesResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> CertificatesResourceWithRawResponse: + return CertificatesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> CertificatesResourceWithStreamingResponse: + return CertificatesResourceWithStreamingResponse(self) + + def create( + self, + *, + account_id: str, + validity_period_days: 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, + ) -> Optional[CertificateCreateResponse]: + """ + Creates a new Zero Trust certificate. + + Args: + validity_period_days: Number of days the generated certificate will be valid, minimum 1 day and + maximum 30 years. Defaults to 5 years. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._post( + f"/accounts/{account_id}/gateway/certificates", + body=maybe_transform( + {"validity_period_days": validity_period_days}, certificate_create_params.CertificateCreateParams + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[CertificateCreateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[CertificateCreateResponse]], ResultWrapper[CertificateCreateResponse]), + ) + + def list( + self, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> SyncSinglePage[CertificateListResponse]: + """ + Fetches all Zero Trust certificates for an account. + + 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_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/gateway/certificates", + page=SyncSinglePage[CertificateListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=CertificateListResponse, + ) + + def delete( + self, + certificate_id: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[CertificateDeleteResponse]: + """ + Deletes a gateway-managed Zero Trust certificate. + + Args: + certificate_id: Certificate UUID tag. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not certificate_id: + raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") + return self._delete( + f"/accounts/{account_id}/gateway/certificates/{certificate_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[CertificateDeleteResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[CertificateDeleteResponse]], ResultWrapper[CertificateDeleteResponse]), + ) + + def get( + self, + certificate_id: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[CertificateGetResponse]: + """ + Fetches a single Zero Trust certificate. + + Args: + certificate_id: Certificate UUID tag. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not certificate_id: + raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") + return self._get( + f"/accounts/{account_id}/gateway/certificates/{certificate_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[CertificateGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[CertificateGetResponse]], ResultWrapper[CertificateGetResponse]), + ) + + +class AsyncCertificatesResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncCertificatesResourceWithRawResponse: + return AsyncCertificatesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncCertificatesResourceWithStreamingResponse: + return AsyncCertificatesResourceWithStreamingResponse(self) + + async def create( + self, + *, + account_id: str, + validity_period_days: 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, + ) -> Optional[CertificateCreateResponse]: + """ + Creates a new Zero Trust certificate. + + Args: + validity_period_days: Number of days the generated certificate will be valid, minimum 1 day and + maximum 30 years. Defaults to 5 years. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._post( + f"/accounts/{account_id}/gateway/certificates", + body=await async_maybe_transform( + {"validity_period_days": validity_period_days}, certificate_create_params.CertificateCreateParams + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[CertificateCreateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[CertificateCreateResponse]], ResultWrapper[CertificateCreateResponse]), + ) + + def list( + self, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> AsyncPaginator[CertificateListResponse, AsyncSinglePage[CertificateListResponse]]: + """ + Fetches all Zero Trust certificates for an account. + + 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_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/gateway/certificates", + page=AsyncSinglePage[CertificateListResponse], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=CertificateListResponse, + ) + + async def delete( + self, + certificate_id: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[CertificateDeleteResponse]: + """ + Deletes a gateway-managed Zero Trust certificate. + + Args: + certificate_id: Certificate UUID tag. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not certificate_id: + raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") + return await self._delete( + f"/accounts/{account_id}/gateway/certificates/{certificate_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[CertificateDeleteResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[CertificateDeleteResponse]], ResultWrapper[CertificateDeleteResponse]), + ) + + async def get( + self, + certificate_id: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[CertificateGetResponse]: + """ + Fetches a single Zero Trust certificate. + + Args: + certificate_id: Certificate UUID tag. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not certificate_id: + raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}") + return await self._get( + f"/accounts/{account_id}/gateway/certificates/{certificate_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[CertificateGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[CertificateGetResponse]], ResultWrapper[CertificateGetResponse]), + ) + + +class CertificatesResourceWithRawResponse: + def __init__(self, certificates: CertificatesResource) -> None: + self._certificates = certificates + + self.create = to_raw_response_wrapper( + certificates.create, + ) + self.list = to_raw_response_wrapper( + certificates.list, + ) + self.delete = to_raw_response_wrapper( + certificates.delete, + ) + self.get = to_raw_response_wrapper( + certificates.get, + ) + + +class AsyncCertificatesResourceWithRawResponse: + def __init__(self, certificates: AsyncCertificatesResource) -> None: + self._certificates = certificates + + self.create = async_to_raw_response_wrapper( + certificates.create, + ) + self.list = async_to_raw_response_wrapper( + certificates.list, + ) + self.delete = async_to_raw_response_wrapper( + certificates.delete, + ) + self.get = async_to_raw_response_wrapper( + certificates.get, + ) + + +class CertificatesResourceWithStreamingResponse: + def __init__(self, certificates: CertificatesResource) -> None: + self._certificates = certificates + + self.create = to_streamed_response_wrapper( + certificates.create, + ) + self.list = to_streamed_response_wrapper( + certificates.list, + ) + self.delete = to_streamed_response_wrapper( + certificates.delete, + ) + self.get = to_streamed_response_wrapper( + certificates.get, + ) + + +class AsyncCertificatesResourceWithStreamingResponse: + def __init__(self, certificates: AsyncCertificatesResource) -> None: + self._certificates = certificates + + self.create = async_to_streamed_response_wrapper( + certificates.create, + ) + self.list = async_to_streamed_response_wrapper( + certificates.list, + ) + self.delete = async_to_streamed_response_wrapper( + certificates.delete, + ) + self.get = async_to_streamed_response_wrapper( + certificates.get, + ) diff --git a/src/cloudflare/resources/zero_trust/gateway/gateway.py b/src/cloudflare/resources/zero_trust/gateway/gateway.py index a2e994272d9..9d43923083a 100644 --- a/src/cloudflare/resources/zero_trust/gateway/gateway.py +++ b/src/cloudflare/resources/zero_trust/gateway/gateway.py @@ -65,6 +65,14 @@ async_to_streamed_response_wrapper, ) from ...._wrappers import ResultWrapper +from .certificates import ( + CertificatesResource, + AsyncCertificatesResource, + CertificatesResourceWithRawResponse, + AsyncCertificatesResourceWithRawResponse, + CertificatesResourceWithStreamingResponse, + AsyncCertificatesResourceWithStreamingResponse, +) from .configurations import ( ConfigurationsResource, AsyncConfigurationsResource, @@ -135,6 +143,10 @@ def proxy_endpoints(self) -> ProxyEndpointsResource: def rules(self) -> RulesResource: return RulesResource(self._client) + @cached_property + def certificates(self) -> CertificatesResource: + return CertificatesResource(self._client) + @cached_property def with_raw_response(self) -> GatewayResourceWithRawResponse: return GatewayResourceWithRawResponse(self) @@ -255,6 +267,10 @@ def proxy_endpoints(self) -> AsyncProxyEndpointsResource: def rules(self) -> AsyncRulesResource: return AsyncRulesResource(self._client) + @cached_property + def certificates(self) -> AsyncCertificatesResource: + return AsyncCertificatesResource(self._client) + @cached_property def with_raw_response(self) -> AsyncGatewayResourceWithRawResponse: return AsyncGatewayResourceWithRawResponse(self) @@ -385,6 +401,10 @@ def proxy_endpoints(self) -> ProxyEndpointsResourceWithRawResponse: def rules(self) -> RulesResourceWithRawResponse: return RulesResourceWithRawResponse(self._gateway.rules) + @cached_property + def certificates(self) -> CertificatesResourceWithRawResponse: + return CertificatesResourceWithRawResponse(self._gateway.certificates) + class AsyncGatewayResourceWithRawResponse: def __init__(self, gateway: AsyncGatewayResource) -> None: @@ -433,6 +453,10 @@ def proxy_endpoints(self) -> AsyncProxyEndpointsResourceWithRawResponse: def rules(self) -> AsyncRulesResourceWithRawResponse: return AsyncRulesResourceWithRawResponse(self._gateway.rules) + @cached_property + def certificates(self) -> AsyncCertificatesResourceWithRawResponse: + return AsyncCertificatesResourceWithRawResponse(self._gateway.certificates) + class GatewayResourceWithStreamingResponse: def __init__(self, gateway: GatewayResource) -> None: @@ -481,6 +505,10 @@ def proxy_endpoints(self) -> ProxyEndpointsResourceWithStreamingResponse: def rules(self) -> RulesResourceWithStreamingResponse: return RulesResourceWithStreamingResponse(self._gateway.rules) + @cached_property + def certificates(self) -> CertificatesResourceWithStreamingResponse: + return CertificatesResourceWithStreamingResponse(self._gateway.certificates) + class AsyncGatewayResourceWithStreamingResponse: def __init__(self, gateway: AsyncGatewayResource) -> None: @@ -528,3 +556,7 @@ def proxy_endpoints(self) -> AsyncProxyEndpointsResourceWithStreamingResponse: @cached_property def rules(self) -> AsyncRulesResourceWithStreamingResponse: return AsyncRulesResourceWithStreamingResponse(self._gateway.rules) + + @cached_property + def certificates(self) -> AsyncCertificatesResourceWithStreamingResponse: + return AsyncCertificatesResourceWithStreamingResponse(self._gateway.certificates) diff --git a/src/cloudflare/types/ai_gateway/__init__.py b/src/cloudflare/types/ai_gateway/__init__.py index e34365f10eb..afc8501bed2 100644 --- a/src/cloudflare/types/ai_gateway/__init__.py +++ b/src/cloudflare/types/ai_gateway/__init__.py @@ -2,8 +2,9 @@ from __future__ import annotations -from .log_get_params import LogGetParams as LogGetParams +from .log_list_params import LogListParams as LogListParams from .log_get_response import LogGetResponse as LogGetResponse +from .log_list_response import LogListResponse as LogListResponse from .ai_gateway_list_params import AIGatewayListParams as AIGatewayListParams from .ai_gateway_get_response import AIGatewayGetResponse as AIGatewayGetResponse from .ai_gateway_create_params import AIGatewayCreateParams as AIGatewayCreateParams diff --git a/src/cloudflare/types/ai_gateway/log_get_response.py b/src/cloudflare/types/ai_gateway/log_get_response.py index c78976e56d4..ff80ce3414d 100644 --- a/src/cloudflare/types/ai_gateway/log_get_response.py +++ b/src/cloudflare/types/ai_gateway/log_get_response.py @@ -1,14 +1,14 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Optional +from typing import Optional from datetime import datetime from ..._models import BaseModel -__all__ = ["LogGetResponse", "LogGetResponseItem"] +__all__ = ["LogGetResponse"] -class LogGetResponseItem(BaseModel): +class LogGetResponse(BaseModel): id: str cached: bool @@ -44,6 +44,3 @@ class LogGetResponseItem(BaseModel): status_code: Optional[int] = None step: Optional[int] = None - - -LogGetResponse = List[LogGetResponseItem] diff --git a/src/cloudflare/types/ai_gateway/log_get_params.py b/src/cloudflare/types/ai_gateway/log_list_params.py similarity index 89% rename from src/cloudflare/types/ai_gateway/log_get_params.py rename to src/cloudflare/types/ai_gateway/log_list_params.py index c6503dfd736..3f3bbe5efa6 100644 --- a/src/cloudflare/types/ai_gateway/log_get_params.py +++ b/src/cloudflare/types/ai_gateway/log_list_params.py @@ -8,10 +8,10 @@ from ..._utils import PropertyInfo -__all__ = ["LogGetParams"] +__all__ = ["LogListParams"] -class LogGetParams(TypedDict, total=False): +class LogListParams(TypedDict, total=False): account_id: Required[str] cached: bool diff --git a/src/cloudflare/types/ai_gateway/log_list_response.py b/src/cloudflare/types/ai_gateway/log_list_response.py new file mode 100644 index 00000000000..54366ffe597 --- /dev/null +++ b/src/cloudflare/types/ai_gateway/log_list_response.py @@ -0,0 +1,46 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime + +from ..._models import BaseModel + +__all__ = ["LogListResponse"] + + +class LogListResponse(BaseModel): + id: str + + cached: bool + + created_at: datetime + + duration: int + + model: str + + path: str + + provider: str + + request: str + + response: str + + success: bool + + tokens_in: int + + tokens_out: int + + metadata: Optional[str] = None + + request_content_type: Optional[str] = None + + request_type: Optional[str] = None + + response_content_type: Optional[str] = None + + status_code: Optional[int] = None + + step: Optional[int] = None diff --git a/src/cloudflare/types/ai_gateway/logs/__init__.py b/src/cloudflare/types/ai_gateway/logs/__init__.py new file mode 100644 index 00000000000..f8ee8b14b1c --- /dev/null +++ b/src/cloudflare/types/ai_gateway/logs/__init__.py @@ -0,0 +1,3 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations diff --git a/src/cloudflare/types/zero_trust/gateway/__init__.py b/src/cloudflare/types/zero_trust/gateway/__init__.py index c462d3ec6af..e0f7ea5cf69 100644 --- a/src/cloudflare/types/zero_trust/gateway/__init__.py +++ b/src/cloudflare/types/zero_trust/gateway/__init__.py @@ -43,17 +43,22 @@ from .location_network_param import LocationNetworkParam as LocationNetworkParam from .location_update_params import LocationUpdateParams as LocationUpdateParams from .extended_email_matching import ExtendedEmailMatching as ExtendedEmailMatching +from .certificate_get_response import CertificateGetResponse as CertificateGetResponse from .dns_resolver_settings_v4 import DNSResolverSettingsV4 as DNSResolverSettingsV4 from .dns_resolver_settings_v6 import DNSResolverSettingsV6 as DNSResolverSettingsV6 from .location_delete_response import LocationDeleteResponse as LocationDeleteResponse from .protocol_detection_param import ProtocolDetectionParam as ProtocolDetectionParam from .anti_virus_settings_param import AntiVirusSettingsParam as AntiVirusSettingsParam from .block_page_settings_param import BlockPageSettingsParam as BlockPageSettingsParam +from .certificate_create_params import CertificateCreateParams as CertificateCreateParams +from .certificate_list_response import CertificateListResponse as CertificateListResponse from .configuration_edit_params import ConfigurationEditParams as ConfigurationEditParams from .browser_isolation_settings import BrowserIsolationSettings as BrowserIsolationSettings from .configuration_get_response import ConfigurationGetResponse as ConfigurationGetResponse from .proxy_endpoint_edit_params import ProxyEndpointEditParams as ProxyEndpointEditParams from .activity_log_settings_param import ActivityLogSettingsParam as ActivityLogSettingsParam +from .certificate_create_response import CertificateCreateResponse as CertificateCreateResponse +from .certificate_delete_response import CertificateDeleteResponse as CertificateDeleteResponse from .configuration_edit_response import ConfigurationEditResponse as ConfigurationEditResponse from .configuration_update_params import ConfigurationUpdateParams as ConfigurationUpdateParams from .custom_certificate_settings import CustomCertificateSettings as CustomCertificateSettings diff --git a/src/cloudflare/types/zero_trust/gateway/certificate_create_params.py b/src/cloudflare/types/zero_trust/gateway/certificate_create_params.py new file mode 100644 index 00000000000..1de699e498c --- /dev/null +++ b/src/cloudflare/types/zero_trust/gateway/certificate_create_params.py @@ -0,0 +1,17 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["CertificateCreateParams"] + + +class CertificateCreateParams(TypedDict, total=False): + account_id: Required[str] + + validity_period_days: int + """ + Number of days the generated certificate will be valid, minimum 1 day and + maximum 30 years. Defaults to 5 years. + """ diff --git a/src/cloudflare/types/zero_trust/gateway/certificate_create_response.py b/src/cloudflare/types/zero_trust/gateway/certificate_create_response.py new file mode 100644 index 00000000000..f80dc62369e --- /dev/null +++ b/src/cloudflare/types/zero_trust/gateway/certificate_create_response.py @@ -0,0 +1,31 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime +from typing_extensions import Literal + +from ...._models import BaseModel + +__all__ = ["CertificateCreateResponse"] + + +class CertificateCreateResponse(BaseModel): + id: Optional[str] = None + """Certificate UUID tag.""" + + binding_status: Optional[Literal["pending_deployment", "active", "pending_deletion", "inactive"]] = None + """The deployment status of the certificate on Cloudflare's edge.""" + + created_at: Optional[datetime] = None + + enabled: Optional[bool] = None + """Use this certificate for Gateway TLS interception""" + + expires_on: Optional[datetime] = None + + type: Optional[Literal["custom", "gateway_managed"]] = None + """The type of certificate, either BYO-PKI (custom) or Gateway-managed.""" + + updated_at: Optional[datetime] = None + + uploaded_on: Optional[datetime] = None diff --git a/src/cloudflare/types/zero_trust/gateway/certificate_delete_response.py b/src/cloudflare/types/zero_trust/gateway/certificate_delete_response.py new file mode 100644 index 00000000000..b8e44b1a35b --- /dev/null +++ b/src/cloudflare/types/zero_trust/gateway/certificate_delete_response.py @@ -0,0 +1,31 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime +from typing_extensions import Literal + +from ...._models import BaseModel + +__all__ = ["CertificateDeleteResponse"] + + +class CertificateDeleteResponse(BaseModel): + id: Optional[str] = None + """Certificate UUID tag.""" + + binding_status: Optional[Literal["pending_deployment", "active", "pending_deletion", "inactive"]] = None + """The deployment status of the certificate on Cloudflare's edge.""" + + created_at: Optional[datetime] = None + + enabled: Optional[bool] = None + """Use this certificate for Gateway TLS interception""" + + expires_on: Optional[datetime] = None + + type: Optional[Literal["custom", "gateway_managed"]] = None + """The type of certificate, either BYO-PKI (custom) or Gateway-managed.""" + + updated_at: Optional[datetime] = None + + uploaded_on: Optional[datetime] = None diff --git a/src/cloudflare/types/zero_trust/gateway/certificate_get_response.py b/src/cloudflare/types/zero_trust/gateway/certificate_get_response.py new file mode 100644 index 00000000000..6a702b1122f --- /dev/null +++ b/src/cloudflare/types/zero_trust/gateway/certificate_get_response.py @@ -0,0 +1,31 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime +from typing_extensions import Literal + +from ...._models import BaseModel + +__all__ = ["CertificateGetResponse"] + + +class CertificateGetResponse(BaseModel): + id: Optional[str] = None + """Certificate UUID tag.""" + + binding_status: Optional[Literal["pending_deployment", "active", "pending_deletion", "inactive"]] = None + """The deployment status of the certificate on Cloudflare's edge.""" + + created_at: Optional[datetime] = None + + enabled: Optional[bool] = None + """Use this certificate for Gateway TLS interception""" + + expires_on: Optional[datetime] = None + + type: Optional[Literal["custom", "gateway_managed"]] = None + """The type of certificate, either BYO-PKI (custom) or Gateway-managed.""" + + updated_at: Optional[datetime] = None + + uploaded_on: Optional[datetime] = None diff --git a/src/cloudflare/types/zero_trust/gateway/certificate_list_response.py b/src/cloudflare/types/zero_trust/gateway/certificate_list_response.py new file mode 100644 index 00000000000..322c092fcaf --- /dev/null +++ b/src/cloudflare/types/zero_trust/gateway/certificate_list_response.py @@ -0,0 +1,31 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from datetime import datetime +from typing_extensions import Literal + +from ...._models import BaseModel + +__all__ = ["CertificateListResponse"] + + +class CertificateListResponse(BaseModel): + id: Optional[str] = None + """Certificate UUID tag.""" + + binding_status: Optional[Literal["pending_deployment", "active", "pending_deletion", "inactive"]] = None + """The deployment status of the certificate on Cloudflare's edge.""" + + created_at: Optional[datetime] = None + + enabled: Optional[bool] = None + """Use this certificate for Gateway TLS interception""" + + expires_on: Optional[datetime] = None + + type: Optional[Literal["custom", "gateway_managed"]] = None + """The type of certificate, either BYO-PKI (custom) or Gateway-managed.""" + + updated_at: Optional[datetime] = None + + uploaded_on: Optional[datetime] = None diff --git a/tests/api_resources/ai_gateway/logs/__init__.py b/tests/api_resources/ai_gateway/logs/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/ai_gateway/logs/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/ai_gateway/logs/test_request.py b/tests/api_resources/ai_gateway/logs/test_request.py new file mode 100644 index 00000000000..d7a2c3da764 --- /dev/null +++ b/tests/api_resources/ai_gateway/logs/test_request.py @@ -0,0 +1,141 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestRequest: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + request = client.ai_gateway.logs.request.get( + "string", + account_id="0d37909e38d3e99c29fa2cd343ac421a", + id="my-gateway", + ) + assert_matches_type(object, request, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.ai_gateway.logs.request.with_raw_response.get( + "string", + account_id="0d37909e38d3e99c29fa2cd343ac421a", + id="my-gateway", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + request = response.parse() + assert_matches_type(object, request, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.ai_gateway.logs.request.with_streaming_response.get( + "string", + account_id="0d37909e38d3e99c29fa2cd343ac421a", + id="my-gateway", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + request = response.parse() + assert_matches_type(object, request, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.ai_gateway.logs.request.with_raw_response.get( + "string", + account_id="", + id="my-gateway", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.ai_gateway.logs.request.with_raw_response.get( + "string", + account_id="0d37909e38d3e99c29fa2cd343ac421a", + id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `log_id` but received ''"): + client.ai_gateway.logs.request.with_raw_response.get( + "", + account_id="0d37909e38d3e99c29fa2cd343ac421a", + id="my-gateway", + ) + + +class TestAsyncRequest: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + request = await async_client.ai_gateway.logs.request.get( + "string", + account_id="0d37909e38d3e99c29fa2cd343ac421a", + id="my-gateway", + ) + assert_matches_type(object, request, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.ai_gateway.logs.request.with_raw_response.get( + "string", + account_id="0d37909e38d3e99c29fa2cd343ac421a", + id="my-gateway", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + request = await response.parse() + assert_matches_type(object, request, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.ai_gateway.logs.request.with_streaming_response.get( + "string", + account_id="0d37909e38d3e99c29fa2cd343ac421a", + id="my-gateway", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + request = await response.parse() + assert_matches_type(object, request, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.ai_gateway.logs.request.with_raw_response.get( + "string", + account_id="", + id="my-gateway", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.ai_gateway.logs.request.with_raw_response.get( + "string", + account_id="0d37909e38d3e99c29fa2cd343ac421a", + id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `log_id` but received ''"): + await async_client.ai_gateway.logs.request.with_raw_response.get( + "", + account_id="0d37909e38d3e99c29fa2cd343ac421a", + id="my-gateway", + ) diff --git a/tests/api_resources/ai_gateway/logs/test_response.py b/tests/api_resources/ai_gateway/logs/test_response.py new file mode 100644 index 00000000000..f66bf7c2449 --- /dev/null +++ b/tests/api_resources/ai_gateway/logs/test_response.py @@ -0,0 +1,141 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestResponse: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + response = client.ai_gateway.logs.response.get( + "string", + account_id="0d37909e38d3e99c29fa2cd343ac421a", + id="my-gateway", + ) + assert_matches_type(object, response, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + http_response = client.ai_gateway.logs.response.with_raw_response.get( + "string", + account_id="0d37909e38d3e99c29fa2cd343ac421a", + id="my-gateway", + ) + + assert http_response.is_closed is True + assert http_response.http_request.headers.get("X-Stainless-Lang") == "python" + response = http_response.parse() + assert_matches_type(object, response, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.ai_gateway.logs.response.with_streaming_response.get( + "string", + account_id="0d37909e38d3e99c29fa2cd343ac421a", + id="my-gateway", + ) as http_response: + assert not http_response.is_closed + assert http_response.http_request.headers.get("X-Stainless-Lang") == "python" + + response = http_response.parse() + assert_matches_type(object, response, path=["response"]) + + assert cast(Any, http_response.is_closed) is True + + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.ai_gateway.logs.response.with_raw_response.get( + "string", + account_id="", + id="my-gateway", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.ai_gateway.logs.response.with_raw_response.get( + "string", + account_id="0d37909e38d3e99c29fa2cd343ac421a", + id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `log_id` but received ''"): + client.ai_gateway.logs.response.with_raw_response.get( + "", + account_id="0d37909e38d3e99c29fa2cd343ac421a", + id="my-gateway", + ) + + +class TestAsyncResponse: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.ai_gateway.logs.response.get( + "string", + account_id="0d37909e38d3e99c29fa2cd343ac421a", + id="my-gateway", + ) + assert_matches_type(object, response, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + http_response = await async_client.ai_gateway.logs.response.with_raw_response.get( + "string", + account_id="0d37909e38d3e99c29fa2cd343ac421a", + id="my-gateway", + ) + + assert http_response.is_closed is True + assert http_response.http_request.headers.get("X-Stainless-Lang") == "python" + response = await http_response.parse() + assert_matches_type(object, response, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.ai_gateway.logs.response.with_streaming_response.get( + "string", + account_id="0d37909e38d3e99c29fa2cd343ac421a", + id="my-gateway", + ) as http_response: + assert not http_response.is_closed + assert http_response.http_request.headers.get("X-Stainless-Lang") == "python" + + response = await http_response.parse() + assert_matches_type(object, response, path=["response"]) + + assert cast(Any, http_response.is_closed) is True + + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.ai_gateway.logs.response.with_raw_response.get( + "string", + account_id="", + id="my-gateway", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.ai_gateway.logs.response.with_raw_response.get( + "string", + account_id="0d37909e38d3e99c29fa2cd343ac421a", + id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `log_id` but received ''"): + await async_client.ai_gateway.logs.response.with_raw_response.get( + "", + account_id="0d37909e38d3e99c29fa2cd343ac421a", + id="my-gateway", + ) diff --git a/tests/api_resources/ai_gateway/test_logs.py b/tests/api_resources/ai_gateway/test_logs.py index 78439db3a89..485dc79d148 100644 --- a/tests/api_resources/ai_gateway/test_logs.py +++ b/tests/api_resources/ai_gateway/test_logs.py @@ -10,7 +10,8 @@ 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 +from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray +from cloudflare.types.ai_gateway import LogGetResponse, LogListResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -19,16 +20,16 @@ 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( + def test_method_list(self, client: Cloudflare) -> None: + log = client.ai_gateway.logs.list( "my-gateway", account_id="0d37909e38d3e99c29fa2cd343ac421a", ) - assert_matches_type(LogGetResponse, log, path=["response"]) + assert_matches_type(SyncV4PagePaginationArray[LogListResponse], log, path=["response"]) @parametrize - def test_method_get_with_all_params(self, client: Cloudflare) -> None: - log = client.ai_gateway.logs.get( + def test_method_list_with_all_params(self, client: Cloudflare) -> None: + log = client.ai_gateway.logs.list( "my-gateway", account_id="0d37909e38d3e99c29fa2cd343ac421a", cached=True, @@ -41,13 +42,63 @@ def test_method_get_with_all_params(self, client: Cloudflare) -> None: start_date=parse_datetime("2019-12-27T18:11:19.117Z"), success=True, ) + assert_matches_type(SyncV4PagePaginationArray[LogListResponse], log, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.ai_gateway.logs.with_raw_response.list( + "my-gateway", + account_id="0d37909e38d3e99c29fa2cd343ac421a", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + log = response.parse() + assert_matches_type(SyncV4PagePaginationArray[LogListResponse], log, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.ai_gateway.logs.with_streaming_response.list( + "my-gateway", + account_id="0d37909e38d3e99c29fa2cd343ac421a", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + log = response.parse() + assert_matches_type(SyncV4PagePaginationArray[LogListResponse], log, 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_id` but received ''"): + client.ai_gateway.logs.with_raw_response.list( + "my-gateway", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.ai_gateway.logs.with_raw_response.list( + "", + account_id="0d37909e38d3e99c29fa2cd343ac421a", + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + log = client.ai_gateway.logs.get( + "string", + account_id="0d37909e38d3e99c29fa2cd343ac421a", + id="my-gateway", + ) assert_matches_type(LogGetResponse, log, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: response = client.ai_gateway.logs.with_raw_response.get( - "my-gateway", + "string", account_id="0d37909e38d3e99c29fa2cd343ac421a", + id="my-gateway", ) assert response.is_closed is True @@ -58,8 +109,9 @@ def test_raw_response_get(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: with client.ai_gateway.logs.with_streaming_response.get( - "my-gateway", + "string", account_id="0d37909e38d3e99c29fa2cd343ac421a", + id="my-gateway", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -73,14 +125,23 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: def test_path_params_get(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): client.ai_gateway.logs.with_raw_response.get( - "my-gateway", + "string", account_id="", + id="my-gateway", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.ai_gateway.logs.with_raw_response.get( + "string", + account_id="0d37909e38d3e99c29fa2cd343ac421a", + id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `log_id` but received ''"): client.ai_gateway.logs.with_raw_response.get( "", account_id="0d37909e38d3e99c29fa2cd343ac421a", + id="my-gateway", ) @@ -88,16 +149,16 @@ 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( + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + log = await async_client.ai_gateway.logs.list( "my-gateway", account_id="0d37909e38d3e99c29fa2cd343ac421a", ) - assert_matches_type(LogGetResponse, log, path=["response"]) + assert_matches_type(AsyncV4PagePaginationArray[LogListResponse], 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( + async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: + log = await async_client.ai_gateway.logs.list( "my-gateway", account_id="0d37909e38d3e99c29fa2cd343ac421a", cached=True, @@ -110,13 +171,63 @@ async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) - start_date=parse_datetime("2019-12-27T18:11:19.117Z"), success=True, ) + assert_matches_type(AsyncV4PagePaginationArray[LogListResponse], log, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.ai_gateway.logs.with_raw_response.list( + "my-gateway", + account_id="0d37909e38d3e99c29fa2cd343ac421a", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + log = await response.parse() + assert_matches_type(AsyncV4PagePaginationArray[LogListResponse], log, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.ai_gateway.logs.with_streaming_response.list( + "my-gateway", + account_id="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(AsyncV4PagePaginationArray[LogListResponse], log, 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_id` but received ''"): + await async_client.ai_gateway.logs.with_raw_response.list( + "my-gateway", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.ai_gateway.logs.with_raw_response.list( + "", + account_id="0d37909e38d3e99c29fa2cd343ac421a", + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + log = await async_client.ai_gateway.logs.get( + "string", + account_id="0d37909e38d3e99c29fa2cd343ac421a", + id="my-gateway", + ) assert_matches_type(LogGetResponse, log, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: response = await async_client.ai_gateway.logs.with_raw_response.get( - "my-gateway", + "string", account_id="0d37909e38d3e99c29fa2cd343ac421a", + id="my-gateway", ) assert response.is_closed is True @@ -127,8 +238,9 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: async with async_client.ai_gateway.logs.with_streaming_response.get( - "my-gateway", + "string", account_id="0d37909e38d3e99c29fa2cd343ac421a", + id="my-gateway", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -142,12 +254,21 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): await async_client.ai_gateway.logs.with_raw_response.get( - "my-gateway", + "string", account_id="", + id="my-gateway", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.ai_gateway.logs.with_raw_response.get( + "string", + account_id="0d37909e38d3e99c29fa2cd343ac421a", + id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `log_id` but received ''"): await async_client.ai_gateway.logs.with_raw_response.get( "", account_id="0d37909e38d3e99c29fa2cd343ac421a", + id="my-gateway", ) diff --git a/tests/api_resources/stream/captions/test_language.py b/tests/api_resources/stream/captions/test_language.py index 15caab5410b..cdcc495bcd5 100644 --- a/tests/api_resources/stream/captions/test_language.py +++ b/tests/api_resources/stream/captions/test_language.py @@ -17,6 +17,66 @@ class TestLanguage: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + @parametrize + def test_method_create(self, client: Cloudflare) -> None: + language = client.stream.captions.language.create( + "tr", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="ea95132c15732412d22c1476fa83f27a", + ) + assert_matches_type(Optional[Caption], language, path=["response"]) + + @parametrize + def test_raw_response_create(self, client: Cloudflare) -> None: + response = client.stream.captions.language.with_raw_response.create( + "tr", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="ea95132c15732412d22c1476fa83f27a", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + language = response.parse() + assert_matches_type(Optional[Caption], language, path=["response"]) + + @parametrize + def test_streaming_response_create(self, client: Cloudflare) -> None: + with client.stream.captions.language.with_streaming_response.create( + "tr", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="ea95132c15732412d22c1476fa83f27a", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + language = response.parse() + assert_matches_type(Optional[Caption], language, 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_id` but received ''"): + client.stream.captions.language.with_raw_response.create( + "tr", + account_id="", + identifier="ea95132c15732412d22c1476fa83f27a", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identifier` but received ''"): + client.stream.captions.language.with_raw_response.create( + "tr", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `language` but received ''"): + client.stream.captions.language.with_raw_response.create( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="ea95132c15732412d22c1476fa83f27a", + ) + @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_method_update(self, client: Cloudflare) -> None: @@ -211,6 +271,66 @@ def test_path_params_get(self, client: Cloudflare) -> None: class TestAsyncLanguage: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + @parametrize + async def test_method_create(self, async_client: AsyncCloudflare) -> None: + language = await async_client.stream.captions.language.create( + "tr", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="ea95132c15732412d22c1476fa83f27a", + ) + assert_matches_type(Optional[Caption], language, path=["response"]) + + @parametrize + async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: + response = await async_client.stream.captions.language.with_raw_response.create( + "tr", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="ea95132c15732412d22c1476fa83f27a", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + language = await response.parse() + assert_matches_type(Optional[Caption], language, path=["response"]) + + @parametrize + async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: + async with async_client.stream.captions.language.with_streaming_response.create( + "tr", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="ea95132c15732412d22c1476fa83f27a", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + language = await response.parse() + assert_matches_type(Optional[Caption], language, 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_id` but received ''"): + await async_client.stream.captions.language.with_raw_response.create( + "tr", + account_id="", + identifier="ea95132c15732412d22c1476fa83f27a", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identifier` but received ''"): + await async_client.stream.captions.language.with_raw_response.create( + "tr", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `language` but received ''"): + await async_client.stream.captions.language.with_raw_response.create( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="ea95132c15732412d22c1476fa83f27a", + ) + @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_method_update(self, async_client: AsyncCloudflare) -> None: diff --git a/tests/api_resources/zero_trust/gateway/test_certificates.py b/tests/api_resources/zero_trust/gateway/test_certificates.py new file mode 100644 index 00000000000..c84aaa00883 --- /dev/null +++ b/tests/api_resources/zero_trust/gateway/test_certificates.py @@ -0,0 +1,388 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, Optional, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.pagination import SyncSinglePage, AsyncSinglePage +from cloudflare.types.zero_trust.gateway import ( + CertificateGetResponse, + CertificateListResponse, + CertificateCreateResponse, + CertificateDeleteResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestCertificates: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_create(self, client: Cloudflare) -> None: + certificate = client.zero_trust.gateway.certificates.create( + account_id="699d98642c564d2e855e9661899b7252", + ) + assert_matches_type(Optional[CertificateCreateResponse], certificate, path=["response"]) + + @parametrize + def test_method_create_with_all_params(self, client: Cloudflare) -> None: + certificate = client.zero_trust.gateway.certificates.create( + account_id="699d98642c564d2e855e9661899b7252", + validity_period_days=1826, + ) + assert_matches_type(Optional[CertificateCreateResponse], certificate, path=["response"]) + + @parametrize + def test_raw_response_create(self, client: Cloudflare) -> None: + response = client.zero_trust.gateway.certificates.with_raw_response.create( + account_id="699d98642c564d2e855e9661899b7252", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + certificate = response.parse() + assert_matches_type(Optional[CertificateCreateResponse], certificate, path=["response"]) + + @parametrize + def test_streaming_response_create(self, client: Cloudflare) -> None: + with client.zero_trust.gateway.certificates.with_streaming_response.create( + account_id="699d98642c564d2e855e9661899b7252", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + certificate = response.parse() + assert_matches_type(Optional[CertificateCreateResponse], certificate, 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_id` but received ''"): + client.zero_trust.gateway.certificates.with_raw_response.create( + account_id="", + ) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + certificate = client.zero_trust.gateway.certificates.list( + account_id="699d98642c564d2e855e9661899b7252", + ) + assert_matches_type(SyncSinglePage[CertificateListResponse], certificate, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.zero_trust.gateway.certificates.with_raw_response.list( + account_id="699d98642c564d2e855e9661899b7252", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + certificate = response.parse() + assert_matches_type(SyncSinglePage[CertificateListResponse], certificate, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.zero_trust.gateway.certificates.with_streaming_response.list( + account_id="699d98642c564d2e855e9661899b7252", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + certificate = response.parse() + assert_matches_type(SyncSinglePage[CertificateListResponse], certificate, 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_id` but received ''"): + client.zero_trust.gateway.certificates.with_raw_response.list( + account_id="", + ) + + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + certificate = client.zero_trust.gateway.certificates.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="699d98642c564d2e855e9661899b7252", + ) + assert_matches_type(Optional[CertificateDeleteResponse], certificate, path=["response"]) + + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.zero_trust.gateway.certificates.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="699d98642c564d2e855e9661899b7252", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + certificate = response.parse() + assert_matches_type(Optional[CertificateDeleteResponse], certificate, path=["response"]) + + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.zero_trust.gateway.certificates.with_streaming_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="699d98642c564d2e855e9661899b7252", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + certificate = response.parse() + assert_matches_type(Optional[CertificateDeleteResponse], certificate, 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_id` but received ''"): + client.zero_trust.gateway.certificates.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `certificate_id` but received ''"): + client.zero_trust.gateway.certificates.with_raw_response.delete( + "", + account_id="699d98642c564d2e855e9661899b7252", + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + certificate = client.zero_trust.gateway.certificates.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="699d98642c564d2e855e9661899b7252", + ) + assert_matches_type(Optional[CertificateGetResponse], certificate, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.zero_trust.gateway.certificates.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="699d98642c564d2e855e9661899b7252", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + certificate = response.parse() + assert_matches_type(Optional[CertificateGetResponse], certificate, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.zero_trust.gateway.certificates.with_streaming_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="699d98642c564d2e855e9661899b7252", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + certificate = response.parse() + assert_matches_type(Optional[CertificateGetResponse], certificate, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.gateway.certificates.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `certificate_id` but received ''"): + client.zero_trust.gateway.certificates.with_raw_response.get( + "", + account_id="699d98642c564d2e855e9661899b7252", + ) + + +class TestAsyncCertificates: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_create(self, async_client: AsyncCloudflare) -> None: + certificate = await async_client.zero_trust.gateway.certificates.create( + account_id="699d98642c564d2e855e9661899b7252", + ) + assert_matches_type(Optional[CertificateCreateResponse], certificate, path=["response"]) + + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: + certificate = await async_client.zero_trust.gateway.certificates.create( + account_id="699d98642c564d2e855e9661899b7252", + validity_period_days=1826, + ) + assert_matches_type(Optional[CertificateCreateResponse], certificate, path=["response"]) + + @parametrize + async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.gateway.certificates.with_raw_response.create( + account_id="699d98642c564d2e855e9661899b7252", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + certificate = await response.parse() + assert_matches_type(Optional[CertificateCreateResponse], certificate, path=["response"]) + + @parametrize + async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.gateway.certificates.with_streaming_response.create( + account_id="699d98642c564d2e855e9661899b7252", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + certificate = await response.parse() + assert_matches_type(Optional[CertificateCreateResponse], certificate, 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_id` but received ''"): + await async_client.zero_trust.gateway.certificates.with_raw_response.create( + account_id="", + ) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + certificate = await async_client.zero_trust.gateway.certificates.list( + account_id="699d98642c564d2e855e9661899b7252", + ) + assert_matches_type(AsyncSinglePage[CertificateListResponse], certificate, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.gateway.certificates.with_raw_response.list( + account_id="699d98642c564d2e855e9661899b7252", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + certificate = await response.parse() + assert_matches_type(AsyncSinglePage[CertificateListResponse], certificate, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.gateway.certificates.with_streaming_response.list( + account_id="699d98642c564d2e855e9661899b7252", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + certificate = await response.parse() + assert_matches_type(AsyncSinglePage[CertificateListResponse], certificate, 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_id` but received ''"): + await async_client.zero_trust.gateway.certificates.with_raw_response.list( + account_id="", + ) + + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + certificate = await async_client.zero_trust.gateway.certificates.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="699d98642c564d2e855e9661899b7252", + ) + assert_matches_type(Optional[CertificateDeleteResponse], certificate, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.gateway.certificates.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="699d98642c564d2e855e9661899b7252", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + certificate = await response.parse() + assert_matches_type(Optional[CertificateDeleteResponse], certificate, path=["response"]) + + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.gateway.certificates.with_streaming_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="699d98642c564d2e855e9661899b7252", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + certificate = await response.parse() + assert_matches_type(Optional[CertificateDeleteResponse], certificate, 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_id` but received ''"): + await async_client.zero_trust.gateway.certificates.with_raw_response.delete( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `certificate_id` but received ''"): + await async_client.zero_trust.gateway.certificates.with_raw_response.delete( + "", + account_id="699d98642c564d2e855e9661899b7252", + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + certificate = await async_client.zero_trust.gateway.certificates.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="699d98642c564d2e855e9661899b7252", + ) + assert_matches_type(Optional[CertificateGetResponse], certificate, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.gateway.certificates.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="699d98642c564d2e855e9661899b7252", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + certificate = await response.parse() + assert_matches_type(Optional[CertificateGetResponse], certificate, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.gateway.certificates.with_streaming_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="699d98642c564d2e855e9661899b7252", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + certificate = await response.parse() + assert_matches_type(Optional[CertificateGetResponse], certificate, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.zero_trust.gateway.certificates.with_raw_response.get( + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `certificate_id` but received ''"): + await async_client.zero_trust.gateway.certificates.with_raw_response.get( + "", + account_id="699d98642c564d2e855e9661899b7252", + )