From 0be54b1440ab2ef694c7fef167409d8450ee37d4 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 2 Mar 2026 22:19:39 +0000 Subject: [PATCH 01/12] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index b047b943714..2353815a6b9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 2041 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9ba099b7936091cc984d2a24fc4d32c3ffcb1d71d86412c8c9084d201e16b3ac.yml openapi_spec_hash: 45edc9a107cf5a5e3b204b230b0d336d -config_hash: be3f6e9410db673744447f9dbe92d922 +config_hash: 5d8bd5002a6f78b6f162dc0420e905bf From c5144a0ae90e1f21df2916fe9624b4dcd5af1967 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 2 Mar 2026 22:38:34 +0000 Subject: [PATCH 02/12] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 2353815a6b9..f3fc049aeb0 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 2041 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9ba099b7936091cc984d2a24fc4d32c3ffcb1d71d86412c8c9084d201e16b3ac.yml openapi_spec_hash: 45edc9a107cf5a5e3b204b230b0d336d -config_hash: 5d8bd5002a6f78b6f162dc0420e905bf +config_hash: 96b952e0e131fab925a95b84c093c64e From 3ed409f13d288ae7b9d31adadd6ffa1309b2a6ba Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 3 Mar 2026 15:38:45 +0000 Subject: [PATCH 03/12] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index f3fc049aeb0..70ac7864dee 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 2041 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9ba099b7936091cc984d2a24fc4d32c3ffcb1d71d86412c8c9084d201e16b3ac.yml openapi_spec_hash: 45edc9a107cf5a5e3b204b230b0d336d -config_hash: 96b952e0e131fab925a95b84c093c64e +config_hash: 9ee8129db73d90fd901d8b8a6ad1f3c2 From 559adb6b91ad5904b0aaac575ce02e0bbfdb6584 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 4 Mar 2026 18:02:38 +0000 Subject: [PATCH 04/12] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 70ac7864dee..a779a860942 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 2041 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9ba099b7936091cc984d2a24fc4d32c3ffcb1d71d86412c8c9084d201e16b3ac.yml openapi_spec_hash: 45edc9a107cf5a5e3b204b230b0d336d -config_hash: 9ee8129db73d90fd901d8b8a6ad1f3c2 +config_hash: 0768e14fdc9dec28e0031cf533c601e6 From c1fdeae1ec8cb33145101286fcd97576e36f532d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 4 Mar 2026 19:02:02 +0000 Subject: [PATCH 05/12] feat: feat(workers): WO-989 Adds Workers>Observability>Destinations resources * feat(workers): WO-989 Adds Workers>Observability>Destinations resources --- .stats.yml | 4 +- api.md | 20 + .../workers/observability/__init__.py | 14 + .../workers/observability/destinations.py | 525 +++++++++++++++++ .../workers/observability/observability.py | 32 + .../types/workers/observability/__init__.py | 7 + .../destination_create_params.py | 34 ++ .../destination_create_response.py | 34 ++ .../destination_delete_response.py | 34 ++ .../observability/destination_list_params.py | 21 + .../destination_list_response.py | 44 ++ .../destination_update_params.py | 24 + .../destination_update_response.py | 34 ++ .../observability/test_destinations.py | 552 ++++++++++++++++++ 14 files changed, 1377 insertions(+), 2 deletions(-) create mode 100644 src/cloudflare/resources/workers/observability/destinations.py create mode 100644 src/cloudflare/types/workers/observability/destination_create_params.py create mode 100644 src/cloudflare/types/workers/observability/destination_create_response.py create mode 100644 src/cloudflare/types/workers/observability/destination_delete_response.py create mode 100644 src/cloudflare/types/workers/observability/destination_list_params.py create mode 100644 src/cloudflare/types/workers/observability/destination_list_response.py create mode 100644 src/cloudflare/types/workers/observability/destination_update_params.py create mode 100644 src/cloudflare/types/workers/observability/destination_update_response.py create mode 100644 tests/api_resources/workers/observability/test_destinations.py diff --git a/.stats.yml b/.stats.yml index a779a860942..ba380523a09 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 2041 +configured_endpoints: 2045 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9ba099b7936091cc984d2a24fc4d32c3ffcb1d71d86412c8c9084d201e16b3ac.yml openapi_spec_hash: 45edc9a107cf5a5e3b204b230b0d336d -config_hash: 0768e14fdc9dec28e0031cf533c601e6 +config_hash: c8f6f451ad44a8349b1876f50735189a diff --git a/api.md b/api.md index 3f5cd6f421a..75d39498134 100644 --- a/api.md +++ b/api.md @@ -2672,6 +2672,26 @@ Methods: - client.workers.observability.telemetry.query(\*, account_id, \*\*params) -> TelemetryQueryResponse - client.workers.observability.telemetry.values(\*, account_id, \*\*params) -> SyncSinglePage[TelemetryValuesResponse] +### Destinations + +Types: + +```python +from cloudflare.types.workers.observability import ( + DestinationCreateResponse, + DestinationUpdateResponse, + DestinationListResponse, + DestinationDeleteResponse, +) +``` + +Methods: + +- client.workers.observability.destinations.create(\*, account_id, \*\*params) -> DestinationCreateResponse +- client.workers.observability.destinations.update(slug, \*, account_id, \*\*params) -> DestinationUpdateResponse +- client.workers.observability.destinations.list(\*, account_id, \*\*params) -> SyncSinglePage[DestinationListResponse] +- client.workers.observability.destinations.delete(slug, \*, account_id) -> Optional[DestinationDeleteResponse] + # KV ## Namespaces diff --git a/src/cloudflare/resources/workers/observability/__init__.py b/src/cloudflare/resources/workers/observability/__init__.py index aa9190629cd..1e48df79576 100644 --- a/src/cloudflare/resources/workers/observability/__init__.py +++ b/src/cloudflare/resources/workers/observability/__init__.py @@ -8,6 +8,14 @@ TelemetryResourceWithStreamingResponse, AsyncTelemetryResourceWithStreamingResponse, ) +from .destinations import ( + DestinationsResource, + AsyncDestinationsResource, + DestinationsResourceWithRawResponse, + AsyncDestinationsResourceWithRawResponse, + DestinationsResourceWithStreamingResponse, + AsyncDestinationsResourceWithStreamingResponse, +) from .observability import ( ObservabilityResource, AsyncObservabilityResource, @@ -24,6 +32,12 @@ "AsyncTelemetryResourceWithRawResponse", "TelemetryResourceWithStreamingResponse", "AsyncTelemetryResourceWithStreamingResponse", + "DestinationsResource", + "AsyncDestinationsResource", + "DestinationsResourceWithRawResponse", + "AsyncDestinationsResourceWithRawResponse", + "DestinationsResourceWithStreamingResponse", + "AsyncDestinationsResourceWithStreamingResponse", "ObservabilityResource", "AsyncObservabilityResource", "ObservabilityResourceWithRawResponse", diff --git a/src/cloudflare/resources/workers/observability/destinations.py b/src/cloudflare/resources/workers/observability/destinations.py new file mode 100644 index 00000000000..26a156b902d --- /dev/null +++ b/src/cloudflare/resources/workers/observability/destinations.py @@ -0,0 +1,525 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Optional, cast +from typing_extensions import Literal + +import httpx + +from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +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.workers.observability import ( + destination_list_params, + destination_create_params, + destination_update_params, +) +from ....types.workers.observability.destination_list_response import DestinationListResponse +from ....types.workers.observability.destination_create_response import DestinationCreateResponse +from ....types.workers.observability.destination_delete_response import DestinationDeleteResponse +from ....types.workers.observability.destination_update_response import DestinationUpdateResponse + +__all__ = ["DestinationsResource", "AsyncDestinationsResource"] + + +class DestinationsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> DestinationsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return DestinationsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> DestinationsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return DestinationsResourceWithStreamingResponse(self) + + def create( + self, + *, + account_id: str, + configuration: destination_create_params.Configuration, + enabled: bool, + name: str, + skip_preflight_check: bool | Omit = omit, + # 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, + ) -> DestinationCreateResponse: + """ + Create a new Workers Observability Telemetry Destination. + + 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._post( + f"/accounts/{account_id}/workers/observability/destinations", + body=maybe_transform( + { + "configuration": configuration, + "enabled": enabled, + "name": name, + "skip_preflight_check": skip_preflight_check, + }, + destination_create_params.DestinationCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[DestinationCreateResponse]._unwrapper, + ), + cast_to=cast(Type[DestinationCreateResponse], ResultWrapper[DestinationCreateResponse]), + ) + + def update( + self, + slug: str, + *, + account_id: str, + configuration: destination_update_params.Configuration, + enabled: bool, + # 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, + ) -> DestinationUpdateResponse: + """ + Update an existing Workers Observability Telemetry Destination. + + 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}") + if not slug: + raise ValueError(f"Expected a non-empty value for `slug` but received {slug!r}") + return self._patch( + f"/accounts/{account_id}/workers/observability/destinations/{slug}", + body=maybe_transform( + { + "configuration": configuration, + "enabled": enabled, + }, + destination_update_params.DestinationUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[DestinationUpdateResponse]._unwrapper, + ), + cast_to=cast(Type[DestinationUpdateResponse], ResultWrapper[DestinationUpdateResponse]), + ) + + def list( + self, + *, + account_id: str, + order: Literal["asc", "desc"] | Omit = omit, + order_by: Literal["created", "updated"] | Omit = omit, + page: float | Omit = omit, + per_page: float | Omit = omit, + # 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[DestinationListResponse]: + """ + List your Workers Observability Telemetry Destinations. + + 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}/workers/observability/destinations", + page=SyncSinglePage[DestinationListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "order": order, + "order_by": order_by, + "page": page, + "per_page": per_page, + }, + destination_list_params.DestinationListParams, + ), + ), + model=DestinationListResponse, + ) + + def delete( + self, + slug: 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[DestinationDeleteResponse]: + """ + Delete a Workers Observability Telemetry Destination. + + 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}") + if not slug: + raise ValueError(f"Expected a non-empty value for `slug` but received {slug!r}") + return self._delete( + f"/accounts/{account_id}/workers/observability/destinations/{slug}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[DestinationDeleteResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[DestinationDeleteResponse]], ResultWrapper[DestinationDeleteResponse]), + ) + + +class AsyncDestinationsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncDestinationsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncDestinationsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncDestinationsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncDestinationsResourceWithStreamingResponse(self) + + async def create( + self, + *, + account_id: str, + configuration: destination_create_params.Configuration, + enabled: bool, + name: str, + skip_preflight_check: bool | Omit = omit, + # 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, + ) -> DestinationCreateResponse: + """ + Create a new Workers Observability Telemetry Destination. + + 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 await self._post( + f"/accounts/{account_id}/workers/observability/destinations", + body=await async_maybe_transform( + { + "configuration": configuration, + "enabled": enabled, + "name": name, + "skip_preflight_check": skip_preflight_check, + }, + destination_create_params.DestinationCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[DestinationCreateResponse]._unwrapper, + ), + cast_to=cast(Type[DestinationCreateResponse], ResultWrapper[DestinationCreateResponse]), + ) + + async def update( + self, + slug: str, + *, + account_id: str, + configuration: destination_update_params.Configuration, + enabled: bool, + # 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, + ) -> DestinationUpdateResponse: + """ + Update an existing Workers Observability Telemetry Destination. + + 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}") + if not slug: + raise ValueError(f"Expected a non-empty value for `slug` but received {slug!r}") + return await self._patch( + f"/accounts/{account_id}/workers/observability/destinations/{slug}", + body=await async_maybe_transform( + { + "configuration": configuration, + "enabled": enabled, + }, + destination_update_params.DestinationUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[DestinationUpdateResponse]._unwrapper, + ), + cast_to=cast(Type[DestinationUpdateResponse], ResultWrapper[DestinationUpdateResponse]), + ) + + def list( + self, + *, + account_id: str, + order: Literal["asc", "desc"] | Omit = omit, + order_by: Literal["created", "updated"] | Omit = omit, + page: float | Omit = omit, + per_page: float | Omit = omit, + # 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[DestinationListResponse, AsyncSinglePage[DestinationListResponse]]: + """ + List your Workers Observability Telemetry Destinations. + + 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}/workers/observability/destinations", + page=AsyncSinglePage[DestinationListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "order": order, + "order_by": order_by, + "page": page, + "per_page": per_page, + }, + destination_list_params.DestinationListParams, + ), + ), + model=DestinationListResponse, + ) + + async def delete( + self, + slug: 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[DestinationDeleteResponse]: + """ + Delete a Workers Observability Telemetry Destination. + + 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}") + if not slug: + raise ValueError(f"Expected a non-empty value for `slug` but received {slug!r}") + return await self._delete( + f"/accounts/{account_id}/workers/observability/destinations/{slug}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[DestinationDeleteResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[DestinationDeleteResponse]], ResultWrapper[DestinationDeleteResponse]), + ) + + +class DestinationsResourceWithRawResponse: + def __init__(self, destinations: DestinationsResource) -> None: + self._destinations = destinations + + self.create = to_raw_response_wrapper( + destinations.create, + ) + self.update = to_raw_response_wrapper( + destinations.update, + ) + self.list = to_raw_response_wrapper( + destinations.list, + ) + self.delete = to_raw_response_wrapper( + destinations.delete, + ) + + +class AsyncDestinationsResourceWithRawResponse: + def __init__(self, destinations: AsyncDestinationsResource) -> None: + self._destinations = destinations + + self.create = async_to_raw_response_wrapper( + destinations.create, + ) + self.update = async_to_raw_response_wrapper( + destinations.update, + ) + self.list = async_to_raw_response_wrapper( + destinations.list, + ) + self.delete = async_to_raw_response_wrapper( + destinations.delete, + ) + + +class DestinationsResourceWithStreamingResponse: + def __init__(self, destinations: DestinationsResource) -> None: + self._destinations = destinations + + self.create = to_streamed_response_wrapper( + destinations.create, + ) + self.update = to_streamed_response_wrapper( + destinations.update, + ) + self.list = to_streamed_response_wrapper( + destinations.list, + ) + self.delete = to_streamed_response_wrapper( + destinations.delete, + ) + + +class AsyncDestinationsResourceWithStreamingResponse: + def __init__(self, destinations: AsyncDestinationsResource) -> None: + self._destinations = destinations + + self.create = async_to_streamed_response_wrapper( + destinations.create, + ) + self.update = async_to_streamed_response_wrapper( + destinations.update, + ) + self.list = async_to_streamed_response_wrapper( + destinations.list, + ) + self.delete = async_to_streamed_response_wrapper( + destinations.delete, + ) diff --git a/src/cloudflare/resources/workers/observability/observability.py b/src/cloudflare/resources/workers/observability/observability.py index 7e09842a71a..e1caadbdd68 100644 --- a/src/cloudflare/resources/workers/observability/observability.py +++ b/src/cloudflare/resources/workers/observability/observability.py @@ -12,6 +12,14 @@ ) from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource +from .destinations import ( + DestinationsResource, + AsyncDestinationsResource, + DestinationsResourceWithRawResponse, + AsyncDestinationsResourceWithRawResponse, + DestinationsResourceWithStreamingResponse, + AsyncDestinationsResourceWithStreamingResponse, +) __all__ = ["ObservabilityResource", "AsyncObservabilityResource"] @@ -21,6 +29,10 @@ class ObservabilityResource(SyncAPIResource): def telemetry(self) -> TelemetryResource: return TelemetryResource(self._client) + @cached_property + def destinations(self) -> DestinationsResource: + return DestinationsResource(self._client) + @cached_property def with_raw_response(self) -> ObservabilityResourceWithRawResponse: """ @@ -46,6 +58,10 @@ class AsyncObservabilityResource(AsyncAPIResource): def telemetry(self) -> AsyncTelemetryResource: return AsyncTelemetryResource(self._client) + @cached_property + def destinations(self) -> AsyncDestinationsResource: + return AsyncDestinationsResource(self._client) + @cached_property def with_raw_response(self) -> AsyncObservabilityResourceWithRawResponse: """ @@ -74,6 +90,10 @@ def __init__(self, observability: ObservabilityResource) -> None: def telemetry(self) -> TelemetryResourceWithRawResponse: return TelemetryResourceWithRawResponse(self._observability.telemetry) + @cached_property + def destinations(self) -> DestinationsResourceWithRawResponse: + return DestinationsResourceWithRawResponse(self._observability.destinations) + class AsyncObservabilityResourceWithRawResponse: def __init__(self, observability: AsyncObservabilityResource) -> None: @@ -83,6 +103,10 @@ def __init__(self, observability: AsyncObservabilityResource) -> None: def telemetry(self) -> AsyncTelemetryResourceWithRawResponse: return AsyncTelemetryResourceWithRawResponse(self._observability.telemetry) + @cached_property + def destinations(self) -> AsyncDestinationsResourceWithRawResponse: + return AsyncDestinationsResourceWithRawResponse(self._observability.destinations) + class ObservabilityResourceWithStreamingResponse: def __init__(self, observability: ObservabilityResource) -> None: @@ -92,6 +116,10 @@ def __init__(self, observability: ObservabilityResource) -> None: def telemetry(self) -> TelemetryResourceWithStreamingResponse: return TelemetryResourceWithStreamingResponse(self._observability.telemetry) + @cached_property + def destinations(self) -> DestinationsResourceWithStreamingResponse: + return DestinationsResourceWithStreamingResponse(self._observability.destinations) + class AsyncObservabilityResourceWithStreamingResponse: def __init__(self, observability: AsyncObservabilityResource) -> None: @@ -100,3 +128,7 @@ def __init__(self, observability: AsyncObservabilityResource) -> None: @cached_property def telemetry(self) -> AsyncTelemetryResourceWithStreamingResponse: return AsyncTelemetryResourceWithStreamingResponse(self._observability.telemetry) + + @cached_property + def destinations(self) -> AsyncDestinationsResourceWithStreamingResponse: + return AsyncDestinationsResourceWithStreamingResponse(self._observability.destinations) diff --git a/src/cloudflare/types/workers/observability/__init__.py b/src/cloudflare/types/workers/observability/__init__.py index 0aaa1d0adea..aa4075caf4b 100644 --- a/src/cloudflare/types/workers/observability/__init__.py +++ b/src/cloudflare/types/workers/observability/__init__.py @@ -4,7 +4,14 @@ from .telemetry_keys_params import TelemetryKeysParams as TelemetryKeysParams from .telemetry_query_params import TelemetryQueryParams as TelemetryQueryParams +from .destination_list_params import DestinationListParams as DestinationListParams from .telemetry_keys_response import TelemetryKeysResponse as TelemetryKeysResponse from .telemetry_values_params import TelemetryValuesParams as TelemetryValuesParams from .telemetry_query_response import TelemetryQueryResponse as TelemetryQueryResponse +from .destination_create_params import DestinationCreateParams as DestinationCreateParams +from .destination_list_response import DestinationListResponse as DestinationListResponse +from .destination_update_params import DestinationUpdateParams as DestinationUpdateParams from .telemetry_values_response import TelemetryValuesResponse as TelemetryValuesResponse +from .destination_create_response import DestinationCreateResponse as DestinationCreateResponse +from .destination_delete_response import DestinationDeleteResponse as DestinationDeleteResponse +from .destination_update_response import DestinationUpdateResponse as DestinationUpdateResponse diff --git a/src/cloudflare/types/workers/observability/destination_create_params.py b/src/cloudflare/types/workers/observability/destination_create_params.py new file mode 100644 index 00000000000..9af45a3f4fc --- /dev/null +++ b/src/cloudflare/types/workers/observability/destination_create_params.py @@ -0,0 +1,34 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict +from typing_extensions import Literal, Required, Annotated, TypedDict + +from ...._utils import PropertyInfo + +__all__ = ["DestinationCreateParams", "Configuration"] + + +class DestinationCreateParams(TypedDict, total=False): + account_id: Required[str] + + configuration: Required[Configuration] + + enabled: Required[bool] + + name: Required[str] + + skip_preflight_check: Annotated[bool, PropertyInfo(alias="skipPreflightCheck")] + + +class Configuration(TypedDict, total=False): + headers: Required[Dict[str, str]] + + logpush_dataset: Required[ + Annotated[Literal["opentelemetry-traces", "opentelemetry-logs"], PropertyInfo(alias="logpushDataset")] + ] + + type: Required[Literal["logpush"]] + + url: Required[str] diff --git a/src/cloudflare/types/workers/observability/destination_create_response.py b/src/cloudflare/types/workers/observability/destination_create_response.py new file mode 100644 index 00000000000..d84b9645bb1 --- /dev/null +++ b/src/cloudflare/types/workers/observability/destination_create_response.py @@ -0,0 +1,34 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from ...._models import BaseModel + +__all__ = ["DestinationCreateResponse", "Configuration"] + + +class Configuration(BaseModel): + destination_conf: str + + logpush_dataset: Literal["opentelemetry-traces", "opentelemetry-logs"] = FieldInfo(alias="logpushDataset") + + logpush_job: float = FieldInfo(alias="logpushJob") + + type: Literal["logpush"] + + url: str + + +class DestinationCreateResponse(BaseModel): + configuration: Configuration + + enabled: bool + + name: str + + scripts: List[str] + + slug: str diff --git a/src/cloudflare/types/workers/observability/destination_delete_response.py b/src/cloudflare/types/workers/observability/destination_delete_response.py new file mode 100644 index 00000000000..953d92ce9ef --- /dev/null +++ b/src/cloudflare/types/workers/observability/destination_delete_response.py @@ -0,0 +1,34 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from ...._models import BaseModel + +__all__ = ["DestinationDeleteResponse", "Configuration"] + + +class Configuration(BaseModel): + destination_conf: str + + logpush_dataset: Literal["opentelemetry-traces", "opentelemetry-logs"] = FieldInfo(alias="logpushDataset") + + logpush_job: float = FieldInfo(alias="logpushJob") + + type: Literal["logpush"] + + url: str + + +class DestinationDeleteResponse(BaseModel): + configuration: Configuration + + enabled: bool + + name: str + + scripts: List[str] + + slug: str diff --git a/src/cloudflare/types/workers/observability/destination_list_params.py b/src/cloudflare/types/workers/observability/destination_list_params.py new file mode 100644 index 00000000000..85d6519f33d --- /dev/null +++ b/src/cloudflare/types/workers/observability/destination_list_params.py @@ -0,0 +1,21 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, Required, Annotated, TypedDict + +from ...._utils import PropertyInfo + +__all__ = ["DestinationListParams"] + + +class DestinationListParams(TypedDict, total=False): + account_id: Required[str] + + order: Literal["asc", "desc"] + + order_by: Annotated[Literal["created", "updated"], PropertyInfo(alias="orderBy")] + + page: float + + per_page: Annotated[float, PropertyInfo(alias="perPage")] diff --git a/src/cloudflare/types/workers/observability/destination_list_response.py b/src/cloudflare/types/workers/observability/destination_list_response.py new file mode 100644 index 00000000000..75ac1e0847e --- /dev/null +++ b/src/cloudflare/types/workers/observability/destination_list_response.py @@ -0,0 +1,44 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, List +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from ...._models import BaseModel + +__all__ = ["DestinationListResponse", "Configuration", "ConfigurationJobStatus"] + + +class ConfigurationJobStatus(BaseModel): + error_message: str + + last_complete: str + + last_error: str + + +class Configuration(BaseModel): + destination_conf: str + + headers: Dict[str, str] + + job_status: ConfigurationJobStatus = FieldInfo(alias="jobStatus") + + logpush_dataset: Literal["opentelemetry-traces", "opentelemetry-logs"] = FieldInfo(alias="logpushDataset") + + type: Literal["logpush"] + + url: str + + +class DestinationListResponse(BaseModel): + configuration: Configuration + + enabled: bool + + name: str + + scripts: List[str] + + slug: str diff --git a/src/cloudflare/types/workers/observability/destination_update_params.py b/src/cloudflare/types/workers/observability/destination_update_params.py new file mode 100644 index 00000000000..a6c2d729053 --- /dev/null +++ b/src/cloudflare/types/workers/observability/destination_update_params.py @@ -0,0 +1,24 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["DestinationUpdateParams", "Configuration"] + + +class DestinationUpdateParams(TypedDict, total=False): + account_id: Required[str] + + configuration: Required[Configuration] + + enabled: Required[bool] + + +class Configuration(TypedDict, total=False): + headers: Required[Dict[str, str]] + + type: Required[Literal["logpush"]] + + url: Required[str] diff --git a/src/cloudflare/types/workers/observability/destination_update_response.py b/src/cloudflare/types/workers/observability/destination_update_response.py new file mode 100644 index 00000000000..f4b392027db --- /dev/null +++ b/src/cloudflare/types/workers/observability/destination_update_response.py @@ -0,0 +1,34 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from ...._models import BaseModel + +__all__ = ["DestinationUpdateResponse", "Configuration"] + + +class Configuration(BaseModel): + destination_conf: str + + logpush_dataset: Literal["opentelemetry-traces", "opentelemetry-logs"] = FieldInfo(alias="logpushDataset") + + logpush_job: float = FieldInfo(alias="logpushJob") + + type: Literal["logpush"] + + url: str + + +class DestinationUpdateResponse(BaseModel): + configuration: Configuration + + enabled: bool + + name: str + + scripts: List[str] + + slug: str diff --git a/tests/api_resources/workers/observability/test_destinations.py b/tests/api_resources/workers/observability/test_destinations.py new file mode 100644 index 00000000000..82f2c056fef --- /dev/null +++ b/tests/api_resources/workers/observability/test_destinations.py @@ -0,0 +1,552 @@ +# 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.workers.observability import ( + DestinationListResponse, + DestinationCreateResponse, + DestinationDeleteResponse, + DestinationUpdateResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestDestinations: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_create(self, client: Cloudflare) -> None: + destination = client.workers.observability.destinations.create( + account_id="account_id", + configuration={ + "headers": {"foo": "string"}, + "logpush_dataset": "opentelemetry-traces", + "type": "logpush", + "url": "url", + }, + enabled=True, + name="name", + ) + assert_matches_type(DestinationCreateResponse, destination, path=["response"]) + + @parametrize + def test_method_create_with_all_params(self, client: Cloudflare) -> None: + destination = client.workers.observability.destinations.create( + account_id="account_id", + configuration={ + "headers": {"foo": "string"}, + "logpush_dataset": "opentelemetry-traces", + "type": "logpush", + "url": "url", + }, + enabled=True, + name="name", + skip_preflight_check=True, + ) + assert_matches_type(DestinationCreateResponse, destination, path=["response"]) + + @parametrize + def test_raw_response_create(self, client: Cloudflare) -> None: + response = client.workers.observability.destinations.with_raw_response.create( + account_id="account_id", + configuration={ + "headers": {"foo": "string"}, + "logpush_dataset": "opentelemetry-traces", + "type": "logpush", + "url": "url", + }, + enabled=True, + name="name", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + destination = response.parse() + assert_matches_type(DestinationCreateResponse, destination, path=["response"]) + + @parametrize + def test_streaming_response_create(self, client: Cloudflare) -> None: + with client.workers.observability.destinations.with_streaming_response.create( + account_id="account_id", + configuration={ + "headers": {"foo": "string"}, + "logpush_dataset": "opentelemetry-traces", + "type": "logpush", + "url": "url", + }, + enabled=True, + name="name", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + destination = response.parse() + assert_matches_type(DestinationCreateResponse, destination, 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.workers.observability.destinations.with_raw_response.create( + account_id="", + configuration={ + "headers": {"foo": "string"}, + "logpush_dataset": "opentelemetry-traces", + "type": "logpush", + "url": "url", + }, + enabled=True, + name="name", + ) + + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + destination = client.workers.observability.destinations.update( + slug="slug", + account_id="account_id", + configuration={ + "headers": {"foo": "string"}, + "type": "logpush", + "url": "url", + }, + enabled=True, + ) + assert_matches_type(DestinationUpdateResponse, destination, path=["response"]) + + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.workers.observability.destinations.with_raw_response.update( + slug="slug", + account_id="account_id", + configuration={ + "headers": {"foo": "string"}, + "type": "logpush", + "url": "url", + }, + enabled=True, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + destination = response.parse() + assert_matches_type(DestinationUpdateResponse, destination, path=["response"]) + + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.workers.observability.destinations.with_streaming_response.update( + slug="slug", + account_id="account_id", + configuration={ + "headers": {"foo": "string"}, + "type": "logpush", + "url": "url", + }, + enabled=True, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + destination = response.parse() + assert_matches_type(DestinationUpdateResponse, destination, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.workers.observability.destinations.with_raw_response.update( + slug="slug", + account_id="", + configuration={ + "headers": {"foo": "string"}, + "type": "logpush", + "url": "url", + }, + enabled=True, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `slug` but received ''"): + client.workers.observability.destinations.with_raw_response.update( + slug="", + account_id="account_id", + configuration={ + "headers": {"foo": "string"}, + "type": "logpush", + "url": "url", + }, + enabled=True, + ) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + destination = client.workers.observability.destinations.list( + account_id="account_id", + ) + assert_matches_type(SyncSinglePage[DestinationListResponse], destination, path=["response"]) + + @parametrize + def test_method_list_with_all_params(self, client: Cloudflare) -> None: + destination = client.workers.observability.destinations.list( + account_id="account_id", + order="asc", + order_by="created", + page=1, + per_page=5, + ) + assert_matches_type(SyncSinglePage[DestinationListResponse], destination, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.workers.observability.destinations.with_raw_response.list( + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + destination = response.parse() + assert_matches_type(SyncSinglePage[DestinationListResponse], destination, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.workers.observability.destinations.with_streaming_response.list( + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + destination = response.parse() + assert_matches_type(SyncSinglePage[DestinationListResponse], destination, 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.workers.observability.destinations.with_raw_response.list( + account_id="", + ) + + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + destination = client.workers.observability.destinations.delete( + slug="slug", + account_id="account_id", + ) + assert_matches_type(Optional[DestinationDeleteResponse], destination, path=["response"]) + + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.workers.observability.destinations.with_raw_response.delete( + slug="slug", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + destination = response.parse() + assert_matches_type(Optional[DestinationDeleteResponse], destination, path=["response"]) + + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.workers.observability.destinations.with_streaming_response.delete( + slug="slug", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + destination = response.parse() + assert_matches_type(Optional[DestinationDeleteResponse], destination, 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.workers.observability.destinations.with_raw_response.delete( + slug="slug", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `slug` but received ''"): + client.workers.observability.destinations.with_raw_response.delete( + slug="", + account_id="account_id", + ) + + +class TestAsyncDestinations: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @parametrize + async def test_method_create(self, async_client: AsyncCloudflare) -> None: + destination = await async_client.workers.observability.destinations.create( + account_id="account_id", + configuration={ + "headers": {"foo": "string"}, + "logpush_dataset": "opentelemetry-traces", + "type": "logpush", + "url": "url", + }, + enabled=True, + name="name", + ) + assert_matches_type(DestinationCreateResponse, destination, path=["response"]) + + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: + destination = await async_client.workers.observability.destinations.create( + account_id="account_id", + configuration={ + "headers": {"foo": "string"}, + "logpush_dataset": "opentelemetry-traces", + "type": "logpush", + "url": "url", + }, + enabled=True, + name="name", + skip_preflight_check=True, + ) + assert_matches_type(DestinationCreateResponse, destination, path=["response"]) + + @parametrize + async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: + response = await async_client.workers.observability.destinations.with_raw_response.create( + account_id="account_id", + configuration={ + "headers": {"foo": "string"}, + "logpush_dataset": "opentelemetry-traces", + "type": "logpush", + "url": "url", + }, + enabled=True, + name="name", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + destination = await response.parse() + assert_matches_type(DestinationCreateResponse, destination, path=["response"]) + + @parametrize + async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: + async with async_client.workers.observability.destinations.with_streaming_response.create( + account_id="account_id", + configuration={ + "headers": {"foo": "string"}, + "logpush_dataset": "opentelemetry-traces", + "type": "logpush", + "url": "url", + }, + enabled=True, + name="name", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + destination = await response.parse() + assert_matches_type(DestinationCreateResponse, destination, 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.workers.observability.destinations.with_raw_response.create( + account_id="", + configuration={ + "headers": {"foo": "string"}, + "logpush_dataset": "opentelemetry-traces", + "type": "logpush", + "url": "url", + }, + enabled=True, + name="name", + ) + + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + destination = await async_client.workers.observability.destinations.update( + slug="slug", + account_id="account_id", + configuration={ + "headers": {"foo": "string"}, + "type": "logpush", + "url": "url", + }, + enabled=True, + ) + assert_matches_type(DestinationUpdateResponse, destination, path=["response"]) + + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.workers.observability.destinations.with_raw_response.update( + slug="slug", + account_id="account_id", + configuration={ + "headers": {"foo": "string"}, + "type": "logpush", + "url": "url", + }, + enabled=True, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + destination = await response.parse() + assert_matches_type(DestinationUpdateResponse, destination, path=["response"]) + + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.workers.observability.destinations.with_streaming_response.update( + slug="slug", + account_id="account_id", + configuration={ + "headers": {"foo": "string"}, + "type": "logpush", + "url": "url", + }, + enabled=True, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + destination = await response.parse() + assert_matches_type(DestinationUpdateResponse, destination, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.workers.observability.destinations.with_raw_response.update( + slug="slug", + account_id="", + configuration={ + "headers": {"foo": "string"}, + "type": "logpush", + "url": "url", + }, + enabled=True, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `slug` but received ''"): + await async_client.workers.observability.destinations.with_raw_response.update( + slug="", + account_id="account_id", + configuration={ + "headers": {"foo": "string"}, + "type": "logpush", + "url": "url", + }, + enabled=True, + ) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + destination = await async_client.workers.observability.destinations.list( + account_id="account_id", + ) + assert_matches_type(AsyncSinglePage[DestinationListResponse], destination, path=["response"]) + + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: + destination = await async_client.workers.observability.destinations.list( + account_id="account_id", + order="asc", + order_by="created", + page=1, + per_page=5, + ) + assert_matches_type(AsyncSinglePage[DestinationListResponse], destination, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.workers.observability.destinations.with_raw_response.list( + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + destination = await response.parse() + assert_matches_type(AsyncSinglePage[DestinationListResponse], destination, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.workers.observability.destinations.with_streaming_response.list( + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + destination = await response.parse() + assert_matches_type(AsyncSinglePage[DestinationListResponse], destination, 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.workers.observability.destinations.with_raw_response.list( + account_id="", + ) + + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + destination = await async_client.workers.observability.destinations.delete( + slug="slug", + account_id="account_id", + ) + assert_matches_type(Optional[DestinationDeleteResponse], destination, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.workers.observability.destinations.with_raw_response.delete( + slug="slug", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + destination = await response.parse() + assert_matches_type(Optional[DestinationDeleteResponse], destination, path=["response"]) + + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.workers.observability.destinations.with_streaming_response.delete( + slug="slug", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + destination = await response.parse() + assert_matches_type(Optional[DestinationDeleteResponse], destination, 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.workers.observability.destinations.with_raw_response.delete( + slug="slug", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `slug` but received ''"): + await async_client.workers.observability.destinations.with_raw_response.delete( + slug="", + account_id="account_id", + ) From bcafc86a702e490d04adbf58fd34cd6b3396d897 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 4 Mar 2026 22:56:41 +0000 Subject: [PATCH 06/12] feat: feat(zero_trust_device_subnet): onboard new terraform resource cloudflare_zero_trust_device_subnet * feat(zero_trust_device_subnet): onboard new terraform resource cloudflare_zero_trust_device_subnet --- .stats.yml | 2 +- api.md | 29 +++-------- .../networks/subnets/cloudflare_source.py | 14 +++--- .../zero_trust/networks/subnets/subnets.py | 14 +++--- .../zero_trust/networks/subnets/warp.py | 40 ++++++++-------- .../types/zero_trust/networks/__init__.py | 1 - .../networks/subnet_list_response.py | 41 ---------------- .../zero_trust/networks/subnets/__init__.py | 5 +- .../cloudflare_source_update_response.py | 41 ---------------- .../{warp_get_response.py => subnet.py} | 4 +- .../networks/subnets/warp_create_response.py | 41 ---------------- .../networks/subnets/warp_edit_response.py | 41 ---------------- .../subnets/test_cloudflare_source.py | 18 +++---- .../zero_trust/networks/subnets/test_warp.py | 48 +++++++++---------- .../zero_trust/networks/test_subnets.py | 18 +++---- 15 files changed, 84 insertions(+), 273 deletions(-) delete mode 100644 src/cloudflare/types/zero_trust/networks/subnet_list_response.py delete mode 100644 src/cloudflare/types/zero_trust/networks/subnets/cloudflare_source_update_response.py rename src/cloudflare/types/zero_trust/networks/subnets/{warp_get_response.py => subnet.py} (94%) delete mode 100644 src/cloudflare/types/zero_trust/networks/subnets/warp_create_response.py delete mode 100644 src/cloudflare/types/zero_trust/networks/subnets/warp_edit_response.py diff --git a/.stats.yml b/.stats.yml index ba380523a09..e454ea14a72 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 2045 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9ba099b7936091cc984d2a24fc4d32c3ffcb1d71d86412c8c9084d201e16b3ac.yml openapi_spec_hash: 45edc9a107cf5a5e3b204b230b0d336d -config_hash: c8f6f451ad44a8349b1876f50735189a +config_hash: 7d51f0daff6082e6eef983fe5a1bcfef diff --git a/api.md b/api.md index 75d39498134..dd8b3a32371 100644 --- a/api.md +++ b/api.md @@ -7340,47 +7340,30 @@ Methods: ### Subnets -Types: - -```python -from cloudflare.types.zero_trust.networks import SubnetListResponse -``` - Methods: -- client.zero_trust.networks.subnets.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[SubnetListResponse] +- client.zero_trust.networks.subnets.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[Subnet] #### WARP Types: ```python -from cloudflare.types.zero_trust.networks.subnets import ( - WARPCreateResponse, - WARPDeleteResponse, - WARPEditResponse, - WARPGetResponse, -) +from cloudflare.types.zero_trust.networks.subnets import Subnet, WARPDeleteResponse ``` Methods: -- client.zero_trust.networks.subnets.warp.create(\*, account_id, \*\*params) -> WARPCreateResponse +- client.zero_trust.networks.subnets.warp.create(\*, account_id, \*\*params) -> Subnet - client.zero_trust.networks.subnets.warp.delete(subnet_id, \*, account_id) -> Optional[WARPDeleteResponse] -- client.zero_trust.networks.subnets.warp.edit(subnet_id, \*, account_id, \*\*params) -> WARPEditResponse -- client.zero_trust.networks.subnets.warp.get(subnet_id, \*, account_id) -> WARPGetResponse +- client.zero_trust.networks.subnets.warp.edit(subnet_id, \*, account_id, \*\*params) -> Subnet +- client.zero_trust.networks.subnets.warp.get(subnet_id, \*, account_id) -> Subnet #### CloudflareSource -Types: - -```python -from cloudflare.types.zero_trust.networks.subnets import CloudflareSourceUpdateResponse -``` - Methods: -- client.zero_trust.networks.subnets.cloudflare_source.update(address_family, \*, account_id, \*\*params) -> CloudflareSourceUpdateResponse +- client.zero_trust.networks.subnets.cloudflare_source.update(address_family, \*, account_id, \*\*params) -> Subnet ### HostnameRoutes diff --git a/src/cloudflare/resources/zero_trust/networks/subnets/cloudflare_source.py b/src/cloudflare/resources/zero_trust/networks/subnets/cloudflare_source.py index 9245c6df3f9..568a1ac9db7 100644 --- a/src/cloudflare/resources/zero_trust/networks/subnets/cloudflare_source.py +++ b/src/cloudflare/resources/zero_trust/networks/subnets/cloudflare_source.py @@ -20,7 +20,7 @@ from ....._wrappers import ResultWrapper from ....._base_client import make_request_options from .....types.zero_trust.networks.subnets import cloudflare_source_update_params -from .....types.zero_trust.networks.subnets.cloudflare_source_update_response import CloudflareSourceUpdateResponse +from .....types.zero_trust.networks.subnets.subnet import Subnet __all__ = ["CloudflareSourceResource", "AsyncCloudflareSourceResource"] @@ -59,7 +59,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> CloudflareSourceUpdateResponse: + ) -> Subnet: """ Updates the Cloudflare Source subnet of the given address family @@ -101,9 +101,9 @@ def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[CloudflareSourceUpdateResponse]._unwrapper, + post_parser=ResultWrapper[Subnet]._unwrapper, ), - cast_to=cast(Type[CloudflareSourceUpdateResponse], ResultWrapper[CloudflareSourceUpdateResponse]), + cast_to=cast(Type[Subnet], ResultWrapper[Subnet]), ) @@ -141,7 +141,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> CloudflareSourceUpdateResponse: + ) -> Subnet: """ Updates the Cloudflare Source subnet of the given address family @@ -183,9 +183,9 @@ async def update( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[CloudflareSourceUpdateResponse]._unwrapper, + post_parser=ResultWrapper[Subnet]._unwrapper, ), - cast_to=cast(Type[CloudflareSourceUpdateResponse], ResultWrapper[CloudflareSourceUpdateResponse]), + cast_to=cast(Type[Subnet], ResultWrapper[Subnet]), ) diff --git a/src/cloudflare/resources/zero_trust/networks/subnets/subnets.py b/src/cloudflare/resources/zero_trust/networks/subnets/subnets.py index d723f449966..799ea74893e 100644 --- a/src/cloudflare/resources/zero_trust/networks/subnets/subnets.py +++ b/src/cloudflare/resources/zero_trust/networks/subnets/subnets.py @@ -35,7 +35,7 @@ AsyncCloudflareSourceResourceWithStreamingResponse, ) from .....types.zero_trust.networks import subnet_list_params -from .....types.zero_trust.networks.subnet_list_response import SubnetListResponse +from .....types.zero_trust.networks.subnets.subnet import Subnet __all__ = ["SubnetsResource", "AsyncSubnetsResource"] @@ -89,7 +89,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> SyncV4PagePaginationArray[SubnetListResponse]: + ) -> SyncV4PagePaginationArray[Subnet]: """ Lists and filters subnets in an account. @@ -134,7 +134,7 @@ def list( 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}/zerotrust/subnets", - page=SyncV4PagePaginationArray[SubnetListResponse], + page=SyncV4PagePaginationArray[Subnet], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -157,7 +157,7 @@ def list( subnet_list_params.SubnetListParams, ), ), - model=SubnetListResponse, + model=Subnet, ) @@ -210,7 +210,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> AsyncPaginator[SubnetListResponse, AsyncV4PagePaginationArray[SubnetListResponse]]: + ) -> AsyncPaginator[Subnet, AsyncV4PagePaginationArray[Subnet]]: """ Lists and filters subnets in an account. @@ -255,7 +255,7 @@ def list( 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}/zerotrust/subnets", - page=AsyncV4PagePaginationArray[SubnetListResponse], + page=AsyncV4PagePaginationArray[Subnet], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -278,7 +278,7 @@ def list( subnet_list_params.SubnetListParams, ), ), - model=SubnetListResponse, + model=Subnet, ) diff --git a/src/cloudflare/resources/zero_trust/networks/subnets/warp.py b/src/cloudflare/resources/zero_trust/networks/subnets/warp.py index 79caba44736..fd964d37ac4 100644 --- a/src/cloudflare/resources/zero_trust/networks/subnets/warp.py +++ b/src/cloudflare/resources/zero_trust/networks/subnets/warp.py @@ -19,9 +19,7 @@ from ....._wrappers import ResultWrapper from ....._base_client import make_request_options from .....types.zero_trust.networks.subnets import warp_edit_params, warp_create_params -from .....types.zero_trust.networks.subnets.warp_get_response import WARPGetResponse -from .....types.zero_trust.networks.subnets.warp_edit_response import WARPEditResponse -from .....types.zero_trust.networks.subnets.warp_create_response import WARPCreateResponse +from .....types.zero_trust.networks.subnets.subnet import Subnet from .....types.zero_trust.networks.subnets.warp_delete_response import WARPDeleteResponse __all__ = ["WARPResource", "AsyncWARPResource"] @@ -61,7 +59,7 @@ def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> WARPCreateResponse: + ) -> Subnet: """Create a WARP IP assignment subnet. Currently, only IPv4 subnets can be created. @@ -114,9 +112,9 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[WARPCreateResponse]._unwrapper, + post_parser=ResultWrapper[Subnet]._unwrapper, ), - cast_to=cast(Type[WARPCreateResponse], ResultWrapper[WARPCreateResponse]), + cast_to=cast(Type[Subnet], ResultWrapper[Subnet]), ) def delete( @@ -180,7 +178,7 @@ def edit( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> WARPEditResponse: + ) -> Subnet: """ Updates a WARP IP assignment subnet. @@ -232,9 +230,9 @@ def edit( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[WARPEditResponse]._unwrapper, + post_parser=ResultWrapper[Subnet]._unwrapper, ), - cast_to=cast(Type[WARPEditResponse], ResultWrapper[WARPEditResponse]), + cast_to=cast(Type[Subnet], ResultWrapper[Subnet]), ) def get( @@ -248,7 +246,7 @@ def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> WARPGetResponse: + ) -> Subnet: """ Get a WARP IP assignment subnet. @@ -276,9 +274,9 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[WARPGetResponse]._unwrapper, + post_parser=ResultWrapper[Subnet]._unwrapper, ), - cast_to=cast(Type[WARPGetResponse], ResultWrapper[WARPGetResponse]), + cast_to=cast(Type[Subnet], ResultWrapper[Subnet]), ) @@ -316,7 +314,7 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> WARPCreateResponse: + ) -> Subnet: """Create a WARP IP assignment subnet. Currently, only IPv4 subnets can be created. @@ -369,9 +367,9 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[WARPCreateResponse]._unwrapper, + post_parser=ResultWrapper[Subnet]._unwrapper, ), - cast_to=cast(Type[WARPCreateResponse], ResultWrapper[WARPCreateResponse]), + cast_to=cast(Type[Subnet], ResultWrapper[Subnet]), ) async def delete( @@ -435,7 +433,7 @@ async def edit( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> WARPEditResponse: + ) -> Subnet: """ Updates a WARP IP assignment subnet. @@ -487,9 +485,9 @@ async def edit( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[WARPEditResponse]._unwrapper, + post_parser=ResultWrapper[Subnet]._unwrapper, ), - cast_to=cast(Type[WARPEditResponse], ResultWrapper[WARPEditResponse]), + cast_to=cast(Type[Subnet], ResultWrapper[Subnet]), ) async def get( @@ -503,7 +501,7 @@ async def get( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> WARPGetResponse: + ) -> Subnet: """ Get a WARP IP assignment subnet. @@ -531,9 +529,9 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[WARPGetResponse]._unwrapper, + post_parser=ResultWrapper[Subnet]._unwrapper, ), - cast_to=cast(Type[WARPGetResponse], ResultWrapper[WARPGetResponse]), + cast_to=cast(Type[Subnet], ResultWrapper[Subnet]), ) diff --git a/src/cloudflare/types/zero_trust/networks/__init__.py b/src/cloudflare/types/zero_trust/networks/__init__.py index 401271d6d2f..0e578a5d991 100644 --- a/src/cloudflare/types/zero_trust/networks/__init__.py +++ b/src/cloudflare/types/zero_trust/networks/__init__.py @@ -10,7 +10,6 @@ from .route_list_params import RouteListParams as RouteListParams from .subnet_list_params import SubnetListParams as SubnetListParams from .route_create_params import RouteCreateParams as RouteCreateParams -from .subnet_list_response import SubnetListResponse as SubnetListResponse from .hostname_route_edit_params import HostnameRouteEditParams as HostnameRouteEditParams from .hostname_route_list_params import HostnameRouteListParams as HostnameRouteListParams from .virtual_network_edit_params import VirtualNetworkEditParams as VirtualNetworkEditParams diff --git a/src/cloudflare/types/zero_trust/networks/subnet_list_response.py b/src/cloudflare/types/zero_trust/networks/subnet_list_response.py deleted file mode 100644 index 4ecca401e28..00000000000 --- a/src/cloudflare/types/zero_trust/networks/subnet_list_response.py +++ /dev/null @@ -1,41 +0,0 @@ -# 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__ = ["SubnetListResponse"] - - -class SubnetListResponse(BaseModel): - id: Optional[str] = None - """The UUID of the subnet.""" - - comment: Optional[str] = None - """An optional description of the subnet.""" - - created_at: Optional[datetime] = None - """Timestamp of when the resource was created.""" - - deleted_at: Optional[datetime] = None - """Timestamp of when the resource was deleted. - - If `null`, the resource has not been deleted. - """ - - is_default_network: Optional[bool] = None - """If `true`, this is the default subnet for the account. - - There can only be one default subnet per account. - """ - - name: Optional[str] = None - """A user-friendly name for the subnet.""" - - network: Optional[str] = None - """The private IPv4 or IPv6 range defining the subnet, in CIDR notation.""" - - subnet_type: Optional[Literal["cloudflare_source", "warp"]] = None - """The type of subnet.""" diff --git a/src/cloudflare/types/zero_trust/networks/subnets/__init__.py b/src/cloudflare/types/zero_trust/networks/subnets/__init__.py index 5c47375b355..aca9235366d 100644 --- a/src/cloudflare/types/zero_trust/networks/subnets/__init__.py +++ b/src/cloudflare/types/zero_trust/networks/subnets/__init__.py @@ -2,11 +2,8 @@ from __future__ import annotations +from .subnet import Subnet as Subnet from .warp_edit_params import WARPEditParams as WARPEditParams -from .warp_get_response import WARPGetResponse as WARPGetResponse from .warp_create_params import WARPCreateParams as WARPCreateParams -from .warp_edit_response import WARPEditResponse as WARPEditResponse -from .warp_create_response import WARPCreateResponse as WARPCreateResponse from .warp_delete_response import WARPDeleteResponse as WARPDeleteResponse from .cloudflare_source_update_params import CloudflareSourceUpdateParams as CloudflareSourceUpdateParams -from .cloudflare_source_update_response import CloudflareSourceUpdateResponse as CloudflareSourceUpdateResponse diff --git a/src/cloudflare/types/zero_trust/networks/subnets/cloudflare_source_update_response.py b/src/cloudflare/types/zero_trust/networks/subnets/cloudflare_source_update_response.py deleted file mode 100644 index 37f881d9a97..00000000000 --- a/src/cloudflare/types/zero_trust/networks/subnets/cloudflare_source_update_response.py +++ /dev/null @@ -1,41 +0,0 @@ -# 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__ = ["CloudflareSourceUpdateResponse"] - - -class CloudflareSourceUpdateResponse(BaseModel): - id: Optional[str] = None - """The UUID of the subnet.""" - - comment: Optional[str] = None - """An optional description of the subnet.""" - - created_at: Optional[datetime] = None - """Timestamp of when the resource was created.""" - - deleted_at: Optional[datetime] = None - """Timestamp of when the resource was deleted. - - If `null`, the resource has not been deleted. - """ - - is_default_network: Optional[bool] = None - """If `true`, this is the default subnet for the account. - - There can only be one default subnet per account. - """ - - name: Optional[str] = None - """A user-friendly name for the subnet.""" - - network: Optional[str] = None - """The private IPv4 or IPv6 range defining the subnet, in CIDR notation.""" - - subnet_type: Optional[Literal["cloudflare_source", "warp"]] = None - """The type of subnet.""" diff --git a/src/cloudflare/types/zero_trust/networks/subnets/warp_get_response.py b/src/cloudflare/types/zero_trust/networks/subnets/subnet.py similarity index 94% rename from src/cloudflare/types/zero_trust/networks/subnets/warp_get_response.py rename to src/cloudflare/types/zero_trust/networks/subnets/subnet.py index efaafd465a5..b2be84028dd 100644 --- a/src/cloudflare/types/zero_trust/networks/subnets/warp_get_response.py +++ b/src/cloudflare/types/zero_trust/networks/subnets/subnet.py @@ -6,10 +6,10 @@ from ....._models import BaseModel -__all__ = ["WARPGetResponse"] +__all__ = ["Subnet"] -class WARPGetResponse(BaseModel): +class Subnet(BaseModel): id: Optional[str] = None """The UUID of the subnet.""" diff --git a/src/cloudflare/types/zero_trust/networks/subnets/warp_create_response.py b/src/cloudflare/types/zero_trust/networks/subnets/warp_create_response.py deleted file mode 100644 index c4ae8abfb42..00000000000 --- a/src/cloudflare/types/zero_trust/networks/subnets/warp_create_response.py +++ /dev/null @@ -1,41 +0,0 @@ -# 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__ = ["WARPCreateResponse"] - - -class WARPCreateResponse(BaseModel): - id: Optional[str] = None - """The UUID of the subnet.""" - - comment: Optional[str] = None - """An optional description of the subnet.""" - - created_at: Optional[datetime] = None - """Timestamp of when the resource was created.""" - - deleted_at: Optional[datetime] = None - """Timestamp of when the resource was deleted. - - If `null`, the resource has not been deleted. - """ - - is_default_network: Optional[bool] = None - """If `true`, this is the default subnet for the account. - - There can only be one default subnet per account. - """ - - name: Optional[str] = None - """A user-friendly name for the subnet.""" - - network: Optional[str] = None - """The private IPv4 or IPv6 range defining the subnet, in CIDR notation.""" - - subnet_type: Optional[Literal["cloudflare_source", "warp"]] = None - """The type of subnet.""" diff --git a/src/cloudflare/types/zero_trust/networks/subnets/warp_edit_response.py b/src/cloudflare/types/zero_trust/networks/subnets/warp_edit_response.py deleted file mode 100644 index b976b41f832..00000000000 --- a/src/cloudflare/types/zero_trust/networks/subnets/warp_edit_response.py +++ /dev/null @@ -1,41 +0,0 @@ -# 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__ = ["WARPEditResponse"] - - -class WARPEditResponse(BaseModel): - id: Optional[str] = None - """The UUID of the subnet.""" - - comment: Optional[str] = None - """An optional description of the subnet.""" - - created_at: Optional[datetime] = None - """Timestamp of when the resource was created.""" - - deleted_at: Optional[datetime] = None - """Timestamp of when the resource was deleted. - - If `null`, the resource has not been deleted. - """ - - is_default_network: Optional[bool] = None - """If `true`, this is the default subnet for the account. - - There can only be one default subnet per account. - """ - - name: Optional[str] = None - """A user-friendly name for the subnet.""" - - network: Optional[str] = None - """The private IPv4 or IPv6 range defining the subnet, in CIDR notation.""" - - subnet_type: Optional[Literal["cloudflare_source", "warp"]] = None - """The type of subnet.""" diff --git a/tests/api_resources/zero_trust/networks/subnets/test_cloudflare_source.py b/tests/api_resources/zero_trust/networks/subnets/test_cloudflare_source.py index 27a5af44aad..405bb8a55b0 100644 --- a/tests/api_resources/zero_trust/networks/subnets/test_cloudflare_source.py +++ b/tests/api_resources/zero_trust/networks/subnets/test_cloudflare_source.py @@ -9,7 +9,7 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type -from cloudflare.types.zero_trust.networks.subnets import CloudflareSourceUpdateResponse +from cloudflare.types.zero_trust.networks.subnets import Subnet base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -23,7 +23,7 @@ def test_method_update(self, client: Cloudflare) -> None: address_family="v4", account_id="699d98642c564d2e855e9661899b7252", ) - assert_matches_type(CloudflareSourceUpdateResponse, cloudflare_source, path=["response"]) + assert_matches_type(Subnet, cloudflare_source, path=["response"]) @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: @@ -34,7 +34,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: name="IPv4 Cloudflare Source IPs", network="100.64.0.0/12", ) - assert_matches_type(CloudflareSourceUpdateResponse, cloudflare_source, path=["response"]) + assert_matches_type(Subnet, cloudflare_source, path=["response"]) @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: @@ -46,7 +46,7 @@ def test_raw_response_update(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" cloudflare_source = response.parse() - assert_matches_type(CloudflareSourceUpdateResponse, cloudflare_source, path=["response"]) + assert_matches_type(Subnet, cloudflare_source, path=["response"]) @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: @@ -58,7 +58,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" cloudflare_source = response.parse() - assert_matches_type(CloudflareSourceUpdateResponse, cloudflare_source, path=["response"]) + assert_matches_type(Subnet, cloudflare_source, path=["response"]) assert cast(Any, response.is_closed) is True @@ -82,7 +82,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: address_family="v4", account_id="699d98642c564d2e855e9661899b7252", ) - assert_matches_type(CloudflareSourceUpdateResponse, cloudflare_source, path=["response"]) + assert_matches_type(Subnet, cloudflare_source, path=["response"]) @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -93,7 +93,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare name="IPv4 Cloudflare Source IPs", network="100.64.0.0/12", ) - assert_matches_type(CloudflareSourceUpdateResponse, cloudflare_source, path=["response"]) + assert_matches_type(Subnet, cloudflare_source, path=["response"]) @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @@ -105,7 +105,7 @@ async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" cloudflare_source = await response.parse() - assert_matches_type(CloudflareSourceUpdateResponse, cloudflare_source, path=["response"]) + assert_matches_type(Subnet, cloudflare_source, path=["response"]) @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: @@ -117,7 +117,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" cloudflare_source = await response.parse() - assert_matches_type(CloudflareSourceUpdateResponse, cloudflare_source, path=["response"]) + assert_matches_type(Subnet, cloudflare_source, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/zero_trust/networks/subnets/test_warp.py b/tests/api_resources/zero_trust/networks/subnets/test_warp.py index b016142f108..29f3796c73f 100644 --- a/tests/api_resources/zero_trust/networks/subnets/test_warp.py +++ b/tests/api_resources/zero_trust/networks/subnets/test_warp.py @@ -10,9 +10,7 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type from cloudflare.types.zero_trust.networks.subnets import ( - WARPGetResponse, - WARPEditResponse, - WARPCreateResponse, + Subnet, WARPDeleteResponse, ) @@ -29,7 +27,7 @@ def test_method_create(self, client: Cloudflare) -> None: name="IPv4 Cloudflare Source IPs", network="100.64.0.0/12", ) - assert_matches_type(WARPCreateResponse, warp, path=["response"]) + assert_matches_type(Subnet, warp, path=["response"]) @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: @@ -40,7 +38,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: comment="example comment", is_default_network=True, ) - assert_matches_type(WARPCreateResponse, warp, path=["response"]) + assert_matches_type(Subnet, warp, path=["response"]) @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: @@ -53,7 +51,7 @@ def test_raw_response_create(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" warp = response.parse() - assert_matches_type(WARPCreateResponse, warp, path=["response"]) + assert_matches_type(Subnet, warp, path=["response"]) @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: @@ -66,7 +64,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" warp = response.parse() - assert_matches_type(WARPCreateResponse, warp, path=["response"]) + assert_matches_type(Subnet, warp, path=["response"]) assert cast(Any, response.is_closed) is True @@ -133,7 +131,7 @@ def test_method_edit(self, client: Cloudflare) -> None: subnet_id="f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) - assert_matches_type(WARPEditResponse, warp, path=["response"]) + assert_matches_type(Subnet, warp, path=["response"]) @parametrize def test_method_edit_with_all_params(self, client: Cloudflare) -> None: @@ -145,7 +143,7 @@ def test_method_edit_with_all_params(self, client: Cloudflare) -> None: name="IPv4 Cloudflare Source IPs", network="100.64.0.0/12", ) - assert_matches_type(WARPEditResponse, warp, path=["response"]) + assert_matches_type(Subnet, warp, path=["response"]) @parametrize def test_raw_response_edit(self, client: Cloudflare) -> None: @@ -157,7 +155,7 @@ def test_raw_response_edit(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" warp = response.parse() - assert_matches_type(WARPEditResponse, warp, path=["response"]) + assert_matches_type(Subnet, warp, path=["response"]) @parametrize def test_streaming_response_edit(self, client: Cloudflare) -> None: @@ -169,7 +167,7 @@ def test_streaming_response_edit(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" warp = response.parse() - assert_matches_type(WARPEditResponse, warp, path=["response"]) + assert_matches_type(Subnet, warp, path=["response"]) assert cast(Any, response.is_closed) is True @@ -193,7 +191,7 @@ def test_method_get(self, client: Cloudflare) -> None: subnet_id="f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) - assert_matches_type(WARPGetResponse, warp, path=["response"]) + assert_matches_type(Subnet, warp, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: @@ -205,7 +203,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" warp = response.parse() - assert_matches_type(WARPGetResponse, warp, path=["response"]) + assert_matches_type(Subnet, warp, path=["response"]) @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: @@ -217,7 +215,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" warp = response.parse() - assert_matches_type(WARPGetResponse, warp, path=["response"]) + assert_matches_type(Subnet, warp, path=["response"]) assert cast(Any, response.is_closed) is True @@ -248,7 +246,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: name="IPv4 Cloudflare Source IPs", network="100.64.0.0/12", ) - assert_matches_type(WARPCreateResponse, warp, path=["response"]) + assert_matches_type(Subnet, warp, path=["response"]) @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -259,7 +257,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare comment="example comment", is_default_network=True, ) - assert_matches_type(WARPCreateResponse, warp, path=["response"]) + assert_matches_type(Subnet, warp, path=["response"]) @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: @@ -272,7 +270,7 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" warp = await response.parse() - assert_matches_type(WARPCreateResponse, warp, path=["response"]) + assert_matches_type(Subnet, warp, path=["response"]) @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: @@ -285,7 +283,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" warp = await response.parse() - assert_matches_type(WARPCreateResponse, warp, path=["response"]) + assert_matches_type(Subnet, warp, path=["response"]) assert cast(Any, response.is_closed) is True @@ -352,7 +350,7 @@ async def test_method_edit(self, async_client: AsyncCloudflare) -> None: subnet_id="f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) - assert_matches_type(WARPEditResponse, warp, path=["response"]) + assert_matches_type(Subnet, warp, path=["response"]) @parametrize async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -364,7 +362,7 @@ async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) name="IPv4 Cloudflare Source IPs", network="100.64.0.0/12", ) - assert_matches_type(WARPEditResponse, warp, path=["response"]) + assert_matches_type(Subnet, warp, path=["response"]) @parametrize async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: @@ -376,7 +374,7 @@ async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" warp = await response.parse() - assert_matches_type(WARPEditResponse, warp, path=["response"]) + assert_matches_type(Subnet, warp, path=["response"]) @parametrize async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: @@ -388,7 +386,7 @@ async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> N assert response.http_request.headers.get("X-Stainless-Lang") == "python" warp = await response.parse() - assert_matches_type(WARPEditResponse, warp, path=["response"]) + assert_matches_type(Subnet, warp, path=["response"]) assert cast(Any, response.is_closed) is True @@ -412,7 +410,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: subnet_id="f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) - assert_matches_type(WARPGetResponse, warp, path=["response"]) + assert_matches_type(Subnet, warp, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @@ -424,7 +422,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" warp = await response.parse() - assert_matches_type(WARPGetResponse, warp, path=["response"]) + assert_matches_type(Subnet, warp, path=["response"]) @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: @@ -436,7 +434,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert response.http_request.headers.get("X-Stainless-Lang") == "python" warp = await response.parse() - assert_matches_type(WARPGetResponse, warp, path=["response"]) + assert_matches_type(Subnet, warp, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/zero_trust/networks/test_subnets.py b/tests/api_resources/zero_trust/networks/test_subnets.py index e8d64025ff2..32c510f6f0b 100644 --- a/tests/api_resources/zero_trust/networks/test_subnets.py +++ b/tests/api_resources/zero_trust/networks/test_subnets.py @@ -10,7 +10,7 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray -from cloudflare.types.zero_trust.networks import SubnetListResponse +from cloudflare.types.zero_trust.networks.subnets import Subnet base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -23,7 +23,7 @@ def test_method_list(self, client: Cloudflare) -> None: subnet = client.zero_trust.networks.subnets.list( account_id="699d98642c564d2e855e9661899b7252", ) - assert_matches_type(SyncV4PagePaginationArray[SubnetListResponse], subnet, path=["response"]) + assert_matches_type(SyncV4PagePaginationArray[Subnet], subnet, path=["response"]) @parametrize def test_method_list_with_all_params(self, client: Cloudflare) -> None: @@ -41,7 +41,7 @@ def test_method_list_with_all_params(self, client: Cloudflare) -> None: sort_order="asc", subnet_types="cloudflare_source", ) - assert_matches_type(SyncV4PagePaginationArray[SubnetListResponse], subnet, path=["response"]) + assert_matches_type(SyncV4PagePaginationArray[Subnet], subnet, path=["response"]) @parametrize def test_raw_response_list(self, client: Cloudflare) -> None: @@ -52,7 +52,7 @@ def test_raw_response_list(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" subnet = response.parse() - assert_matches_type(SyncV4PagePaginationArray[SubnetListResponse], subnet, path=["response"]) + assert_matches_type(SyncV4PagePaginationArray[Subnet], subnet, path=["response"]) @parametrize def test_streaming_response_list(self, client: Cloudflare) -> None: @@ -63,7 +63,7 @@ def test_streaming_response_list(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" subnet = response.parse() - assert_matches_type(SyncV4PagePaginationArray[SubnetListResponse], subnet, path=["response"]) + assert_matches_type(SyncV4PagePaginationArray[Subnet], subnet, path=["response"]) assert cast(Any, response.is_closed) is True @@ -85,7 +85,7 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None: subnet = await async_client.zero_trust.networks.subnets.list( account_id="699d98642c564d2e855e9661899b7252", ) - assert_matches_type(AsyncV4PagePaginationArray[SubnetListResponse], subnet, path=["response"]) + assert_matches_type(AsyncV4PagePaginationArray[Subnet], subnet, path=["response"]) @parametrize async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: @@ -103,7 +103,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) sort_order="asc", subnet_types="cloudflare_source", ) - assert_matches_type(AsyncV4PagePaginationArray[SubnetListResponse], subnet, path=["response"]) + assert_matches_type(AsyncV4PagePaginationArray[Subnet], subnet, path=["response"]) @parametrize async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: @@ -114,7 +114,7 @@ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" subnet = await response.parse() - assert_matches_type(AsyncV4PagePaginationArray[SubnetListResponse], subnet, path=["response"]) + assert_matches_type(AsyncV4PagePaginationArray[Subnet], subnet, path=["response"]) @parametrize async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: @@ -125,7 +125,7 @@ async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> N assert response.http_request.headers.get("X-Stainless-Lang") == "python" subnet = await response.parse() - assert_matches_type(AsyncV4PagePaginationArray[SubnetListResponse], subnet, path=["response"]) + assert_matches_type(AsyncV4PagePaginationArray[Subnet], subnet, path=["response"]) assert cast(Any, response.is_closed) is True From fe2b21d02c0cd4ecbf5216714907cfb95f374083 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 5 Mar 2026 00:35:42 +0000 Subject: [PATCH 07/12] feat: feat(ip_profile): onboard new terraform resource cloudflare_zero_trust_device_ip_profile * feat(ip_profile): onboard new terraform resource cloudflare_zero_trust_device_ip_profile * feat(ip_profile): onboard new terraform resource cloudflare_zero_trust_device_ip_profile --- .stats.yml | 4 +- api.md | 16 + .../resources/zero_trust/devices/__init__.py | 14 + .../resources/zero_trust/devices/devices.py | 32 + .../zero_trust/devices/ip_profiles.py | 692 ++++++++++++++++++ .../types/zero_trust/devices/__init__.py | 5 + .../types/zero_trust/devices/ip_profile.py | 44 ++ .../devices/ip_profile_create_params.py | 38 + .../devices/ip_profile_delete_response.py | 12 + .../devices/ip_profile_list_params.py | 14 + .../devices/ip_profile_update_params.py | 37 + .../zero_trust/devices/test_ip_profiles.py | 570 +++++++++++++++ 12 files changed, 1476 insertions(+), 2 deletions(-) create mode 100644 src/cloudflare/resources/zero_trust/devices/ip_profiles.py create mode 100644 src/cloudflare/types/zero_trust/devices/ip_profile.py create mode 100644 src/cloudflare/types/zero_trust/devices/ip_profile_create_params.py create mode 100644 src/cloudflare/types/zero_trust/devices/ip_profile_delete_response.py create mode 100644 src/cloudflare/types/zero_trust/devices/ip_profile_list_params.py create mode 100644 src/cloudflare/types/zero_trust/devices/ip_profile_update_params.py create mode 100644 tests/api_resources/zero_trust/devices/test_ip_profiles.py diff --git a/.stats.yml b/.stats.yml index e454ea14a72..abfd2fbdca7 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 2045 +configured_endpoints: 2050 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9ba099b7936091cc984d2a24fc4d32c3ffcb1d71d86412c8c9084d201e16b3ac.yml openapi_spec_hash: 45edc9a107cf5a5e3b204b230b0d336d -config_hash: 7d51f0daff6082e6eef983fe5a1bcfef +config_hash: 082014e766adf9596cfb12f88a73329a diff --git a/api.md b/api.md index dd8b3a32371..3ddbf724f9b 100644 --- a/api.md +++ b/api.md @@ -5637,6 +5637,22 @@ Methods: - client.zero_trust.devices.dex_tests.delete(dex_test_id, \*, account_id) -> Optional[DEXTestDeleteResponse] - client.zero_trust.devices.dex_tests.get(dex_test_id, \*, account_id) -> Optional[DEXTestGetResponse] +### IPProfiles + +Types: + +```python +from cloudflare.types.zero_trust.devices import IPProfile, IPProfileDeleteResponse +``` + +Methods: + +- client.zero_trust.devices.ip_profiles.create(\*, account_id, \*\*params) -> IPProfile +- client.zero_trust.devices.ip_profiles.update(profile_id, \*, account_id, \*\*params) -> IPProfile +- client.zero_trust.devices.ip_profiles.list(\*, account_id, \*\*params) -> SyncSinglePage[IPProfile] +- client.zero_trust.devices.ip_profiles.delete(profile_id, \*, account_id) -> IPProfileDeleteResponse +- client.zero_trust.devices.ip_profiles.get(profile_id, \*, account_id) -> IPProfile + ### Networks Types: diff --git a/src/cloudflare/resources/zero_trust/devices/__init__.py b/src/cloudflare/resources/zero_trust/devices/__init__.py index b3bd5980ce4..a3579f08c06 100644 --- a/src/cloudflare/resources/zero_trust/devices/__init__.py +++ b/src/cloudflare/resources/zero_trust/devices/__init__.py @@ -72,6 +72,14 @@ ResilienceResourceWithStreamingResponse, AsyncResilienceResourceWithStreamingResponse, ) +from .ip_profiles import ( + IPProfilesResource, + AsyncIPProfilesResource, + IPProfilesResourceWithRawResponse, + AsyncIPProfilesResourceWithRawResponse, + IPProfilesResourceWithStreamingResponse, + AsyncIPProfilesResourceWithStreamingResponse, +) from .fleet_status import ( FleetStatusResource, AsyncFleetStatusResource, @@ -116,6 +124,12 @@ "AsyncDEXTestsResourceWithRawResponse", "DEXTestsResourceWithStreamingResponse", "AsyncDEXTestsResourceWithStreamingResponse", + "IPProfilesResource", + "AsyncIPProfilesResource", + "IPProfilesResourceWithRawResponse", + "AsyncIPProfilesResourceWithRawResponse", + "IPProfilesResourceWithStreamingResponse", + "AsyncIPProfilesResourceWithStreamingResponse", "NetworksResource", "AsyncNetworksResource", "NetworksResourceWithRawResponse", diff --git a/src/cloudflare/resources/zero_trust/devices/devices.py b/src/cloudflare/resources/zero_trust/devices/devices.py index ce53ece99fb..0127c723960 100644 --- a/src/cloudflare/resources/zero_trust/devices/devices.py +++ b/src/cloudflare/resources/zero_trust/devices/devices.py @@ -50,6 +50,14 @@ AsyncDEXTestsResourceWithStreamingResponse, ) from ...._compat import cached_property +from .ip_profiles import ( + IPProfilesResource, + AsyncIPProfilesResource, + IPProfilesResourceWithRawResponse, + AsyncIPProfilesResourceWithRawResponse, + IPProfilesResourceWithStreamingResponse, + AsyncIPProfilesResourceWithStreamingResponse, +) from ...._resource import SyncAPIResource, AsyncAPIResource from ...._response import ( to_raw_response_wrapper, @@ -131,6 +139,10 @@ def registrations(self) -> RegistrationsResource: def dex_tests(self) -> DEXTestsResource: return DEXTestsResource(self._client) + @cached_property + def ip_profiles(self) -> IPProfilesResource: + return IPProfilesResource(self._client) + @cached_property def networks(self) -> NetworksResource: return NetworksResource(self._client) @@ -295,6 +307,10 @@ def registrations(self) -> AsyncRegistrationsResource: def dex_tests(self) -> AsyncDEXTestsResource: return AsyncDEXTestsResource(self._client) + @cached_property + def ip_profiles(self) -> AsyncIPProfilesResource: + return AsyncIPProfilesResource(self._client) + @cached_property def networks(self) -> AsyncNetworksResource: return AsyncNetworksResource(self._client) @@ -473,6 +489,10 @@ def registrations(self) -> RegistrationsResourceWithRawResponse: def dex_tests(self) -> DEXTestsResourceWithRawResponse: return DEXTestsResourceWithRawResponse(self._devices.dex_tests) + @cached_property + def ip_profiles(self) -> IPProfilesResourceWithRawResponse: + return IPProfilesResourceWithRawResponse(self._devices.ip_profiles) + @cached_property def networks(self) -> NetworksResourceWithRawResponse: return NetworksResourceWithRawResponse(self._devices.networks) @@ -537,6 +557,10 @@ def registrations(self) -> AsyncRegistrationsResourceWithRawResponse: def dex_tests(self) -> AsyncDEXTestsResourceWithRawResponse: return AsyncDEXTestsResourceWithRawResponse(self._devices.dex_tests) + @cached_property + def ip_profiles(self) -> AsyncIPProfilesResourceWithRawResponse: + return AsyncIPProfilesResourceWithRawResponse(self._devices.ip_profiles) + @cached_property def networks(self) -> AsyncNetworksResourceWithRawResponse: return AsyncNetworksResourceWithRawResponse(self._devices.networks) @@ -601,6 +625,10 @@ def registrations(self) -> RegistrationsResourceWithStreamingResponse: def dex_tests(self) -> DEXTestsResourceWithStreamingResponse: return DEXTestsResourceWithStreamingResponse(self._devices.dex_tests) + @cached_property + def ip_profiles(self) -> IPProfilesResourceWithStreamingResponse: + return IPProfilesResourceWithStreamingResponse(self._devices.ip_profiles) + @cached_property def networks(self) -> NetworksResourceWithStreamingResponse: return NetworksResourceWithStreamingResponse(self._devices.networks) @@ -665,6 +693,10 @@ def registrations(self) -> AsyncRegistrationsResourceWithStreamingResponse: def dex_tests(self) -> AsyncDEXTestsResourceWithStreamingResponse: return AsyncDEXTestsResourceWithStreamingResponse(self._devices.dex_tests) + @cached_property + def ip_profiles(self) -> AsyncIPProfilesResourceWithStreamingResponse: + return AsyncIPProfilesResourceWithStreamingResponse(self._devices.ip_profiles) + @cached_property def networks(self) -> AsyncNetworksResourceWithStreamingResponse: return AsyncNetworksResourceWithStreamingResponse(self._devices.networks) diff --git a/src/cloudflare/resources/zero_trust/devices/ip_profiles.py b/src/cloudflare/resources/zero_trust/devices/ip_profiles.py new file mode 100644 index 00000000000..413013cd2f0 --- /dev/null +++ b/src/cloudflare/resources/zero_trust/devices/ip_profiles.py @@ -0,0 +1,692 @@ +# 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 Body, Omit, Query, Headers, NotGiven, omit, not_given +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.devices import ip_profile_list_params, ip_profile_create_params, ip_profile_update_params +from ....types.zero_trust.devices.ip_profile import IPProfile +from ....types.zero_trust.devices.ip_profile_delete_response import IPProfileDeleteResponse + +__all__ = ["IPProfilesResource", "AsyncIPProfilesResource"] + + +class IPProfilesResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> IPProfilesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return IPProfilesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> IPProfilesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return IPProfilesResourceWithStreamingResponse(self) + + def create( + self, + *, + account_id: str, + match: str, + name: str, + precedence: int, + subnet_id: str, + description: Optional[str] | Omit = omit, + enabled: bool | Omit = omit, + # 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, + ) -> IPProfile: + """Creates a WARP Device IP profile. + + Currently, only IPv4 Device subnets can be + associated. + + Args: + match: + The wirefilter expression to match registrations. Available values: + "identity.name", "identity.email", "identity.groups.id", "identity.groups.name", + "identity.groups.email", "identity.saml_attributes". + + name: A user-friendly name for the Device IP profile. + + precedence: The precedence of the Device IP profile. Lower values indicate higher + precedence. Device IP profile will be evaluated in ascending order of this + field. + + subnet_id: The ID of the Subnet. + + description: An optional description of the Device IP profile. + + enabled: Whether the Device IP profile will be applied to matching devices. + + 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}/devices/ip-profiles", + body=maybe_transform( + { + "match": match, + "name": name, + "precedence": precedence, + "subnet_id": subnet_id, + "description": description, + "enabled": enabled, + }, + ip_profile_create_params.IPProfileCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[IPProfile]._unwrapper, + ), + cast_to=cast(Type[IPProfile], ResultWrapper[IPProfile]), + ) + + def update( + self, + profile_id: str, + *, + account_id: str, + description: str | Omit = omit, + enabled: bool | Omit = omit, + match: str | Omit = omit, + name: str | Omit = omit, + precedence: int | Omit = omit, + subnet_id: str | Omit = omit, + # 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, + ) -> IPProfile: + """Updates a WARP Device IP profile. + + Currently, only IPv4 Device subnets can be + associated. + + Args: + description: An optional description of the Device IP profile. + + enabled: Whether the Device IP profile is enabled. + + match: + The wirefilter expression to match registrations. Available values: + "identity.name", "identity.email", "identity.groups.id", "identity.groups.name", + "identity.groups.email", "identity.saml_attributes". + + name: A user-friendly name for the Device IP profile. + + precedence: The precedence of the Device IP profile. Lower values indicate higher + precedence. Device IP profile will be evaluated in ascending order of this + field. + + subnet_id: The ID of the Subnet. + + 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 profile_id: + raise ValueError(f"Expected a non-empty value for `profile_id` but received {profile_id!r}") + return self._patch( + f"/accounts/{account_id}/devices/ip-profiles/{profile_id}", + body=maybe_transform( + { + "description": description, + "enabled": enabled, + "match": match, + "name": name, + "precedence": precedence, + "subnet_id": subnet_id, + }, + ip_profile_update_params.IPProfileUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[IPProfile]._unwrapper, + ), + cast_to=cast(Type[IPProfile], ResultWrapper[IPProfile]), + ) + + def list( + self, + *, + account_id: str, + per_page: int | Omit = omit, + # 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[IPProfile]: + """ + Lists WARP Device IP profiles. + + Args: + per_page: The number of IP profiles to return per page. + + 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}/devices/ip-profiles", + page=SyncSinglePage[IPProfile], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform({"per_page": per_page}, ip_profile_list_params.IPProfileListParams), + ), + model=IPProfile, + ) + + def delete( + self, + profile_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, + ) -> IPProfileDeleteResponse: + """ + Delete a WARP Device IP profile. + + 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}") + if not profile_id: + raise ValueError(f"Expected a non-empty value for `profile_id` but received {profile_id!r}") + return self._delete( + f"/accounts/{account_id}/devices/ip-profiles/{profile_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[IPProfileDeleteResponse]._unwrapper, + ), + cast_to=cast(Type[IPProfileDeleteResponse], ResultWrapper[IPProfileDeleteResponse]), + ) + + def get( + self, + profile_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, + ) -> IPProfile: + """ + Fetches a single WARP Device IP profile. + + 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}") + if not profile_id: + raise ValueError(f"Expected a non-empty value for `profile_id` but received {profile_id!r}") + return self._get( + f"/accounts/{account_id}/devices/ip-profiles/{profile_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[IPProfile]._unwrapper, + ), + cast_to=cast(Type[IPProfile], ResultWrapper[IPProfile]), + ) + + +class AsyncIPProfilesResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncIPProfilesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncIPProfilesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncIPProfilesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncIPProfilesResourceWithStreamingResponse(self) + + async def create( + self, + *, + account_id: str, + match: str, + name: str, + precedence: int, + subnet_id: str, + description: Optional[str] | Omit = omit, + enabled: bool | Omit = omit, + # 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, + ) -> IPProfile: + """Creates a WARP Device IP profile. + + Currently, only IPv4 Device subnets can be + associated. + + Args: + match: + The wirefilter expression to match registrations. Available values: + "identity.name", "identity.email", "identity.groups.id", "identity.groups.name", + "identity.groups.email", "identity.saml_attributes". + + name: A user-friendly name for the Device IP profile. + + precedence: The precedence of the Device IP profile. Lower values indicate higher + precedence. Device IP profile will be evaluated in ascending order of this + field. + + subnet_id: The ID of the Subnet. + + description: An optional description of the Device IP profile. + + enabled: Whether the Device IP profile will be applied to matching devices. + + 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}/devices/ip-profiles", + body=await async_maybe_transform( + { + "match": match, + "name": name, + "precedence": precedence, + "subnet_id": subnet_id, + "description": description, + "enabled": enabled, + }, + ip_profile_create_params.IPProfileCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[IPProfile]._unwrapper, + ), + cast_to=cast(Type[IPProfile], ResultWrapper[IPProfile]), + ) + + async def update( + self, + profile_id: str, + *, + account_id: str, + description: str | Omit = omit, + enabled: bool | Omit = omit, + match: str | Omit = omit, + name: str | Omit = omit, + precedence: int | Omit = omit, + subnet_id: str | Omit = omit, + # 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, + ) -> IPProfile: + """Updates a WARP Device IP profile. + + Currently, only IPv4 Device subnets can be + associated. + + Args: + description: An optional description of the Device IP profile. + + enabled: Whether the Device IP profile is enabled. + + match: + The wirefilter expression to match registrations. Available values: + "identity.name", "identity.email", "identity.groups.id", "identity.groups.name", + "identity.groups.email", "identity.saml_attributes". + + name: A user-friendly name for the Device IP profile. + + precedence: The precedence of the Device IP profile. Lower values indicate higher + precedence. Device IP profile will be evaluated in ascending order of this + field. + + subnet_id: The ID of the Subnet. + + 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 profile_id: + raise ValueError(f"Expected a non-empty value for `profile_id` but received {profile_id!r}") + return await self._patch( + f"/accounts/{account_id}/devices/ip-profiles/{profile_id}", + body=await async_maybe_transform( + { + "description": description, + "enabled": enabled, + "match": match, + "name": name, + "precedence": precedence, + "subnet_id": subnet_id, + }, + ip_profile_update_params.IPProfileUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[IPProfile]._unwrapper, + ), + cast_to=cast(Type[IPProfile], ResultWrapper[IPProfile]), + ) + + def list( + self, + *, + account_id: str, + per_page: int | Omit = omit, + # 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[IPProfile, AsyncSinglePage[IPProfile]]: + """ + Lists WARP Device IP profiles. + + Args: + per_page: The number of IP profiles to return per page. + + 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}/devices/ip-profiles", + page=AsyncSinglePage[IPProfile], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform({"per_page": per_page}, ip_profile_list_params.IPProfileListParams), + ), + model=IPProfile, + ) + + async def delete( + self, + profile_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, + ) -> IPProfileDeleteResponse: + """ + Delete a WARP Device IP profile. + + 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}") + if not profile_id: + raise ValueError(f"Expected a non-empty value for `profile_id` but received {profile_id!r}") + return await self._delete( + f"/accounts/{account_id}/devices/ip-profiles/{profile_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[IPProfileDeleteResponse]._unwrapper, + ), + cast_to=cast(Type[IPProfileDeleteResponse], ResultWrapper[IPProfileDeleteResponse]), + ) + + async def get( + self, + profile_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, + ) -> IPProfile: + """ + Fetches a single WARP Device IP profile. + + 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}") + if not profile_id: + raise ValueError(f"Expected a non-empty value for `profile_id` but received {profile_id!r}") + return await self._get( + f"/accounts/{account_id}/devices/ip-profiles/{profile_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[IPProfile]._unwrapper, + ), + cast_to=cast(Type[IPProfile], ResultWrapper[IPProfile]), + ) + + +class IPProfilesResourceWithRawResponse: + def __init__(self, ip_profiles: IPProfilesResource) -> None: + self._ip_profiles = ip_profiles + + self.create = to_raw_response_wrapper( + ip_profiles.create, + ) + self.update = to_raw_response_wrapper( + ip_profiles.update, + ) + self.list = to_raw_response_wrapper( + ip_profiles.list, + ) + self.delete = to_raw_response_wrapper( + ip_profiles.delete, + ) + self.get = to_raw_response_wrapper( + ip_profiles.get, + ) + + +class AsyncIPProfilesResourceWithRawResponse: + def __init__(self, ip_profiles: AsyncIPProfilesResource) -> None: + self._ip_profiles = ip_profiles + + self.create = async_to_raw_response_wrapper( + ip_profiles.create, + ) + self.update = async_to_raw_response_wrapper( + ip_profiles.update, + ) + self.list = async_to_raw_response_wrapper( + ip_profiles.list, + ) + self.delete = async_to_raw_response_wrapper( + ip_profiles.delete, + ) + self.get = async_to_raw_response_wrapper( + ip_profiles.get, + ) + + +class IPProfilesResourceWithStreamingResponse: + def __init__(self, ip_profiles: IPProfilesResource) -> None: + self._ip_profiles = ip_profiles + + self.create = to_streamed_response_wrapper( + ip_profiles.create, + ) + self.update = to_streamed_response_wrapper( + ip_profiles.update, + ) + self.list = to_streamed_response_wrapper( + ip_profiles.list, + ) + self.delete = to_streamed_response_wrapper( + ip_profiles.delete, + ) + self.get = to_streamed_response_wrapper( + ip_profiles.get, + ) + + +class AsyncIPProfilesResourceWithStreamingResponse: + def __init__(self, ip_profiles: AsyncIPProfilesResource) -> None: + self._ip_profiles = ip_profiles + + self.create = async_to_streamed_response_wrapper( + ip_profiles.create, + ) + self.update = async_to_streamed_response_wrapper( + ip_profiles.update, + ) + self.list = async_to_streamed_response_wrapper( + ip_profiles.list, + ) + self.delete = async_to_streamed_response_wrapper( + ip_profiles.delete, + ) + self.get = async_to_streamed_response_wrapper( + ip_profiles.get, + ) diff --git a/src/cloudflare/types/zero_trust/devices/__init__.py b/src/cloudflare/types/zero_trust/devices/__init__.py index c6997f543e5..b8a661717f2 100644 --- a/src/cloudflare/types/zero_trust/devices/__init__.py +++ b/src/cloudflare/types/zero_trust/devices/__init__.py @@ -3,6 +3,7 @@ from __future__ import annotations from .file_input import FileInput as FileInput +from .ip_profile import IPProfile as IPProfile from .device_input import DeviceInput as DeviceInput from .device_match import DeviceMatch as DeviceMatch from .intune_input import IntuneInput as IntuneInput @@ -48,6 +49,7 @@ from .dex_test_create_params import DEXTestCreateParams as DEXTestCreateParams from .dex_test_list_response import DEXTestListResponse as DEXTestListResponse from .dex_test_update_params import DEXTestUpdateParams as DEXTestUpdateParams +from .ip_profile_list_params import IPProfileListParams as IPProfileListParams from .os_version_input_param import OSVersionInputParam as OSVersionInputParam from .revoke_create_response import RevokeCreateResponse as RevokeCreateResponse from .unique_client_id_input import UniqueClientIDInput as UniqueClientIDInput @@ -61,6 +63,8 @@ from .dex_test_create_response import DEXTestCreateResponse as DEXTestCreateResponse from .dex_test_delete_response import DEXTestDeleteResponse as DEXTestDeleteResponse from .dex_test_update_response import DEXTestUpdateResponse as DEXTestUpdateResponse +from .ip_profile_create_params import IPProfileCreateParams as IPProfileCreateParams +from .ip_profile_update_params import IPProfileUpdateParams as IPProfileUpdateParams from .registration_list_params import RegistrationListParams as RegistrationListParams from .unrevoke_create_response import UnrevokeCreateResponse as UnrevokeCreateResponse from .domain_joined_input_param import DomainJoinedInputParam as DomainJoinedInputParam @@ -68,6 +72,7 @@ from .registration_get_response import RegistrationGetResponse as RegistrationGetResponse from .workspace_one_input_param import WorkspaceOneInputParam as WorkspaceOneInputParam from .device_policy_certificates import DevicePolicyCertificates as DevicePolicyCertificates +from .ip_profile_delete_response import IPProfileDeleteResponse as IPProfileDeleteResponse from .override_code_get_response import OverrideCodeGetResponse as OverrideCodeGetResponse from .registration_list_response import RegistrationListResponse as RegistrationListResponse from .registration_revoke_params import RegistrationRevokeParams as RegistrationRevokeParams diff --git a/src/cloudflare/types/zero_trust/devices/ip_profile.py b/src/cloudflare/types/zero_trust/devices/ip_profile.py new file mode 100644 index 00000000000..93f0a5eda46 --- /dev/null +++ b/src/cloudflare/types/zero_trust/devices/ip_profile.py @@ -0,0 +1,44 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ...._models import BaseModel + +__all__ = ["IPProfile"] + + +class IPProfile(BaseModel): + id: str + """The ID of the Device IP profile.""" + + created_at: str + """The RFC3339Nano timestamp when the Device IP profile was created.""" + + description: Optional[str] = None + """An optional description of the Device IP profile.""" + + enabled: bool + """Whether the Device IP profile is enabled.""" + + match: str + """The wirefilter expression to match registrations. + + Available values: "identity.name", "identity.email", "identity.groups.id", + "identity.groups.name", "identity.groups.email", "identity.saml_attributes". + """ + + name: str + """A user-friendly name for the Device IP profile.""" + + precedence: int + """The precedence of the Device IP profile. + + Lower values indicate higher precedence. Device IP profile will be evaluated in + ascending order of this field. + """ + + subnet_id: str + """The ID of the Subnet.""" + + updated_at: str + """The RFC3339Nano timestamp when the Device IP profile was last updated.""" diff --git a/src/cloudflare/types/zero_trust/devices/ip_profile_create_params.py b/src/cloudflare/types/zero_trust/devices/ip_profile_create_params.py new file mode 100644 index 00000000000..60ab6588144 --- /dev/null +++ b/src/cloudflare/types/zero_trust/devices/ip_profile_create_params.py @@ -0,0 +1,38 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Optional +from typing_extensions import Required, TypedDict + +__all__ = ["IPProfileCreateParams"] + + +class IPProfileCreateParams(TypedDict, total=False): + account_id: Required[str] + + match: Required[str] + """The wirefilter expression to match registrations. + + Available values: "identity.name", "identity.email", "identity.groups.id", + "identity.groups.name", "identity.groups.email", "identity.saml_attributes". + """ + + name: Required[str] + """A user-friendly name for the Device IP profile.""" + + precedence: Required[int] + """The precedence of the Device IP profile. + + Lower values indicate higher precedence. Device IP profile will be evaluated in + ascending order of this field. + """ + + subnet_id: Required[str] + """The ID of the Subnet.""" + + description: Optional[str] + """An optional description of the Device IP profile.""" + + enabled: bool + """Whether the Device IP profile will be applied to matching devices.""" diff --git a/src/cloudflare/types/zero_trust/devices/ip_profile_delete_response.py b/src/cloudflare/types/zero_trust/devices/ip_profile_delete_response.py new file mode 100644 index 00000000000..de2178bc21e --- /dev/null +++ b/src/cloudflare/types/zero_trust/devices/ip_profile_delete_response.py @@ -0,0 +1,12 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from ...._models import BaseModel + +__all__ = ["IPProfileDeleteResponse"] + + +class IPProfileDeleteResponse(BaseModel): + id: Optional[str] = None + """ID of the deleted Device IP profile.""" diff --git a/src/cloudflare/types/zero_trust/devices/ip_profile_list_params.py b/src/cloudflare/types/zero_trust/devices/ip_profile_list_params.py new file mode 100644 index 00000000000..184eba34c9b --- /dev/null +++ b/src/cloudflare/types/zero_trust/devices/ip_profile_list_params.py @@ -0,0 +1,14 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["IPProfileListParams"] + + +class IPProfileListParams(TypedDict, total=False): + account_id: Required[str] + + per_page: int + """The number of IP profiles to return per page.""" diff --git a/src/cloudflare/types/zero_trust/devices/ip_profile_update_params.py b/src/cloudflare/types/zero_trust/devices/ip_profile_update_params.py new file mode 100644 index 00000000000..793212497f8 --- /dev/null +++ b/src/cloudflare/types/zero_trust/devices/ip_profile_update_params.py @@ -0,0 +1,37 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["IPProfileUpdateParams"] + + +class IPProfileUpdateParams(TypedDict, total=False): + account_id: Required[str] + + description: str + """An optional description of the Device IP profile.""" + + enabled: bool + """Whether the Device IP profile is enabled.""" + + match: str + """The wirefilter expression to match registrations. + + Available values: "identity.name", "identity.email", "identity.groups.id", + "identity.groups.name", "identity.groups.email", "identity.saml_attributes". + """ + + name: str + """A user-friendly name for the Device IP profile.""" + + precedence: int + """The precedence of the Device IP profile. + + Lower values indicate higher precedence. Device IP profile will be evaluated in + ascending order of this field. + """ + + subnet_id: str + """The ID of the Subnet.""" diff --git a/tests/api_resources/zero_trust/devices/test_ip_profiles.py b/tests/api_resources/zero_trust/devices/test_ip_profiles.py new file mode 100644 index 00000000000..14fbc171dd0 --- /dev/null +++ b/tests/api_resources/zero_trust/devices/test_ip_profiles.py @@ -0,0 +1,570 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.pagination import SyncSinglePage, AsyncSinglePage +from cloudflare.types.zero_trust.devices import ( + IPProfile, + IPProfileDeleteResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestIPProfiles: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_create(self, client: Cloudflare) -> None: + ip_profile = client.zero_trust.devices.ip_profiles.create( + account_id="account_id", + match='identity.email == "test@cloudflare.com"', + name="IPv4 Cloudflare Source IPs", + precedence=100, + subnet_id="b70ff985-a4ef-4643-bbbc-4a0ed4fc8415", + ) + assert_matches_type(IPProfile, ip_profile, path=["response"]) + + @parametrize + def test_method_create_with_all_params(self, client: Cloudflare) -> None: + ip_profile = client.zero_trust.devices.ip_profiles.create( + account_id="account_id", + match='identity.email == "test@cloudflare.com"', + name="IPv4 Cloudflare Source IPs", + precedence=100, + subnet_id="b70ff985-a4ef-4643-bbbc-4a0ed4fc8415", + description="example comment", + enabled=True, + ) + assert_matches_type(IPProfile, ip_profile, path=["response"]) + + @parametrize + def test_raw_response_create(self, client: Cloudflare) -> None: + response = client.zero_trust.devices.ip_profiles.with_raw_response.create( + account_id="account_id", + match='identity.email == "test@cloudflare.com"', + name="IPv4 Cloudflare Source IPs", + precedence=100, + subnet_id="b70ff985-a4ef-4643-bbbc-4a0ed4fc8415", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ip_profile = response.parse() + assert_matches_type(IPProfile, ip_profile, path=["response"]) + + @parametrize + def test_streaming_response_create(self, client: Cloudflare) -> None: + with client.zero_trust.devices.ip_profiles.with_streaming_response.create( + account_id="account_id", + match='identity.email == "test@cloudflare.com"', + name="IPv4 Cloudflare Source IPs", + precedence=100, + subnet_id="b70ff985-a4ef-4643-bbbc-4a0ed4fc8415", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ip_profile = response.parse() + assert_matches_type(IPProfile, ip_profile, 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.devices.ip_profiles.with_raw_response.create( + account_id="", + match='identity.email == "test@cloudflare.com"', + name="IPv4 Cloudflare Source IPs", + precedence=100, + subnet_id="b70ff985-a4ef-4643-bbbc-4a0ed4fc8415", + ) + + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + ip_profile = client.zero_trust.devices.ip_profiles.update( + profile_id="profile_id", + account_id="account_id", + ) + assert_matches_type(IPProfile, ip_profile, path=["response"]) + + @parametrize + def test_method_update_with_all_params(self, client: Cloudflare) -> None: + ip_profile = client.zero_trust.devices.ip_profiles.update( + profile_id="profile_id", + account_id="account_id", + description="example comment", + enabled=True, + match='identity.email == "test@cloudflare.com"', + name="IPv4 Cloudflare Source IPs", + precedence=100, + subnet_id="b70ff985-a4ef-4643-bbbc-4a0ed4fc8415", + ) + assert_matches_type(IPProfile, ip_profile, path=["response"]) + + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.zero_trust.devices.ip_profiles.with_raw_response.update( + profile_id="profile_id", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ip_profile = response.parse() + assert_matches_type(IPProfile, ip_profile, path=["response"]) + + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.zero_trust.devices.ip_profiles.with_streaming_response.update( + profile_id="profile_id", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ip_profile = response.parse() + assert_matches_type(IPProfile, ip_profile, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.devices.ip_profiles.with_raw_response.update( + profile_id="profile_id", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `profile_id` but received ''"): + client.zero_trust.devices.ip_profiles.with_raw_response.update( + profile_id="", + account_id="account_id", + ) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + ip_profile = client.zero_trust.devices.ip_profiles.list( + account_id="account_id", + ) + assert_matches_type(SyncSinglePage[IPProfile], ip_profile, path=["response"]) + + @parametrize + def test_method_list_with_all_params(self, client: Cloudflare) -> None: + ip_profile = client.zero_trust.devices.ip_profiles.list( + account_id="account_id", + per_page=1, + ) + assert_matches_type(SyncSinglePage[IPProfile], ip_profile, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.zero_trust.devices.ip_profiles.with_raw_response.list( + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ip_profile = response.parse() + assert_matches_type(SyncSinglePage[IPProfile], ip_profile, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.zero_trust.devices.ip_profiles.with_streaming_response.list( + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ip_profile = response.parse() + assert_matches_type(SyncSinglePage[IPProfile], ip_profile, 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.devices.ip_profiles.with_raw_response.list( + account_id="", + ) + + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + ip_profile = client.zero_trust.devices.ip_profiles.delete( + profile_id="profile_id", + account_id="account_id", + ) + assert_matches_type(IPProfileDeleteResponse, ip_profile, path=["response"]) + + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.zero_trust.devices.ip_profiles.with_raw_response.delete( + profile_id="profile_id", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ip_profile = response.parse() + assert_matches_type(IPProfileDeleteResponse, ip_profile, path=["response"]) + + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.zero_trust.devices.ip_profiles.with_streaming_response.delete( + profile_id="profile_id", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ip_profile = response.parse() + assert_matches_type(IPProfileDeleteResponse, ip_profile, 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.devices.ip_profiles.with_raw_response.delete( + profile_id="profile_id", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `profile_id` but received ''"): + client.zero_trust.devices.ip_profiles.with_raw_response.delete( + profile_id="", + account_id="account_id", + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + ip_profile = client.zero_trust.devices.ip_profiles.get( + profile_id="profile_id", + account_id="account_id", + ) + assert_matches_type(IPProfile, ip_profile, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.zero_trust.devices.ip_profiles.with_raw_response.get( + profile_id="profile_id", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ip_profile = response.parse() + assert_matches_type(IPProfile, ip_profile, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.zero_trust.devices.ip_profiles.with_streaming_response.get( + profile_id="profile_id", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ip_profile = response.parse() + assert_matches_type(IPProfile, ip_profile, 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.devices.ip_profiles.with_raw_response.get( + profile_id="profile_id", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `profile_id` but received ''"): + client.zero_trust.devices.ip_profiles.with_raw_response.get( + profile_id="", + account_id="account_id", + ) + + +class TestAsyncIPProfiles: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @parametrize + async def test_method_create(self, async_client: AsyncCloudflare) -> None: + ip_profile = await async_client.zero_trust.devices.ip_profiles.create( + account_id="account_id", + match='identity.email == "test@cloudflare.com"', + name="IPv4 Cloudflare Source IPs", + precedence=100, + subnet_id="b70ff985-a4ef-4643-bbbc-4a0ed4fc8415", + ) + assert_matches_type(IPProfile, ip_profile, path=["response"]) + + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: + ip_profile = await async_client.zero_trust.devices.ip_profiles.create( + account_id="account_id", + match='identity.email == "test@cloudflare.com"', + name="IPv4 Cloudflare Source IPs", + precedence=100, + subnet_id="b70ff985-a4ef-4643-bbbc-4a0ed4fc8415", + description="example comment", + enabled=True, + ) + assert_matches_type(IPProfile, ip_profile, path=["response"]) + + @parametrize + async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.devices.ip_profiles.with_raw_response.create( + account_id="account_id", + match='identity.email == "test@cloudflare.com"', + name="IPv4 Cloudflare Source IPs", + precedence=100, + subnet_id="b70ff985-a4ef-4643-bbbc-4a0ed4fc8415", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ip_profile = await response.parse() + assert_matches_type(IPProfile, ip_profile, path=["response"]) + + @parametrize + async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.devices.ip_profiles.with_streaming_response.create( + account_id="account_id", + match='identity.email == "test@cloudflare.com"', + name="IPv4 Cloudflare Source IPs", + precedence=100, + subnet_id="b70ff985-a4ef-4643-bbbc-4a0ed4fc8415", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ip_profile = await response.parse() + assert_matches_type(IPProfile, ip_profile, 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.devices.ip_profiles.with_raw_response.create( + account_id="", + match='identity.email == "test@cloudflare.com"', + name="IPv4 Cloudflare Source IPs", + precedence=100, + subnet_id="b70ff985-a4ef-4643-bbbc-4a0ed4fc8415", + ) + + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + ip_profile = await async_client.zero_trust.devices.ip_profiles.update( + profile_id="profile_id", + account_id="account_id", + ) + assert_matches_type(IPProfile, ip_profile, path=["response"]) + + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: + ip_profile = await async_client.zero_trust.devices.ip_profiles.update( + profile_id="profile_id", + account_id="account_id", + description="example comment", + enabled=True, + match='identity.email == "test@cloudflare.com"', + name="IPv4 Cloudflare Source IPs", + precedence=100, + subnet_id="b70ff985-a4ef-4643-bbbc-4a0ed4fc8415", + ) + assert_matches_type(IPProfile, ip_profile, path=["response"]) + + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.devices.ip_profiles.with_raw_response.update( + profile_id="profile_id", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ip_profile = await response.parse() + assert_matches_type(IPProfile, ip_profile, path=["response"]) + + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.devices.ip_profiles.with_streaming_response.update( + profile_id="profile_id", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ip_profile = await response.parse() + assert_matches_type(IPProfile, ip_profile, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.zero_trust.devices.ip_profiles.with_raw_response.update( + profile_id="profile_id", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `profile_id` but received ''"): + await async_client.zero_trust.devices.ip_profiles.with_raw_response.update( + profile_id="", + account_id="account_id", + ) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + ip_profile = await async_client.zero_trust.devices.ip_profiles.list( + account_id="account_id", + ) + assert_matches_type(AsyncSinglePage[IPProfile], ip_profile, path=["response"]) + + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: + ip_profile = await async_client.zero_trust.devices.ip_profiles.list( + account_id="account_id", + per_page=1, + ) + assert_matches_type(AsyncSinglePage[IPProfile], ip_profile, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.devices.ip_profiles.with_raw_response.list( + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ip_profile = await response.parse() + assert_matches_type(AsyncSinglePage[IPProfile], ip_profile, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.devices.ip_profiles.with_streaming_response.list( + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ip_profile = await response.parse() + assert_matches_type(AsyncSinglePage[IPProfile], ip_profile, 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.devices.ip_profiles.with_raw_response.list( + account_id="", + ) + + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + ip_profile = await async_client.zero_trust.devices.ip_profiles.delete( + profile_id="profile_id", + account_id="account_id", + ) + assert_matches_type(IPProfileDeleteResponse, ip_profile, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.devices.ip_profiles.with_raw_response.delete( + profile_id="profile_id", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ip_profile = await response.parse() + assert_matches_type(IPProfileDeleteResponse, ip_profile, path=["response"]) + + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.devices.ip_profiles.with_streaming_response.delete( + profile_id="profile_id", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ip_profile = await response.parse() + assert_matches_type(IPProfileDeleteResponse, ip_profile, 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.devices.ip_profiles.with_raw_response.delete( + profile_id="profile_id", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `profile_id` but received ''"): + await async_client.zero_trust.devices.ip_profiles.with_raw_response.delete( + profile_id="", + account_id="account_id", + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + ip_profile = await async_client.zero_trust.devices.ip_profiles.get( + profile_id="profile_id", + account_id="account_id", + ) + assert_matches_type(IPProfile, ip_profile, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.devices.ip_profiles.with_raw_response.get( + profile_id="profile_id", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + ip_profile = await response.parse() + assert_matches_type(IPProfile, ip_profile, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.devices.ip_profiles.with_streaming_response.get( + profile_id="profile_id", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + ip_profile = await response.parse() + assert_matches_type(IPProfile, ip_profile, 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.devices.ip_profiles.with_raw_response.get( + profile_id="profile_id", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `profile_id` but received ''"): + await async_client.zero_trust.devices.ip_profiles.with_raw_response.get( + profile_id="", + account_id="account_id", + ) From 2358e0af7d1023765832e67d1bf727b68eee4eb3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 5 Mar 2026 16:41:05 +0000 Subject: [PATCH 08/12] feat: chore(zero_trust_device_ip_profile): skip go prism tests --- .stats.yml | 2 +- .../zero_trust/devices/test_ip_profiles.py | 46 +++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index abfd2fbdca7..5798a769b7d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 2050 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9ba099b7936091cc984d2a24fc4d32c3ffcb1d71d86412c8c9084d201e16b3ac.yml openapi_spec_hash: 45edc9a107cf5a5e3b204b230b0d336d -config_hash: 082014e766adf9596cfb12f88a73329a +config_hash: e0714aca87c83c7d709440ec515aef8a diff --git a/tests/api_resources/zero_trust/devices/test_ip_profiles.py b/tests/api_resources/zero_trust/devices/test_ip_profiles.py index 14fbc171dd0..3bafccc9b0d 100644 --- a/tests/api_resources/zero_trust/devices/test_ip_profiles.py +++ b/tests/api_resources/zero_trust/devices/test_ip_profiles.py @@ -21,6 +21,7 @@ class TestIPProfiles: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @parametrize def test_method_create(self, client: Cloudflare) -> None: ip_profile = client.zero_trust.devices.ip_profiles.create( @@ -32,6 +33,7 @@ def test_method_create(self, client: Cloudflare) -> None: ) assert_matches_type(IPProfile, ip_profile, path=["response"]) + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: ip_profile = client.zero_trust.devices.ip_profiles.create( @@ -45,6 +47,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: ) assert_matches_type(IPProfile, ip_profile, path=["response"]) + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: response = client.zero_trust.devices.ip_profiles.with_raw_response.create( @@ -60,6 +63,7 @@ def test_raw_response_create(self, client: Cloudflare) -> None: ip_profile = response.parse() assert_matches_type(IPProfile, ip_profile, path=["response"]) + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: with client.zero_trust.devices.ip_profiles.with_streaming_response.create( @@ -77,6 +81,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @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 ''"): @@ -88,6 +93,7 @@ def test_path_params_create(self, client: Cloudflare) -> None: subnet_id="b70ff985-a4ef-4643-bbbc-4a0ed4fc8415", ) + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @parametrize def test_method_update(self, client: Cloudflare) -> None: ip_profile = client.zero_trust.devices.ip_profiles.update( @@ -96,6 +102,7 @@ def test_method_update(self, client: Cloudflare) -> None: ) assert_matches_type(IPProfile, ip_profile, path=["response"]) + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @parametrize def test_method_update_with_all_params(self, client: Cloudflare) -> None: ip_profile = client.zero_trust.devices.ip_profiles.update( @@ -110,6 +117,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: ) assert_matches_type(IPProfile, ip_profile, path=["response"]) + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: response = client.zero_trust.devices.ip_profiles.with_raw_response.update( @@ -122,6 +130,7 @@ def test_raw_response_update(self, client: Cloudflare) -> None: ip_profile = response.parse() assert_matches_type(IPProfile, ip_profile, path=["response"]) + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: with client.zero_trust.devices.ip_profiles.with_streaming_response.update( @@ -136,6 +145,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @parametrize def test_path_params_update(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -150,6 +160,7 @@ def test_path_params_update(self, client: Cloudflare) -> None: account_id="account_id", ) + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @parametrize def test_method_list(self, client: Cloudflare) -> None: ip_profile = client.zero_trust.devices.ip_profiles.list( @@ -157,6 +168,7 @@ def test_method_list(self, client: Cloudflare) -> None: ) assert_matches_type(SyncSinglePage[IPProfile], ip_profile, path=["response"]) + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @parametrize def test_method_list_with_all_params(self, client: Cloudflare) -> None: ip_profile = client.zero_trust.devices.ip_profiles.list( @@ -165,6 +177,7 @@ def test_method_list_with_all_params(self, client: Cloudflare) -> None: ) assert_matches_type(SyncSinglePage[IPProfile], ip_profile, path=["response"]) + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @parametrize def test_raw_response_list(self, client: Cloudflare) -> None: response = client.zero_trust.devices.ip_profiles.with_raw_response.list( @@ -176,6 +189,7 @@ def test_raw_response_list(self, client: Cloudflare) -> None: ip_profile = response.parse() assert_matches_type(SyncSinglePage[IPProfile], ip_profile, path=["response"]) + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @parametrize def test_streaming_response_list(self, client: Cloudflare) -> None: with client.zero_trust.devices.ip_profiles.with_streaming_response.list( @@ -189,6 +203,7 @@ def test_streaming_response_list(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @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 ''"): @@ -196,6 +211,7 @@ def test_path_params_list(self, client: Cloudflare) -> None: account_id="", ) + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @parametrize def test_method_delete(self, client: Cloudflare) -> None: ip_profile = client.zero_trust.devices.ip_profiles.delete( @@ -204,6 +220,7 @@ def test_method_delete(self, client: Cloudflare) -> None: ) assert_matches_type(IPProfileDeleteResponse, ip_profile, path=["response"]) + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @parametrize def test_raw_response_delete(self, client: Cloudflare) -> None: response = client.zero_trust.devices.ip_profiles.with_raw_response.delete( @@ -216,6 +233,7 @@ def test_raw_response_delete(self, client: Cloudflare) -> None: ip_profile = response.parse() assert_matches_type(IPProfileDeleteResponse, ip_profile, path=["response"]) + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @parametrize def test_streaming_response_delete(self, client: Cloudflare) -> None: with client.zero_trust.devices.ip_profiles.with_streaming_response.delete( @@ -230,6 +248,7 @@ def test_streaming_response_delete(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @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 ''"): @@ -244,6 +263,7 @@ def test_path_params_delete(self, client: Cloudflare) -> None: account_id="account_id", ) + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @parametrize def test_method_get(self, client: Cloudflare) -> None: ip_profile = client.zero_trust.devices.ip_profiles.get( @@ -252,6 +272,7 @@ def test_method_get(self, client: Cloudflare) -> None: ) assert_matches_type(IPProfile, ip_profile, path=["response"]) + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: response = client.zero_trust.devices.ip_profiles.with_raw_response.get( @@ -264,6 +285,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: ip_profile = response.parse() assert_matches_type(IPProfile, ip_profile, path=["response"]) + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: with client.zero_trust.devices.ip_profiles.with_streaming_response.get( @@ -278,6 +300,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @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 ''"): @@ -298,6 +321,7 @@ class TestAsyncIPProfiles: "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] ) + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @parametrize async def test_method_create(self, async_client: AsyncCloudflare) -> None: ip_profile = await async_client.zero_trust.devices.ip_profiles.create( @@ -309,6 +333,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(IPProfile, ip_profile, path=["response"]) + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: ip_profile = await async_client.zero_trust.devices.ip_profiles.create( @@ -322,6 +347,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare ) assert_matches_type(IPProfile, ip_profile, path=["response"]) + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: response = await async_client.zero_trust.devices.ip_profiles.with_raw_response.create( @@ -337,6 +363,7 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: ip_profile = await response.parse() assert_matches_type(IPProfile, ip_profile, path=["response"]) + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: async with async_client.zero_trust.devices.ip_profiles.with_streaming_response.create( @@ -354,6 +381,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @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 ''"): @@ -365,6 +393,7 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: subnet_id="b70ff985-a4ef-4643-bbbc-4a0ed4fc8415", ) + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @parametrize async def test_method_update(self, async_client: AsyncCloudflare) -> None: ip_profile = await async_client.zero_trust.devices.ip_profiles.update( @@ -373,6 +402,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(IPProfile, ip_profile, path=["response"]) + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @parametrize async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: ip_profile = await async_client.zero_trust.devices.ip_profiles.update( @@ -387,6 +417,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare ) assert_matches_type(IPProfile, ip_profile, path=["response"]) + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: response = await async_client.zero_trust.devices.ip_profiles.with_raw_response.update( @@ -399,6 +430,7 @@ async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: ip_profile = await response.parse() assert_matches_type(IPProfile, ip_profile, path=["response"]) + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: async with async_client.zero_trust.devices.ip_profiles.with_streaming_response.update( @@ -413,6 +445,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @parametrize async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): @@ -427,6 +460,7 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: account_id="account_id", ) + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @parametrize async def test_method_list(self, async_client: AsyncCloudflare) -> None: ip_profile = await async_client.zero_trust.devices.ip_profiles.list( @@ -434,6 +468,7 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(AsyncSinglePage[IPProfile], ip_profile, path=["response"]) + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @parametrize async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: ip_profile = await async_client.zero_trust.devices.ip_profiles.list( @@ -442,6 +477,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) ) assert_matches_type(AsyncSinglePage[IPProfile], ip_profile, path=["response"]) + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @parametrize async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: response = await async_client.zero_trust.devices.ip_profiles.with_raw_response.list( @@ -453,6 +489,7 @@ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: ip_profile = await response.parse() assert_matches_type(AsyncSinglePage[IPProfile], ip_profile, path=["response"]) + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @parametrize async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: async with async_client.zero_trust.devices.ip_profiles.with_streaming_response.list( @@ -466,6 +503,7 @@ async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> N assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @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 ''"): @@ -473,6 +511,7 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: account_id="", ) + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @parametrize async def test_method_delete(self, async_client: AsyncCloudflare) -> None: ip_profile = await async_client.zero_trust.devices.ip_profiles.delete( @@ -481,6 +520,7 @@ async def test_method_delete(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(IPProfileDeleteResponse, ip_profile, path=["response"]) + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @parametrize async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: response = await async_client.zero_trust.devices.ip_profiles.with_raw_response.delete( @@ -493,6 +533,7 @@ async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: ip_profile = await response.parse() assert_matches_type(IPProfileDeleteResponse, ip_profile, path=["response"]) + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @parametrize async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: async with async_client.zero_trust.devices.ip_profiles.with_streaming_response.delete( @@ -507,6 +548,7 @@ async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @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 ''"): @@ -521,6 +563,7 @@ async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: account_id="account_id", ) + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @parametrize async def test_method_get(self, async_client: AsyncCloudflare) -> None: ip_profile = await async_client.zero_trust.devices.ip_profiles.get( @@ -529,6 +572,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(IPProfile, ip_profile, path=["response"]) + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: response = await async_client.zero_trust.devices.ip_profiles.with_raw_response.get( @@ -541,6 +585,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: ip_profile = await response.parse() assert_matches_type(IPProfile, ip_profile, path=["response"]) + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: async with async_client.zero_trust.devices.ip_profiles.with_streaming_response.get( @@ -555,6 +600,7 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="401 Unauthorized: Prism doesnt handle api tokens") @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 ''"): From 76eacbbe8f01e7c2f72e209d189595c63317de57 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 5 Mar 2026 18:06:29 +0000 Subject: [PATCH 09/12] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 5798a769b7d..5006ac24b6c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 2050 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9ba099b7936091cc984d2a24fc4d32c3ffcb1d71d86412c8c9084d201e16b3ac.yml openapi_spec_hash: 45edc9a107cf5a5e3b204b230b0d336d -config_hash: e0714aca87c83c7d709440ec515aef8a +config_hash: ebde54bdd7ec58f9abf7de1c45a2c076 From 31cc1676eeeef320495c7527252e92e0a8d4f972 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 5 Mar 2026 20:55:33 +0000 Subject: [PATCH 10/12] chore(api): update composite API spec --- .stats.yml | 6 +- api.md | 7 +- .../resources/abuse_reports/abuse_reports.py | 8 +- src/cloudflare/resources/ai/models/schema.py | 4 +- src/cloudflare/resources/ai/to_markdown.py | 8 +- .../resources/ai_gateway/ai_gateway.py | 44 +- .../resources/ai_gateway/datasets.py | 20 +- .../resources/ai_gateway/evaluations.py | 16 +- src/cloudflare/resources/ai_gateway/logs.py | 16 +- .../resources/ai_gateway/provider_configs.py | 8 +- src/cloudflare/resources/ai_gateway/urls.py | 4 +- .../resources/aisearch/instances/instances.py | 42 +- .../resources/aisearch/instances/items.py | 105 -- .../resources/aisearch/instances/jobs.py | 6 +- src/cloudflare/resources/aisearch/tokens.py | 17 + .../resources/api_gateway/configurations.py | 18 +- .../expression_template/fallthrough.py | 12 +- .../api_gateway/operations/operations.py | 30 +- .../api_gateway/user_schemas/hosts.py | 12 +- .../api_gateway/user_schemas/user_schemas.py | 36 +- .../threat_events/datasets/datasets.py | 12 +- .../email_security/investigate/investigate.py | 34 +- .../email_security/investigate/move.py | 6 +- .../email_security/investigate/preview.py | 6 +- .../email_security/investigate/reclassify.py | 6 +- .../email_security/investigate/release.py | 6 +- .../email_security/investigate/trace.py | 6 +- .../email_security/phishguard/reports.py | 6 +- .../email_security/settings/allow_policies.py | 30 +- .../email_security/settings/block_senders.py | 26 +- .../email_security/settings/domains.py | 14 +- .../settings/impersonation_registry.py | 16 +- .../settings/trusted_domains.py | 26 +- .../resources/email_security/submissions.py | 4 + .../resources/magic_transit/apps.py | 30 + .../magic_transit/connectors/connectors.py | 71 +- .../resources/magic_transit/sites/lans.py | 48 + .../resources/radar/ai/inference/inference.py | 4 +- .../resources/radar/ai/to_markdown.py | 4 +- src/cloudflare/resources/radar/dns/dns.py | 16 +- src/cloudflare/resources/radar/http/http.py | 8 + .../resources/radar/netflows/netflows.py | 8 +- src/cloudflare/resources/rulesets/rules.py | 730 +++++++++- .../resources/schema_validation/schemas.py | 40 +- .../schema_validation/settings/operations.py | 26 +- .../schema_validation/settings/settings.py | 16 +- src/cloudflare/resources/speed/schedule.py | 24 +- .../resources/workers/scripts/versions.py | 4 +- .../resources/workflows/instances/events.py | 4 +- .../workflows/instances/instances.py | 44 +- .../resources/workflows/instances/status.py | 6 +- .../resources/workflows/versions.py | 8 +- .../resources/workflows/workflows.py | 16 +- .../zero_trust/dlp/profiles/custom.py | 56 +- .../abuse_report_create_params.py | 2 +- .../ai_gateway/ai_gateway_create_params.py | 5 +- .../ai_gateway/ai_gateway_create_response.py | 11 +- .../ai_gateway/ai_gateway_delete_response.py | 11 +- .../ai_gateway/ai_gateway_get_response.py | 11 +- .../ai_gateway/ai_gateway_list_response.py | 11 +- .../ai_gateway/ai_gateway_update_params.py | 7 +- .../ai_gateway/ai_gateway_update_response.py | 11 +- .../ai_gateway/dataset_create_response.py | 4 - .../ai_gateway/dataset_delete_response.py | 4 - .../types/ai_gateway/dataset_get_response.py | 4 - .../types/ai_gateway/dataset_list_response.py | 4 - .../ai_gateway/dataset_update_response.py | 4 - ...amic_routing_create_deployment_response.py | 2 - .../dynamic_routing_create_response.py | 2 - ...dynamic_routing_create_version_response.py | 2 - .../dynamic_routing_delete_response.py | 2 - .../dynamic_routing_get_response.py | 2 - .../dynamic_routing_get_version_response.py | 2 - .../ai_gateway/evaluation_create_response.py | 4 - .../ai_gateway/evaluation_delete_response.py | 4 - .../ai_gateway/evaluation_get_response.py | 4 - .../ai_gateway/evaluation_list_response.py | 4 - .../provider_config_create_response.py | 4 - .../provider_config_list_response.py | 4 - .../instance_chat_completions_params.py | 28 + .../types/aisearch/instance_create_params.py | 64 +- .../aisearch/instance_create_response.py | 60 +- .../aisearch/instance_delete_response.py | 60 +- .../types/aisearch/instance_list_params.py | 8 +- .../types/aisearch/instance_list_response.py | 60 +- .../types/aisearch/instance_read_response.py | 60 +- .../types/aisearch/instance_search_params.py | 28 + .../types/aisearch/instance_update_params.py | 52 + .../aisearch/instance_update_response.py | 60 +- .../types/aisearch/instances/__init__.py | 2 +- .../aisearch/instances/item_get_response.py | 35 - .../aisearch/instances/job_create_params.py | 13 + .../aisearch/instances/job_create_response.py | 2 + .../aisearch/instances/job_get_response.py | 2 + .../aisearch/instances/job_list_response.py | 2 + .../types/aisearch/token_list_params.py | 8 +- .../threat_events/dataset_raw_response.py | 4 +- src/cloudflare/types/d1/d1.py | 6 + .../types/d1/database_list_response.py | 7 + .../investigate_get_response.py | 2 + .../email_security/investigate_list_params.py | 14 +- .../investigate_list_response.py | 2 + .../email_security/submission_list_params.py | 2 + .../submission_list_response.py | 2 + .../types/magic_transit/app_create_params.py | 6 + .../magic_transit/app_create_response.py | 6 + .../magic_transit/app_delete_response.py | 6 + .../types/magic_transit/app_edit_params.py | 6 + .../types/magic_transit/app_edit_response.py | 6 + .../types/magic_transit/app_list_response.py | 12 + .../types/magic_transit/app_update_params.py | 6 + .../magic_transit/app_update_response.py | 6 + .../magic_transit/connector_create_params.py | 13 +- .../connector_create_response.py | 11 +- .../connector_delete_response.py | 11 +- .../magic_transit/connector_edit_params.py | 13 +- .../magic_transit/connector_edit_response.py | 11 +- .../magic_transit/connector_get_response.py | 11 +- .../magic_transit/connector_list_response.py | 11 +- .../magic_transit/connector_update_params.py | 13 +- .../connector_update_response.py | 11 +- .../types/magic_transit/sites/lan.py | 6 + .../magic_transit/sites/lan_create_params.py | 6 + .../magic_transit/sites/lan_edit_params.py | 6 + .../magic_transit/sites/lan_update_params.py | 6 + .../types/pipelines/sink_get_response.py | 52 +- .../types/pipelines/sink_list_response.py | 52 +- .../inference_timeseries_groups_v2_params.py | 2 +- .../types/radar/geolocation_get_response.py | 7 + .../types/radar/geolocation_list_response.py | 8 +- src/cloudflare/types/rulesets/phase.py | 1 + .../types/rulesets/phase_get_response.py | 762 ++++++++++ .../types/rulesets/phase_update_params.py | 740 +++++++++- .../types/rulesets/phase_update_response.py | 762 ++++++++++ .../rulesets/phases/version_get_response.py | 762 ++++++++++ .../types/rulesets/rule_create_params.py | 826 ++++++++++- .../types/rulesets/rule_create_response.py | 762 ++++++++++ .../types/rulesets/rule_delete_response.py | 762 ++++++++++ .../types/rulesets/rule_edit_params.py | 832 ++++++++++- .../types/rulesets/rule_edit_response.py | 762 ++++++++++ .../types/rulesets/ruleset_create_params.py | 740 +++++++++- .../types/rulesets/ruleset_create_response.py | 762 ++++++++++ .../types/rulesets/ruleset_get_response.py | 762 ++++++++++ .../types/rulesets/ruleset_update_params.py | 740 +++++++++- .../types/rulesets/ruleset_update_response.py | 762 ++++++++++ .../types/rulesets/set_cache_settings_rule.py | 9 + .../rulesets/set_cache_settings_rule_param.py | 9 + .../types/rulesets/version_get_response.py | 762 ++++++++++ .../security_txt/security_txt_get_response.py | 4 +- .../security_txt_update_params.py | 2 +- .../types/speed/schedule_create_params.py | 6 + .../configuration_edit_response.py | 3 + .../types/workers/beta/workers/version.py | 7 + src/cloudflare/types/workflows/__init__.py | 1 + .../types/workflows/instance_get_params.py | 19 + .../types/workflows/instance_get_response.py | 2 + .../types/workflows/version_get_response.py | 9 +- .../types/workflows/version_list_response.py | 9 +- .../types/workflows/workflow_update_params.py | 8 +- .../dlp/payload_log_get_response.py | 6 +- .../dlp/payload_log_update_response.py | 6 +- .../types/zero_trust/dlp/profile.py | 9 + .../dlp/profiles/custom_create_params.py | 11 + .../dlp/profiles/custom_update_params.py | 19 + .../types/zones/setting_edit_response.py | 24 + .../types/zones/setting_get_response.py | 24 + .../aisearch/instances/test_items.py | 122 +- .../aisearch/instances/test_jobs.py | 18 + .../api_resources/aisearch/test_instances.py | 120 +- tests/api_resources/aisearch/test_tokens.py | 4 + .../email_security/test_investigate.py | 2 + .../email_security/test_submissions.py | 2 + .../magic_transit/sites/test_lans.py | 12 + .../api_resources/magic_transit/test_apps.py | 6 + .../magic_transit/test_connectors.py | 24 +- .../api_resources/radar/ai/test_inference.py | 4 +- tests/api_resources/radar/test_dns.py | 32 +- tests/api_resources/rulesets/test_rules.py | 1240 +++++++++++++++-- tests/api_resources/speed/test_schedule.py | 2 + tests/api_resources/test_ai_gateway.py | 10 +- tests/api_resources/test_workflows.py | 22 + .../api_resources/workflows/test_instances.py | 22 + .../zero_trust/dlp/profiles/test_custom.py | 12 + 183 files changed, 15188 insertions(+), 944 deletions(-) delete mode 100644 src/cloudflare/types/aisearch/instances/item_get_response.py create mode 100644 src/cloudflare/types/aisearch/instances/job_create_params.py create mode 100644 src/cloudflare/types/workflows/instance_get_params.py diff --git a/.stats.yml b/.stats.yml index 5006ac24b6c..10011598aba 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 2050 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-9ba099b7936091cc984d2a24fc4d32c3ffcb1d71d86412c8c9084d201e16b3ac.yml -openapi_spec_hash: 45edc9a107cf5a5e3b204b230b0d336d +configured_endpoints: 2049 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ee23c4fe5cfe74e6576003db5f37b8b85cd8aaae1ff7576ccd2e16fa47008934.yml +openapi_spec_hash: 20046482414d30b12cdc7ab777b15e94 config_hash: ebde54bdd7ec58f9abf7de1c45a2c076 diff --git a/api.md b/api.md index 3ddbf724f9b..fdf2a04d227 100644 --- a/api.md +++ b/api.md @@ -10443,7 +10443,7 @@ Methods: - client.workflows.instances.create(workflow_name, \*, account_id, \*\*params) -> InstanceCreateResponse - client.workflows.instances.list(workflow_name, \*, account_id, \*\*params) -> SyncV4PagePaginationArray[InstanceListResponse] - client.workflows.instances.bulk(workflow_name, \*, account_id, \*\*params) -> SyncSinglePage[InstanceBulkResponse] -- client.workflows.instances.get(instance_id, \*, account_id, workflow_name) -> InstanceGetResponse +- client.workflows.instances.get(instance_id, \*, account_id, workflow_name, \*\*params) -> InstanceGetResponse ### Status @@ -10785,13 +10785,12 @@ Methods: Types: ```python -from cloudflare.types.aisearch.instances import ItemListResponse, ItemGetResponse +from cloudflare.types.aisearch.instances import ItemListResponse ``` Methods: - client.aisearch.instances.items.list(id, \*, account_id, \*\*params) -> SyncV4PagePaginationArray[ItemListResponse] -- client.aisearch.instances.items.get(item_id, \*, account_id, id) -> ItemGetResponse ### Jobs @@ -10808,7 +10807,7 @@ from cloudflare.types.aisearch.instances import ( Methods: -- client.aisearch.instances.jobs.create(id, \*, account_id) -> JobCreateResponse +- client.aisearch.instances.jobs.create(id, \*, account_id, \*\*params) -> JobCreateResponse - client.aisearch.instances.jobs.list(id, \*, account_id, \*\*params) -> SyncV4PagePaginationArray[JobListResponse] - client.aisearch.instances.jobs.get(job_id, \*, account_id, id) -> JobGetResponse - client.aisearch.instances.jobs.logs(job_id, \*, account_id, id, \*\*params) -> JobLogsResponse diff --git a/src/cloudflare/resources/abuse_reports/abuse_reports.py b/src/cloudflare/resources/abuse_reports/abuse_reports.py index 9cf0a64aa03..0766fbdbf26 100644 --- a/src/cloudflare/resources/abuse_reports/abuse_reports.py +++ b/src/cloudflare/resources/abuse_reports/abuse_reports.py @@ -273,7 +273,7 @@ def create( host_notification: Literal["send", "send-anon"], justification: str, name: str, - owner_notification: Literal["send", "send-anon", "none"], + owner_notification: Literal["send", "send-anon"], urls: str, comments: str | Omit = omit, company: str | Omit = omit, @@ -866,7 +866,7 @@ def create( host_notification: Literal["send"] | Literal["send", "send-anon"] | Omit = omit, name: str, original_work: str | Omit = omit, - owner_notification: Literal["send"] | Literal["send", "send-anon", "none"] | Literal["send", "send-anon"], + owner_notification: Literal["send"] | Literal["send", "send-anon"] | Literal["send", "send-anon", "none"], signature: str | Omit = omit, state: str | Omit = omit, urls: str, @@ -1299,7 +1299,7 @@ async def create( host_notification: Literal["send", "send-anon"], justification: str, name: str, - owner_notification: Literal["send", "send-anon", "none"], + owner_notification: Literal["send", "send-anon"], urls: str, comments: str | Omit = omit, company: str | Omit = omit, @@ -1892,7 +1892,7 @@ async def create( host_notification: Literal["send"] | Literal["send", "send-anon"] | Omit = omit, name: str, original_work: str | Omit = omit, - owner_notification: Literal["send"] | Literal["send", "send-anon", "none"] | Literal["send", "send-anon"], + owner_notification: Literal["send"] | Literal["send", "send-anon"] | Literal["send", "send-anon", "none"], signature: str | Omit = omit, state: str | Omit = omit, urls: str, diff --git a/src/cloudflare/resources/ai/models/schema.py b/src/cloudflare/resources/ai/models/schema.py index d555ab98627..a041d762955 100644 --- a/src/cloudflare/resources/ai/models/schema.py +++ b/src/cloudflare/resources/ai/models/schema.py @@ -57,7 +57,7 @@ def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SchemaGetResponse: """ - Get Model Schema + Retrieves the input and output JSON schema definition for a Workers AI model. Args: model: Model Name @@ -119,7 +119,7 @@ async def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SchemaGetResponse: """ - Get Model Schema + Retrieves the input and output JSON schema definition for a Workers AI model. Args: model: Model Name diff --git a/src/cloudflare/resources/ai/to_markdown.py b/src/cloudflare/resources/ai/to_markdown.py index 15cab8aa9e4..a4792606100 100644 --- a/src/cloudflare/resources/ai/to_markdown.py +++ b/src/cloudflare/resources/ai/to_markdown.py @@ -57,7 +57,7 @@ def supported( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncSinglePage[ToMarkdownSupportedResponse]: """ - Get all converted formats supported + Lists all file formats supported for conversion to Markdown. Args: extra_headers: Send extra headers @@ -92,7 +92,7 @@ def transform( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncSinglePage[ToMarkdownTransformResponse]: """ - Convert Files into Markdown + Converts uploaded files into Markdown format using Workers AI. Args: extra_headers: Send extra headers @@ -156,7 +156,7 @@ def supported( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[ToMarkdownSupportedResponse, AsyncSinglePage[ToMarkdownSupportedResponse]]: """ - Get all converted formats supported + Lists all file formats supported for conversion to Markdown. Args: extra_headers: Send extra headers @@ -191,7 +191,7 @@ def transform( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[ToMarkdownTransformResponse, AsyncSinglePage[ToMarkdownTransformResponse]]: """ - Convert Files into Markdown + Converts uploaded files into Markdown format using Workers AI. Args: extra_headers: Send extra headers diff --git a/src/cloudflare/resources/ai_gateway/ai_gateway.py b/src/cloudflare/resources/ai_gateway/ai_gateway.py index 545ad9b28e6..43c3b00b118 100644 --- a/src/cloudflare/resources/ai_gateway/ai_gateway.py +++ b/src/cloudflare/resources/ai_gateway/ai_gateway.py @@ -146,11 +146,11 @@ def create( rate_limiting_limit: Optional[int], rate_limiting_technique: Literal["fixed", "sliding"], authentication: bool | Omit = omit, - is_default: bool | Omit = omit, log_management: Optional[int] | Omit = omit, log_management_strategy: Optional[Literal["STOP_INSERTING", "DELETE_OLDEST"]] | Omit = omit, logpush: bool | Omit = omit, logpush_public_key: Optional[str] | Omit = omit, + workers_ai_billing_mode: Literal["postpaid", "unified"] | Omit = omit, zdr: bool | Omit = omit, # 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. @@ -160,11 +160,13 @@ def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AIGatewayCreateResponse: """ - Create a new Gateway + Creates a new AI Gateway. Args: id: gateway id + workers_ai_billing_mode: Controls how Workers AI inference calls routed through this gateway are billed + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -187,11 +189,11 @@ def create( "rate_limiting_limit": rate_limiting_limit, "rate_limiting_technique": rate_limiting_technique, "authentication": authentication, - "is_default": is_default, "log_management": log_management, "log_management_strategy": log_management_strategy, "logpush": logpush, "logpush_public_key": logpush_public_key, + "workers_ai_billing_mode": workers_ai_billing_mode, "zdr": zdr, }, ai_gateway_create_params.AIGatewayCreateParams, @@ -219,7 +221,6 @@ def update( rate_limiting_technique: Literal["fixed", "sliding"], authentication: bool | Omit = omit, dlp: ai_gateway_update_params.DLP | Omit = omit, - is_default: bool | Omit = omit, log_management: Optional[int] | Omit = omit, log_management_strategy: Optional[Literal["STOP_INSERTING", "DELETE_OLDEST"]] | Omit = omit, logpush: bool | Omit = omit, @@ -227,6 +228,7 @@ def update( otel: Optional[Iterable[ai_gateway_update_params.Otel]] | Omit = omit, store_id: Optional[str] | Omit = omit, stripe: Optional[ai_gateway_update_params.Stripe] | Omit = omit, + workers_ai_billing_mode: Literal["postpaid", "unified"] | Omit = omit, zdr: bool | Omit = omit, # 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. @@ -236,11 +238,13 @@ def update( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AIGatewayUpdateResponse: """ - Update a Gateway + Updates an existing AI Gateway dataset. Args: id: gateway id + workers_ai_billing_mode: Controls how Workers AI inference calls routed through this gateway are billed + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -265,7 +269,6 @@ def update( "rate_limiting_technique": rate_limiting_technique, "authentication": authentication, "dlp": dlp, - "is_default": is_default, "log_management": log_management, "log_management_strategy": log_management_strategy, "logpush": logpush, @@ -273,6 +276,7 @@ def update( "otel": otel, "store_id": store_id, "stripe": stripe, + "workers_ai_billing_mode": workers_ai_billing_mode, "zdr": zdr, }, ai_gateway_update_params.AIGatewayUpdateParams, @@ -302,7 +306,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncV4PagePaginationArray[AIGatewayListResponse]: """ - List Gateways + Lists all AI Gateway evaluator types configured for the account. Args: search: Search by id @@ -350,7 +354,7 @@ def delete( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AIGatewayDeleteResponse: """ - Delete a Gateway + Deletes an AI Gateway dataset. Args: id: gateway id @@ -392,7 +396,7 @@ def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AIGatewayGetResponse: """ - Fetch a Gateway + Retrieves details for a specific AI Gateway dataset. Args: id: gateway id @@ -482,11 +486,11 @@ async def create( rate_limiting_limit: Optional[int], rate_limiting_technique: Literal["fixed", "sliding"], authentication: bool | Omit = omit, - is_default: bool | Omit = omit, log_management: Optional[int] | Omit = omit, log_management_strategy: Optional[Literal["STOP_INSERTING", "DELETE_OLDEST"]] | Omit = omit, logpush: bool | Omit = omit, logpush_public_key: Optional[str] | Omit = omit, + workers_ai_billing_mode: Literal["postpaid", "unified"] | Omit = omit, zdr: bool | Omit = omit, # 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. @@ -496,11 +500,13 @@ async def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AIGatewayCreateResponse: """ - Create a new Gateway + Creates a new AI Gateway. Args: id: gateway id + workers_ai_billing_mode: Controls how Workers AI inference calls routed through this gateway are billed + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -523,11 +529,11 @@ async def create( "rate_limiting_limit": rate_limiting_limit, "rate_limiting_technique": rate_limiting_technique, "authentication": authentication, - "is_default": is_default, "log_management": log_management, "log_management_strategy": log_management_strategy, "logpush": logpush, "logpush_public_key": logpush_public_key, + "workers_ai_billing_mode": workers_ai_billing_mode, "zdr": zdr, }, ai_gateway_create_params.AIGatewayCreateParams, @@ -555,7 +561,6 @@ async def update( rate_limiting_technique: Literal["fixed", "sliding"], authentication: bool | Omit = omit, dlp: ai_gateway_update_params.DLP | Omit = omit, - is_default: bool | Omit = omit, log_management: Optional[int] | Omit = omit, log_management_strategy: Optional[Literal["STOP_INSERTING", "DELETE_OLDEST"]] | Omit = omit, logpush: bool | Omit = omit, @@ -563,6 +568,7 @@ async def update( otel: Optional[Iterable[ai_gateway_update_params.Otel]] | Omit = omit, store_id: Optional[str] | Omit = omit, stripe: Optional[ai_gateway_update_params.Stripe] | Omit = omit, + workers_ai_billing_mode: Literal["postpaid", "unified"] | Omit = omit, zdr: bool | Omit = omit, # 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. @@ -572,11 +578,13 @@ async def update( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AIGatewayUpdateResponse: """ - Update a Gateway + Updates an existing AI Gateway dataset. Args: id: gateway id + workers_ai_billing_mode: Controls how Workers AI inference calls routed through this gateway are billed + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -601,7 +609,6 @@ async def update( "rate_limiting_technique": rate_limiting_technique, "authentication": authentication, "dlp": dlp, - "is_default": is_default, "log_management": log_management, "log_management_strategy": log_management_strategy, "logpush": logpush, @@ -609,6 +616,7 @@ async def update( "otel": otel, "store_id": store_id, "stripe": stripe, + "workers_ai_billing_mode": workers_ai_billing_mode, "zdr": zdr, }, ai_gateway_update_params.AIGatewayUpdateParams, @@ -638,7 +646,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[AIGatewayListResponse, AsyncV4PagePaginationArray[AIGatewayListResponse]]: """ - List Gateways + Lists all AI Gateway evaluator types configured for the account. Args: search: Search by id @@ -686,7 +694,7 @@ async def delete( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AIGatewayDeleteResponse: """ - Delete a Gateway + Deletes an AI Gateway dataset. Args: id: gateway id @@ -728,7 +736,7 @@ async def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AIGatewayGetResponse: """ - Fetch a Gateway + Retrieves details for a specific AI Gateway dataset. Args: id: gateway id diff --git a/src/cloudflare/resources/ai_gateway/datasets.py b/src/cloudflare/resources/ai_gateway/datasets.py index bb256a33205..91601b7a385 100644 --- a/src/cloudflare/resources/ai_gateway/datasets.py +++ b/src/cloudflare/resources/ai_gateway/datasets.py @@ -65,7 +65,7 @@ def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> DatasetCreateResponse: """ - Create a new Dataset + Creates a new AI Gateway. Args: gateway_id: gateway id @@ -119,7 +119,7 @@ def update( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> DatasetUpdateResponse: """ - Update a Dataset + Updates an existing AI Gateway dataset. Args: gateway_id: gateway id @@ -176,7 +176,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncV4PagePaginationArray[DatasetListResponse]: """ - List Datasets + Lists all AI Gateway evaluator types configured for the account. Args: gateway_id: gateway id @@ -231,7 +231,7 @@ def delete( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> DatasetDeleteResponse: """ - Delete a Dataset + Deletes an AI Gateway dataset. Args: gateway_id: gateway id @@ -276,7 +276,7 @@ def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> DatasetGetResponse: """ - Fetch a Dataset + Retrieves details for a specific AI Gateway dataset. Args: gateway_id: gateway id @@ -344,7 +344,7 @@ async def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> DatasetCreateResponse: """ - Create a new Dataset + Creates a new AI Gateway. Args: gateway_id: gateway id @@ -398,7 +398,7 @@ async def update( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> DatasetUpdateResponse: """ - Update a Dataset + Updates an existing AI Gateway dataset. Args: gateway_id: gateway id @@ -455,7 +455,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[DatasetListResponse, AsyncV4PagePaginationArray[DatasetListResponse]]: """ - List Datasets + Lists all AI Gateway evaluator types configured for the account. Args: gateway_id: gateway id @@ -510,7 +510,7 @@ async def delete( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> DatasetDeleteResponse: """ - Delete a Dataset + Deletes an AI Gateway dataset. Args: gateway_id: gateway id @@ -555,7 +555,7 @@ async def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> DatasetGetResponse: """ - Fetch a Dataset + Retrieves details for a specific AI Gateway dataset. Args: gateway_id: gateway id diff --git a/src/cloudflare/resources/ai_gateway/evaluations.py b/src/cloudflare/resources/ai_gateway/evaluations.py index e3d9fd87309..b466e084495 100644 --- a/src/cloudflare/resources/ai_gateway/evaluations.py +++ b/src/cloudflare/resources/ai_gateway/evaluations.py @@ -64,7 +64,7 @@ def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> EvaluationCreateResponse: """ - Create a new Evaluation + Creates a new AI Gateway. Args: gateway_id: gateway id @@ -119,7 +119,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncV4PagePaginationArray[EvaluationListResponse]: """ - List Evaluations + Lists all AI Gateway evaluator types configured for the account. Args: gateway_id: gateway id @@ -174,7 +174,7 @@ def delete( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> EvaluationDeleteResponse: """ - Delete a Evaluation + Deletes an AI Gateway dataset. Args: gateway_id: gateway id @@ -219,7 +219,7 @@ def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> EvaluationGetResponse: """ - Fetch a Evaluation + Retrieves details for a specific AI Gateway dataset. Args: gateway_id: gateway id @@ -287,7 +287,7 @@ async def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> EvaluationCreateResponse: """ - Create a new Evaluation + Creates a new AI Gateway. Args: gateway_id: gateway id @@ -342,7 +342,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[EvaluationListResponse, AsyncV4PagePaginationArray[EvaluationListResponse]]: """ - List Evaluations + Lists all AI Gateway evaluator types configured for the account. Args: gateway_id: gateway id @@ -397,7 +397,7 @@ async def delete( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> EvaluationDeleteResponse: """ - Delete a Evaluation + Deletes an AI Gateway dataset. Args: gateway_id: gateway id @@ -442,7 +442,7 @@ async def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> EvaluationGetResponse: """ - Fetch a Evaluation + Retrieves details for a specific AI Gateway dataset. Args: gateway_id: gateway id diff --git a/src/cloudflare/resources/ai_gateway/logs.py b/src/cloudflare/resources/ai_gateway/logs.py index 8518d36781c..0ea6559c96b 100644 --- a/src/cloudflare/resources/ai_gateway/logs.py +++ b/src/cloudflare/resources/ai_gateway/logs.py @@ -236,7 +236,7 @@ def edit( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> object: """ - Patch Gateway Log + Updates metadata for an AI Gateway log entry. Args: gateway_id: gateway id @@ -289,7 +289,7 @@ def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> LogGetResponse: """ - Get Gateway Log Detail + Retrieves detailed information for a specific AI Gateway log entry. Args: gateway_id: gateway id @@ -334,7 +334,7 @@ def request( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> object: """ - Get Gateway Log Request + Retrieves the original request payload for an AI Gateway log entry. Args: gateway_id: gateway id @@ -375,7 +375,7 @@ def response( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> object: """ - Get Gateway Log Response + Retrieves the response payload for an AI Gateway log entry. Args: gateway_id: gateway id @@ -610,7 +610,7 @@ async def edit( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> object: """ - Patch Gateway Log + Updates metadata for an AI Gateway log entry. Args: gateway_id: gateway id @@ -663,7 +663,7 @@ async def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> LogGetResponse: """ - Get Gateway Log Detail + Retrieves detailed information for a specific AI Gateway log entry. Args: gateway_id: gateway id @@ -708,7 +708,7 @@ async def request( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> object: """ - Get Gateway Log Request + Retrieves the original request payload for an AI Gateway log entry. Args: gateway_id: gateway id @@ -749,7 +749,7 @@ async def response( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> object: """ - Get Gateway Log Response + Retrieves the response payload for an AI Gateway log entry. Args: gateway_id: gateway id diff --git a/src/cloudflare/resources/ai_gateway/provider_configs.py b/src/cloudflare/resources/ai_gateway/provider_configs.py index 60c7fc5f891..2e75c14bdc3 100644 --- a/src/cloudflare/resources/ai_gateway/provider_configs.py +++ b/src/cloudflare/resources/ai_gateway/provider_configs.py @@ -66,7 +66,7 @@ def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> ProviderConfigCreateResponse: """ - Create a new Provider Configs + Creates a new AI Gateway. Args: gateway_id: gateway id @@ -122,7 +122,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncV4PagePaginationArray[ProviderConfigListResponse]: """ - List Provider Configs + Lists all AI Gateway evaluator types configured for the account. Args: gateway_id: gateway id @@ -199,7 +199,7 @@ async def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> ProviderConfigCreateResponse: """ - Create a new Provider Configs + Creates a new AI Gateway. Args: gateway_id: gateway id @@ -255,7 +255,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[ProviderConfigListResponse, AsyncV4PagePaginationArray[ProviderConfigListResponse]]: """ - List Provider Configs + Lists all AI Gateway evaluator types configured for the account. Args: gateway_id: gateway id diff --git a/src/cloudflare/resources/ai_gateway/urls.py b/src/cloudflare/resources/ai_gateway/urls.py index 8f660faa164..988e21ecc24 100644 --- a/src/cloudflare/resources/ai_gateway/urls.py +++ b/src/cloudflare/resources/ai_gateway/urls.py @@ -56,7 +56,7 @@ def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> str: """ - Get Gateway URL + Retrieves the endpoint URL for an AI Gateway. Args: gateway_id: gateway id @@ -122,7 +122,7 @@ async def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> str: """ - Get Gateway URL + Retrieves the endpoint URL for an AI Gateway. Args: gateway_id: gateway id diff --git a/src/cloudflare/resources/aisearch/instances/instances.py b/src/cloudflare/resources/aisearch/instances/instances.py index 256d55b0ba3..a6eb75d2b48 100644 --- a/src/cloudflare/resources/aisearch/instances/instances.py +++ b/src/cloudflare/resources/aisearch/instances/instances.py @@ -88,8 +88,6 @@ def create( *, account_id: str, id: str, - source: str, - type: Literal["r2", "web-crawler"], ai_gateway_id: Optional[str] | Omit = omit, aisearch_model: Literal[ "@cf/meta/llama-3.3-70b-instruct-fp8-fast", @@ -122,6 +120,9 @@ def create( "", ] | Omit = omit, + cache: bool | Omit = omit, + cache_threshold: Literal["super_strict_match", "close_enough", "flexible_friend", "anything_goes"] + | Omit = omit, chunk: bool | Omit = omit, chunk_overlap: int | Omit = omit, chunk_size: int | Omit = omit, @@ -178,8 +179,10 @@ def create( | Omit = omit, rewrite_query: bool | Omit = omit, score_threshold: float | Omit = omit, + source: str | Omit = omit, source_params: Optional[instance_create_params.SourceParams] | Omit = omit, token_id: str | Omit = omit, + type: Literal["r2", "web-crawler"] | Omit = omit, # 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, @@ -208,10 +211,10 @@ def create( body=maybe_transform( { "id": id, - "source": source, - "type": type, "ai_gateway_id": ai_gateway_id, "aisearch_model": aisearch_model, + "cache": cache, + "cache_threshold": cache_threshold, "chunk": chunk, "chunk_overlap": chunk_overlap, "chunk_size": chunk_size, @@ -228,8 +231,10 @@ def create( "rewrite_model": rewrite_model, "rewrite_query": rewrite_query, "score_threshold": score_threshold, + "source": source, "source_params": source_params, "token_id": token_id, + "type": type, }, instance_create_params.InstanceCreateParams, ), @@ -451,6 +456,8 @@ def list( self, *, account_id: str, + order_by: Literal["created_at"] | Omit = omit, + order_by_direction: Literal["asc", "desc"] | Omit = omit, page: int | Omit = omit, per_page: int | Omit = omit, search: str | Omit = omit, @@ -465,6 +472,10 @@ def list( List instances. Args: + order_by: Order By Column Name + + order_by_direction: Order By Direction + search: Search by id extra_headers: Send extra headers @@ -487,6 +498,8 @@ def list( timeout=timeout, query=maybe_transform( { + "order_by": order_by, + "order_by_direction": order_by_direction, "page": page, "per_page": per_page, "search": search, @@ -791,8 +804,6 @@ async def create( *, account_id: str, id: str, - source: str, - type: Literal["r2", "web-crawler"], ai_gateway_id: Optional[str] | Omit = omit, aisearch_model: Literal[ "@cf/meta/llama-3.3-70b-instruct-fp8-fast", @@ -825,6 +836,9 @@ async def create( "", ] | Omit = omit, + cache: bool | Omit = omit, + cache_threshold: Literal["super_strict_match", "close_enough", "flexible_friend", "anything_goes"] + | Omit = omit, chunk: bool | Omit = omit, chunk_overlap: int | Omit = omit, chunk_size: int | Omit = omit, @@ -881,8 +895,10 @@ async def create( | Omit = omit, rewrite_query: bool | Omit = omit, score_threshold: float | Omit = omit, + source: str | Omit = omit, source_params: Optional[instance_create_params.SourceParams] | Omit = omit, token_id: str | Omit = omit, + type: Literal["r2", "web-crawler"] | Omit = omit, # 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, @@ -911,10 +927,10 @@ async def create( body=await async_maybe_transform( { "id": id, - "source": source, - "type": type, "ai_gateway_id": ai_gateway_id, "aisearch_model": aisearch_model, + "cache": cache, + "cache_threshold": cache_threshold, "chunk": chunk, "chunk_overlap": chunk_overlap, "chunk_size": chunk_size, @@ -931,8 +947,10 @@ async def create( "rewrite_model": rewrite_model, "rewrite_query": rewrite_query, "score_threshold": score_threshold, + "source": source, "source_params": source_params, "token_id": token_id, + "type": type, }, instance_create_params.InstanceCreateParams, ), @@ -1154,6 +1172,8 @@ def list( self, *, account_id: str, + order_by: Literal["created_at"] | Omit = omit, + order_by_direction: Literal["asc", "desc"] | Omit = omit, page: int | Omit = omit, per_page: int | Omit = omit, search: str | Omit = omit, @@ -1168,6 +1188,10 @@ def list( List instances. Args: + order_by: Order By Column Name + + order_by_direction: Order By Direction + search: Search by id extra_headers: Send extra headers @@ -1190,6 +1214,8 @@ def list( timeout=timeout, query=maybe_transform( { + "order_by": order_by, + "order_by_direction": order_by_direction, "page": page, "per_page": per_page, "search": search, diff --git a/src/cloudflare/resources/aisearch/instances/items.py b/src/cloudflare/resources/aisearch/instances/items.py index eaa492c2593..52f24c2ecec 100644 --- a/src/cloudflare/resources/aisearch/instances/items.py +++ b/src/cloudflare/resources/aisearch/instances/items.py @@ -2,7 +2,6 @@ from __future__ import annotations -from typing import Type, cast from typing_extensions import Literal import httpx @@ -17,11 +16,9 @@ async_to_raw_response_wrapper, async_to_streamed_response_wrapper, ) -from ...._wrappers import ResultWrapper from ....pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray from ...._base_client import AsyncPaginator, make_request_options from ....types.aisearch.instances import item_list_params -from ....types.aisearch.instances.item_get_response import ItemGetResponse from ....types.aisearch.instances.item_list_response import ItemListResponse __all__ = ["ItemsResource", "AsyncItemsResource"] @@ -102,51 +99,6 @@ def list( model=ItemListResponse, ) - def get( - self, - item_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, - ) -> ItemGetResponse: - """ - Retrieves a specific indexed item from an AI Search instance. - - Args: - id: Use your AI Search 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 item_id: - raise ValueError(f"Expected a non-empty value for `item_id` but received {item_id!r}") - return self._get( - f"/accounts/{account_id}/ai-search/instances/{id}/items/{item_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[ItemGetResponse]._unwrapper, - ), - cast_to=cast(Type[ItemGetResponse], ResultWrapper[ItemGetResponse]), - ) - class AsyncItemsResource(AsyncAPIResource): @cached_property @@ -223,51 +175,6 @@ def list( model=ItemListResponse, ) - async def get( - self, - item_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, - ) -> ItemGetResponse: - """ - Retrieves a specific indexed item from an AI Search instance. - - Args: - id: Use your AI Search 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 item_id: - raise ValueError(f"Expected a non-empty value for `item_id` but received {item_id!r}") - return await self._get( - f"/accounts/{account_id}/ai-search/instances/{id}/items/{item_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[ItemGetResponse]._unwrapper, - ), - cast_to=cast(Type[ItemGetResponse], ResultWrapper[ItemGetResponse]), - ) - class ItemsResourceWithRawResponse: def __init__(self, items: ItemsResource) -> None: @@ -276,9 +183,6 @@ def __init__(self, items: ItemsResource) -> None: self.list = to_raw_response_wrapper( items.list, ) - self.get = to_raw_response_wrapper( - items.get, - ) class AsyncItemsResourceWithRawResponse: @@ -288,9 +192,6 @@ def __init__(self, items: AsyncItemsResource) -> None: self.list = async_to_raw_response_wrapper( items.list, ) - self.get = async_to_raw_response_wrapper( - items.get, - ) class ItemsResourceWithStreamingResponse: @@ -300,9 +201,6 @@ def __init__(self, items: ItemsResource) -> None: self.list = to_streamed_response_wrapper( items.list, ) - self.get = to_streamed_response_wrapper( - items.get, - ) class AsyncItemsResourceWithStreamingResponse: @@ -312,6 +210,3 @@ def __init__(self, items: AsyncItemsResource) -> None: self.list = async_to_streamed_response_wrapper( items.list, ) - self.get = async_to_streamed_response_wrapper( - items.get, - ) diff --git a/src/cloudflare/resources/aisearch/instances/jobs.py b/src/cloudflare/resources/aisearch/instances/jobs.py index d5c03bf6e7a..24ef439a64c 100644 --- a/src/cloudflare/resources/aisearch/instances/jobs.py +++ b/src/cloudflare/resources/aisearch/instances/jobs.py @@ -19,7 +19,7 @@ from ...._wrappers import ResultWrapper from ....pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray from ...._base_client import AsyncPaginator, make_request_options -from ....types.aisearch.instances import job_list_params, job_logs_params +from ....types.aisearch.instances import job_list_params, job_logs_params, job_create_params from ....types.aisearch.instances.job_get_response import JobGetResponse from ....types.aisearch.instances.job_list_response import JobListResponse from ....types.aisearch.instances.job_logs_response import JobLogsResponse @@ -53,6 +53,7 @@ def create( id: str, *, account_id: str, + description: str | Omit = omit, # 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, @@ -80,6 +81,7 @@ def create( raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") return self._post( f"/accounts/{account_id}/ai-search/instances/{id}/jobs", + body=maybe_transform({"description": description}, job_create_params.JobCreateParams), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -266,6 +268,7 @@ async def create( id: str, *, account_id: str, + description: str | Omit = omit, # 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, @@ -293,6 +296,7 @@ async def create( raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") return await self._post( f"/accounts/{account_id}/ai-search/instances/{id}/jobs", + body=await async_maybe_transform({"description": description}, job_create_params.JobCreateParams), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/cloudflare/resources/aisearch/tokens.py b/src/cloudflare/resources/aisearch/tokens.py index 8916dfecec0..94654a58c85 100644 --- a/src/cloudflare/resources/aisearch/tokens.py +++ b/src/cloudflare/resources/aisearch/tokens.py @@ -3,6 +3,7 @@ from __future__ import annotations from typing import Type, cast +from typing_extensions import Literal import httpx @@ -152,6 +153,8 @@ def list( self, *, account_id: str, + order_by: Literal["created_at"] | Omit = omit, + order_by_direction: Literal["asc", "desc"] | Omit = omit, page: int | Omit = omit, per_page: int | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -165,6 +168,10 @@ def list( List tokens. Args: + order_by: Order By Column Name + + order_by_direction: Order By Direction + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -185,6 +192,8 @@ def list( timeout=timeout, query=maybe_transform( { + "order_by": order_by, + "order_by_direction": order_by_direction, "page": page, "per_page": per_page, }, @@ -398,6 +407,8 @@ def list( self, *, account_id: str, + order_by: Literal["created_at"] | Omit = omit, + order_by_direction: Literal["asc", "desc"] | Omit = omit, page: int | Omit = omit, per_page: int | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -411,6 +422,10 @@ def list( List tokens. Args: + order_by: Order By Column Name + + order_by_direction: Order By Direction + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -431,6 +446,8 @@ def list( timeout=timeout, query=maybe_transform( { + "order_by": order_by, + "order_by_direction": order_by_direction, "page": page, "per_page": per_page, }, diff --git a/src/cloudflare/resources/api_gateway/configurations.py b/src/cloudflare/resources/api_gateway/configurations.py index 96cebe13223..bd62e5e568b 100644 --- a/src/cloudflare/resources/api_gateway/configurations.py +++ b/src/cloudflare/resources/api_gateway/configurations.py @@ -57,8 +57,10 @@ def update( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Configuration: - """ - Update configuration properties + """Updates API Shield configuration settings for a zone. + + Can modify validation + strictness, enforcement mode, and other global settings. Args: zone_id: Identifier. @@ -105,7 +107,8 @@ def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Configuration: """ - Retrieve information about specific configuration properties + Gets the current API Shield configuration settings for a zone, including + validation behavior and enforcement mode. Args: zone_id: Identifier. @@ -169,8 +172,10 @@ async def update( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Configuration: - """ - Update configuration properties + """Updates API Shield configuration settings for a zone. + + Can modify validation + strictness, enforcement mode, and other global settings. Args: zone_id: Identifier. @@ -219,7 +224,8 @@ async def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> Configuration: """ - Retrieve information about specific configuration properties + Gets the current API Shield configuration settings for a zone, including + validation behavior and enforcement mode. Args: zone_id: Identifier. diff --git a/src/cloudflare/resources/api_gateway/expression_template/fallthrough.py b/src/cloudflare/resources/api_gateway/expression_template/fallthrough.py index 1434470cfad..8f4d2735cd0 100644 --- a/src/cloudflare/resources/api_gateway/expression_template/fallthrough.py +++ b/src/cloudflare/resources/api_gateway/expression_template/fallthrough.py @@ -56,8 +56,10 @@ def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> FallthroughCreateResponse: - """ - Generate fallthrough WAF expression template from a set of API hosts + """Creates an expression template fallthrough rule for API Shield. + + Used for + configuring default behavior when no other expression templates match. Args: zone_id: Identifier. @@ -120,8 +122,10 @@ async def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> FallthroughCreateResponse: - """ - Generate fallthrough WAF expression template from a set of API hosts + """Creates an expression template fallthrough rule for API Shield. + + Used for + configuring default behavior when no other expression templates match. Args: zone_id: Identifier. diff --git a/src/cloudflare/resources/api_gateway/operations/operations.py b/src/cloudflare/resources/api_gateway/operations/operations.py index 1a6038c3688..f69385e3dd9 100644 --- a/src/cloudflare/resources/api_gateway/operations/operations.py +++ b/src/cloudflare/resources/api_gateway/operations/operations.py @@ -152,7 +152,8 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncV4PagePaginationArray[OperationListResponse]: """ - Retrieve information about all operations on a zone + Lists all API operations tracked by API Shield for a zone with pagination. + Returns operation details including method, path, and feature configurations. Args: zone_id: Identifier. @@ -223,8 +224,10 @@ def delete( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> OperationDeleteResponse: - """ - Delete an operation + """Removes a single API operation from API Shield endpoint management. + + The + operation will no longer be tracked or protected by API Shield rules. Args: zone_id: Identifier. @@ -307,7 +310,8 @@ def bulk_delete( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> OperationBulkDeleteResponse: """ - Delete multiple operations + Bulk removes multiple API operations from API Shield endpoint management in a + single request. Efficient for cleaning up unused endpoints. Args: zone_id: Identifier. @@ -344,7 +348,8 @@ def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> OperationGetResponse: """ - Retrieve information about an operation + Gets detailed information about a specific API operation in API Shield, + including its schema validation settings and traffic statistics. Args: zone_id: Identifier. @@ -489,7 +494,8 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[OperationListResponse, AsyncV4PagePaginationArray[OperationListResponse]]: """ - Retrieve information about all operations on a zone + Lists all API operations tracked by API Shield for a zone with pagination. + Returns operation details including method, path, and feature configurations. Args: zone_id: Identifier. @@ -560,8 +566,10 @@ async def delete( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> OperationDeleteResponse: - """ - Delete an operation + """Removes a single API operation from API Shield endpoint management. + + The + operation will no longer be tracked or protected by API Shield rules. Args: zone_id: Identifier. @@ -644,7 +652,8 @@ async def bulk_delete( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> OperationBulkDeleteResponse: """ - Delete multiple operations + Bulk removes multiple API operations from API Shield endpoint management in a + single request. Efficient for cleaning up unused endpoints. Args: zone_id: Identifier. @@ -681,7 +690,8 @@ async def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> OperationGetResponse: """ - Retrieve information about an operation + Gets detailed information about a specific API operation in API Shield, + including its schema validation settings and traffic statistics. Args: zone_id: Identifier. diff --git a/src/cloudflare/resources/api_gateway/user_schemas/hosts.py b/src/cloudflare/resources/api_gateway/user_schemas/hosts.py index 01861b64473..d193678ec7d 100644 --- a/src/cloudflare/resources/api_gateway/user_schemas/hosts.py +++ b/src/cloudflare/resources/api_gateway/user_schemas/hosts.py @@ -60,8 +60,10 @@ def list( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncV4PagePaginationArray[HostListResponse]: - """ - Retrieve schema hosts in a zone + """Lists all unique hosts found in uploaded OpenAPI schemas for the zone. + + Useful + for understanding which domains have schema coverage. Args: zone_id: Identifier. @@ -136,8 +138,10 @@ def list( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[HostListResponse, AsyncV4PagePaginationArray[HostListResponse]]: - """ - Retrieve schema hosts in a zone + """Lists all unique hosts found in uploaded OpenAPI schemas for the zone. + + Useful + for understanding which domains have schema coverage. Args: zone_id: Identifier. diff --git a/src/cloudflare/resources/api_gateway/user_schemas/user_schemas.py b/src/cloudflare/resources/api_gateway/user_schemas/user_schemas.py index e7d9626a705..346db5396d5 100644 --- a/src/cloudflare/resources/api_gateway/user_schemas/user_schemas.py +++ b/src/cloudflare/resources/api_gateway/user_schemas/user_schemas.py @@ -166,7 +166,8 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncV4PagePaginationArray[OldPublicSchema]: """ - Retrieve information about all schemas on a zone + Lists all OpenAPI schemas uploaded to API Shield for the zone, including their + validation status and associated operations. Args: zone_id: Identifier. @@ -225,8 +226,10 @@ def delete( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> UserSchemaDeleteResponse: - """ - Delete a schema + """Permanently removes an uploaded OpenAPI schema from API Shield schema + validation. + + Operations using this schema will lose their validation rules. Args: zone_id: Identifier. @@ -267,8 +270,10 @@ def edit( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> OldPublicSchema: - """ - Enable validation for a schema + """Activates schema validation for an uploaded OpenAPI schema. + + Requests to matching + endpoints will be validated against the schema definitions. Args: zone_id: Identifier. @@ -319,7 +324,8 @@ def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> OldPublicSchema: """ - Retrieve information about a specific schema on a zone + Gets detailed information about a specific uploaded OpenAPI schema, including + its contents and validation configuration. Args: zone_id: Identifier. @@ -468,7 +474,8 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[OldPublicSchema, AsyncV4PagePaginationArray[OldPublicSchema]]: """ - Retrieve information about all schemas on a zone + Lists all OpenAPI schemas uploaded to API Shield for the zone, including their + validation status and associated operations. Args: zone_id: Identifier. @@ -527,8 +534,10 @@ async def delete( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> UserSchemaDeleteResponse: - """ - Delete a schema + """Permanently removes an uploaded OpenAPI schema from API Shield schema + validation. + + Operations using this schema will lose their validation rules. Args: zone_id: Identifier. @@ -569,8 +578,10 @@ async def edit( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> OldPublicSchema: - """ - Enable validation for a schema + """Activates schema validation for an uploaded OpenAPI schema. + + Requests to matching + endpoints will be validated against the schema definitions. Args: zone_id: Identifier. @@ -621,7 +632,8 @@ async def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> OldPublicSchema: """ - Retrieve information about a specific schema on a zone + Gets detailed information about a specific uploaded OpenAPI schema, including + its contents and validation configuration. Args: zone_id: Identifier. diff --git a/src/cloudflare/resources/cloudforce_one/threat_events/datasets/datasets.py b/src/cloudflare/resources/cloudforce_one/threat_events/datasets/datasets.py index 6a430786bc9..6fb96b5cba8 100644 --- a/src/cloudflare/resources/cloudforce_one/threat_events/datasets/datasets.py +++ b/src/cloudflare/resources/cloudforce_one/threat_events/datasets/datasets.py @@ -236,8 +236,10 @@ def raw( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> DatasetRawResponse: - """ - Reads data for a raw event + """Retrieves the raw data associated with an event. + + Searches across all shards in + the dataset. Args: account_id: Account ID. @@ -480,8 +482,10 @@ async def raw( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> DatasetRawResponse: - """ - Reads data for a raw event + """Retrieves the raw data associated with an event. + + Searches across all shards in + the dataset. Args: account_id: Account ID. diff --git a/src/cloudflare/resources/email_security/investigate/investigate.py b/src/cloudflare/resources/email_security/investigate/investigate.py index 819279a8b67..d8057b8d8f3 100644 --- a/src/cloudflare/resources/email_security/investigate/investigate.py +++ b/src/cloudflare/resources/email_security/investigate/investigate.py @@ -142,6 +142,7 @@ def list( detections_only: bool | Omit = omit, domain: str | Omit = omit, end: Union[str, datetime] | Omit = omit, + exact_subject: str | Omit = omit, final_disposition: Literal["MALICIOUS", "SUSPICIOUS", "SPOOF", "SPAM", "BULK", "NONE"] | Omit = omit, message_action: Literal["PREVIEW", "QUARANTINE_RELEASED", "MOVED"] | Omit = omit, message_id: str | Omit = omit, @@ -173,10 +174,13 @@ def list( detections_only: Determines if the search results will include detections or not. - domain: The sender domains the search filters by. + domain: Filter by a domain found in the email: sender domain, recipient domain, or a + domain in a link. end: The end of the search date range. Defaults to `now` if not provided. + exact_subject: Search for messages with an exact subject match. + final_disposition: The dispositions the search filters by. message_action: The message actions the search filters by. @@ -210,9 +214,16 @@ def list( - x_originating_ip - Subject + recipient: Filter by recipient. Matches either an email address or a domain. + + sender: Filter by sender. Matches either an email address or a domain. + start: The beginning of the search date range. Defaults to `now - 30 days` if not provided. + subject: Search for messages containing individual keywords in any order within the + subject. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -239,6 +250,7 @@ def list( "detections_only": detections_only, "domain": domain, "end": end, + "exact_subject": exact_subject, "final_disposition": final_disposition, "message_action": message_action, "message_id": message_id, @@ -270,7 +282,8 @@ def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> InvestigateGetResponse: """ - Get message details + Retrieves detailed information about a specific email message, including + headers, metadata, and security scan results. Args: account_id: Account Identifier @@ -360,6 +373,7 @@ def list( detections_only: bool | Omit = omit, domain: str | Omit = omit, end: Union[str, datetime] | Omit = omit, + exact_subject: str | Omit = omit, final_disposition: Literal["MALICIOUS", "SUSPICIOUS", "SPOOF", "SPAM", "BULK", "NONE"] | Omit = omit, message_action: Literal["PREVIEW", "QUARANTINE_RELEASED", "MOVED"] | Omit = omit, message_id: str | Omit = omit, @@ -391,10 +405,13 @@ def list( detections_only: Determines if the search results will include detections or not. - domain: The sender domains the search filters by. + domain: Filter by a domain found in the email: sender domain, recipient domain, or a + domain in a link. end: The end of the search date range. Defaults to `now` if not provided. + exact_subject: Search for messages with an exact subject match. + final_disposition: The dispositions the search filters by. message_action: The message actions the search filters by. @@ -428,9 +445,16 @@ def list( - x_originating_ip - Subject + recipient: Filter by recipient. Matches either an email address or a domain. + + sender: Filter by sender. Matches either an email address or a domain. + start: The beginning of the search date range. Defaults to `now - 30 days` if not provided. + subject: Search for messages containing individual keywords in any order within the + subject. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -457,6 +481,7 @@ def list( "detections_only": detections_only, "domain": domain, "end": end, + "exact_subject": exact_subject, "final_disposition": final_disposition, "message_action": message_action, "message_id": message_id, @@ -488,7 +513,8 @@ async def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> InvestigateGetResponse: """ - Get message details + Retrieves detailed information about a specific email message, including + headers, metadata, and security scan results. Args: account_id: Account Identifier diff --git a/src/cloudflare/resources/email_security/investigate/move.py b/src/cloudflare/resources/email_security/investigate/move.py index f4a2267332a..1ca1bfc4536 100644 --- a/src/cloudflare/resources/email_security/investigate/move.py +++ b/src/cloudflare/resources/email_security/investigate/move.py @@ -61,7 +61,8 @@ def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncSinglePage[MoveCreateResponse]: """ - Move a message + Moves a single email message to a different folder or changes its quarantine + status. Args: account_id: Account Identifier @@ -182,7 +183,8 @@ def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[MoveCreateResponse, AsyncSinglePage[MoveCreateResponse]]: """ - Move a message + Moves a single email message to a different folder or changes its quarantine + status. Args: account_id: Account Identifier diff --git a/src/cloudflare/resources/email_security/investigate/preview.py b/src/cloudflare/resources/email_security/investigate/preview.py index eb256fad862..9c11c012ad6 100644 --- a/src/cloudflare/resources/email_security/investigate/preview.py +++ b/src/cloudflare/resources/email_security/investigate/preview.py @@ -58,7 +58,8 @@ def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> PreviewCreateResponse: """ - Preview for non-detection messages + Generates a preview of an email message for safe viewing without executing any + embedded content. Args: account_id: Account Identifier @@ -167,7 +168,8 @@ async def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> PreviewCreateResponse: """ - Preview for non-detection messages + Generates a preview of an email message for safe viewing without executing any + embedded content. Args: account_id: Account Identifier diff --git a/src/cloudflare/resources/email_security/investigate/reclassify.py b/src/cloudflare/resources/email_security/investigate/reclassify.py index 61efd16b622..479bece1b7f 100644 --- a/src/cloudflare/resources/email_security/investigate/reclassify.py +++ b/src/cloudflare/resources/email_security/investigate/reclassify.py @@ -60,7 +60,8 @@ def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> object: """ - Change email classfication + Submits an email message for reclassification, updating its threat assessment + based on new analysis. Args: account_id: Account Identifier @@ -138,7 +139,8 @@ async def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> object: """ - Change email classfication + Submits an email message for reclassification, updating its threat assessment + based on new analysis. Args: account_id: Account Identifier diff --git a/src/cloudflare/resources/email_security/investigate/release.py b/src/cloudflare/resources/email_security/investigate/release.py index 12789ed5119..1fe506c920d 100644 --- a/src/cloudflare/resources/email_security/investigate/release.py +++ b/src/cloudflare/resources/email_security/investigate/release.py @@ -54,7 +54,8 @@ def bulk( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncSinglePage[ReleaseBulkResponse]: """ - Release messages from quarantine + Releases a quarantined email message, allowing it to be delivered to the + recipient. Args: account_id: Account Identifier @@ -116,7 +117,8 @@ def bulk( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[ReleaseBulkResponse, AsyncSinglePage[ReleaseBulkResponse]]: """ - Release messages from quarantine + Releases a quarantined email message, allowing it to be delivered to the + recipient. Args: account_id: Account Identifier diff --git a/src/cloudflare/resources/email_security/investigate/trace.py b/src/cloudflare/resources/email_security/investigate/trace.py index 6ca1601d587..8bfb16d9696 100644 --- a/src/cloudflare/resources/email_security/investigate/trace.py +++ b/src/cloudflare/resources/email_security/investigate/trace.py @@ -55,7 +55,8 @@ def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> TraceGetResponse: """ - Get email trace + Gets the delivery trace for an email message, showing its path through email + security processing. Args: account_id: Account Identifier @@ -120,7 +121,8 @@ async def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> TraceGetResponse: """ - Get email trace + Gets the delivery trace for an email message, showing its path through email + security processing. Args: account_id: Account Identifier diff --git a/src/cloudflare/resources/email_security/phishguard/reports.py b/src/cloudflare/resources/email_security/phishguard/reports.py index 880fe8397f2..14e10e977f3 100644 --- a/src/cloudflare/resources/email_security/phishguard/reports.py +++ b/src/cloudflare/resources/email_security/phishguard/reports.py @@ -61,7 +61,8 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncSinglePage[ReportListResponse]: """ - Get `PhishGuard` reports + Retrieves `PhishGuard` reports showing phishing attempts and suspicious email + patterns detected. Args: account_id: Account Identifier @@ -138,7 +139,8 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[ReportListResponse, AsyncSinglePage[ReportListResponse]]: """ - Get `PhishGuard` reports + Retrieves `PhishGuard` reports showing phishing attempts and suspicious email + patterns detected. Args: account_id: Account Identifier diff --git a/src/cloudflare/resources/email_security/settings/allow_policies.py b/src/cloudflare/resources/email_security/settings/allow_policies.py index a2b0da56230..05d886a4b0f 100644 --- a/src/cloudflare/resources/email_security/settings/allow_policies.py +++ b/src/cloudflare/resources/email_security/settings/allow_policies.py @@ -77,7 +77,8 @@ def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AllowPolicyCreateResponse: """ - Create an email allow policy + Creates a new email allow policy that permits specific senders, domains, or + patterns to bypass security scanning. Args: account_id: Account Identifier @@ -227,8 +228,10 @@ def delete( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AllowPolicyDeleteResponse: - """ - Delete an email allow policy + """Removes an email allow policy. + + Previously allowed senders will be subject to + normal security scanning. Args: account_id: Account Identifier @@ -278,7 +281,8 @@ def edit( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AllowPolicyEditResponse: """ - Update an email allow policy + Updates an existing email allow policy, modifying its matching criteria or + scope. Args: account_id: Account Identifier @@ -344,7 +348,8 @@ def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AllowPolicyGetResponse: """ - Get an email allow policy + Retrieves details for a specific email allow policy, including its matching + criteria and scope. Args: account_id: Account Identifier @@ -417,7 +422,8 @@ async def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AllowPolicyCreateResponse: """ - Create an email allow policy + Creates a new email allow policy that permits specific senders, domains, or + patterns to bypass security scanning. Args: account_id: Account Identifier @@ -567,8 +573,10 @@ async def delete( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AllowPolicyDeleteResponse: - """ - Delete an email allow policy + """Removes an email allow policy. + + Previously allowed senders will be subject to + normal security scanning. Args: account_id: Account Identifier @@ -618,7 +626,8 @@ async def edit( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AllowPolicyEditResponse: """ - Update an email allow policy + Updates an existing email allow policy, modifying its matching criteria or + scope. Args: account_id: Account Identifier @@ -684,7 +693,8 @@ async def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AllowPolicyGetResponse: """ - Get an email allow policy + Retrieves details for a specific email allow policy, including its matching + criteria and scope. Args: account_id: Account Identifier diff --git a/src/cloudflare/resources/email_security/settings/block_senders.py b/src/cloudflare/resources/email_security/settings/block_senders.py index 350053cb5b4..c4f72b56dc6 100644 --- a/src/cloudflare/resources/email_security/settings/block_senders.py +++ b/src/cloudflare/resources/email_security/settings/block_senders.py @@ -70,7 +70,8 @@ def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> BlockSenderCreateResponse: """ - Create a blocked email sender + Adds a sender pattern to the email block list, preventing messages from matching + senders from being delivered. Args: account_id: Account Identifier @@ -125,7 +126,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncV4PagePaginationArray[BlockSenderListResponse]: """ - List blocked email senders + Lists all blocked sender entries with their patterns and block reasons. Args: account_id: Account Identifier @@ -189,7 +190,8 @@ def delete( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> BlockSenderDeleteResponse: """ - Delete a blocked email sender + Removes a sender from the email block list, allowing their messages to be + delivered normally. Args: account_id: Account Identifier @@ -235,7 +237,7 @@ def edit( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> BlockSenderEditResponse: """ - Update a blocked email sender + Modifies a blocked sender entry, updating its pattern or block reason. Args: account_id: Account Identifier @@ -286,7 +288,8 @@ def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> BlockSenderGetResponse: """ - Get a blocked email sender + Gets information about a specific blocked sender entry, including the pattern + and block reason. Args: account_id: Account Identifier @@ -352,7 +355,8 @@ async def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> BlockSenderCreateResponse: """ - Create a blocked email sender + Adds a sender pattern to the email block list, preventing messages from matching + senders from being delivered. Args: account_id: Account Identifier @@ -407,7 +411,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[BlockSenderListResponse, AsyncV4PagePaginationArray[BlockSenderListResponse]]: """ - List blocked email senders + Lists all blocked sender entries with their patterns and block reasons. Args: account_id: Account Identifier @@ -471,7 +475,8 @@ async def delete( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> BlockSenderDeleteResponse: """ - Delete a blocked email sender + Removes a sender from the email block list, allowing their messages to be + delivered normally. Args: account_id: Account Identifier @@ -517,7 +522,7 @@ async def edit( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> BlockSenderEditResponse: """ - Update a blocked email sender + Modifies a blocked sender entry, updating its pattern or block reason. Args: account_id: Account Identifier @@ -568,7 +573,8 @@ async def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> BlockSenderGetResponse: """ - Get a blocked email sender + Gets information about a specific blocked sender entry, including the pattern + and block reason. Args: account_id: Account Identifier diff --git a/src/cloudflare/resources/email_security/settings/domains.py b/src/cloudflare/resources/email_security/settings/domains.py index 9f8f717056a..cfe78def266 100644 --- a/src/cloudflare/resources/email_security/settings/domains.py +++ b/src/cloudflare/resources/email_security/settings/domains.py @@ -186,7 +186,8 @@ def bulk_delete( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncSinglePage[DomainBulkDeleteResponse]: """ - Unprotect multiple email domains + Bulk removes multiple domains from email security configuration in a single + request. Args: account_id: Account Identifier @@ -249,7 +250,7 @@ def edit( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> DomainEditResponse: """ - Update an email domain + Updates configuration for a domain in email security. Args: account_id: Account Identifier @@ -307,7 +308,7 @@ def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> DomainGetResponse: """ - Get an email domain + Gets configuration details for a specific domain in email security. Args: account_id: Account Identifier @@ -493,7 +494,8 @@ def bulk_delete( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[DomainBulkDeleteResponse, AsyncSinglePage[DomainBulkDeleteResponse]]: """ - Unprotect multiple email domains + Bulk removes multiple domains from email security configuration in a single + request. Args: account_id: Account Identifier @@ -556,7 +558,7 @@ async def edit( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> DomainEditResponse: """ - Update an email domain + Updates configuration for a domain in email security. Args: account_id: Account Identifier @@ -614,7 +616,7 @@ async def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> DomainGetResponse: """ - Get an email domain + Gets configuration details for a specific domain in email security. Args: account_id: Account Identifier diff --git a/src/cloudflare/resources/email_security/settings/impersonation_registry.py b/src/cloudflare/resources/email_security/settings/impersonation_registry.py index e5dcaae2429..988929ff74d 100644 --- a/src/cloudflare/resources/email_security/settings/impersonation_registry.py +++ b/src/cloudflare/resources/email_security/settings/impersonation_registry.py @@ -69,7 +69,7 @@ def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> ImpersonationRegistryCreateResponse: """ - Create an entry in impersonation registry + Creates a display name entry for email security impersonation protection. Args: account_id: Account Identifier @@ -186,7 +186,7 @@ def delete( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> ImpersonationRegistryDeleteResponse: """ - Delete an entry from impersonation registry + Removes a display name from impersonation protection monitoring. Args: account_id: Account Identifier @@ -229,7 +229,7 @@ def edit( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> ImpersonationRegistryEditResponse: """ - Update an entry in impersonation registry + Updates a display name entry used for impersonation protection. Args: account_id: Account Identifier @@ -277,7 +277,7 @@ def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> ImpersonationRegistryGetResponse: """ - Get an entry in impersonation registry + Retrieves a display name entry used for impersonation protection. Args: account_id: Account Identifier @@ -340,7 +340,7 @@ async def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> ImpersonationRegistryCreateResponse: """ - Create an entry in impersonation registry + Creates a display name entry for email security impersonation protection. Args: account_id: Account Identifier @@ -459,7 +459,7 @@ async def delete( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> ImpersonationRegistryDeleteResponse: """ - Delete an entry from impersonation registry + Removes a display name from impersonation protection monitoring. Args: account_id: Account Identifier @@ -502,7 +502,7 @@ async def edit( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> ImpersonationRegistryEditResponse: """ - Update an entry in impersonation registry + Updates a display name entry used for impersonation protection. Args: account_id: Account Identifier @@ -550,7 +550,7 @@ async def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> ImpersonationRegistryGetResponse: """ - Get an entry in impersonation registry + Retrieves a display name entry used for impersonation protection. Args: account_id: Account Identifier diff --git a/src/cloudflare/resources/email_security/settings/trusted_domains.py b/src/cloudflare/resources/email_security/settings/trusted_domains.py index 184b212d2ee..e79b273cc4e 100644 --- a/src/cloudflare/resources/email_security/settings/trusted_domains.py +++ b/src/cloudflare/resources/email_security/settings/trusted_domains.py @@ -72,7 +72,8 @@ def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> TrustedDomainCreateResponse: """ - Create a trusted email domain + Adds a domain to the trusted domains list for email security, reducing false + positive detections. Args: account_id: Account Identifier @@ -107,7 +108,8 @@ def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> TrustedDomainCreateResponse: """ - Create a trusted email domain + Adds a domain to the trusted domains list for email security, reducing false + positive detections. Args: account_id: Account Identifier @@ -255,7 +257,8 @@ def delete( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> TrustedDomainDeleteResponse: """ - Delete a trusted email domain + Removes a domain from the trusted domains list, subjecting it to normal security + scanning. Args: account_id: Account Identifier @@ -302,7 +305,7 @@ def edit( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> TrustedDomainEditResponse: """ - Update a trusted email domain + Modifies a trusted domain entry's configuration. Args: account_id: Account Identifier @@ -360,7 +363,7 @@ def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> TrustedDomainGetResponse: """ - Get a trusted email domain + Gets information about a specific trusted domain entry. Args: account_id: Account Identifier @@ -428,7 +431,8 @@ async def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> TrustedDomainCreateResponse: """ - Create a trusted email domain + Adds a domain to the trusted domains list for email security, reducing false + positive detections. Args: account_id: Account Identifier @@ -463,7 +467,8 @@ async def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> TrustedDomainCreateResponse: """ - Create a trusted email domain + Adds a domain to the trusted domains list for email security, reducing false + positive detections. Args: account_id: Account Identifier @@ -611,7 +616,8 @@ async def delete( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> TrustedDomainDeleteResponse: """ - Delete a trusted email domain + Removes a domain from the trusted domains list, subjecting it to normal security + scanning. Args: account_id: Account Identifier @@ -658,7 +664,7 @@ async def edit( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> TrustedDomainEditResponse: """ - Update a trusted email domain + Modifies a trusted domain entry's configuration. Args: account_id: Account Identifier @@ -716,7 +722,7 @@ async def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> TrustedDomainGetResponse: """ - Get a trusted email domain + Gets information about a specific trusted domain entry. Args: account_id: Account Identifier diff --git a/src/cloudflare/resources/email_security/submissions.py b/src/cloudflare/resources/email_security/submissions.py index 5eff9c1c234..685b8ee74de 100644 --- a/src/cloudflare/resources/email_security/submissions.py +++ b/src/cloudflare/resources/email_security/submissions.py @@ -50,6 +50,7 @@ def list( self, *, account_id: str, + customer_status: Literal["escalated", "reviewed", "unreviewed"] | Omit = omit, end: Union[str, datetime] | Omit = omit, original_disposition: Literal["MALICIOUS", "SUSPICIOUS", "SPOOF", "SPAM", "BULK", "NONE"] | Omit = omit, outcome_disposition: Literal["MALICIOUS", "SUSPICIOUS", "SPOOF", "SPAM", "BULK", "NONE"] | Omit = omit, @@ -103,6 +104,7 @@ def list( timeout=timeout, query=maybe_transform( { + "customer_status": customer_status, "end": end, "original_disposition": original_disposition, "outcome_disposition": outcome_disposition, @@ -146,6 +148,7 @@ def list( self, *, account_id: str, + customer_status: Literal["escalated", "reviewed", "unreviewed"] | Omit = omit, end: Union[str, datetime] | Omit = omit, original_disposition: Literal["MALICIOUS", "SUSPICIOUS", "SPOOF", "SPAM", "BULK", "NONE"] | Omit = omit, outcome_disposition: Literal["MALICIOUS", "SUSPICIOUS", "SPOOF", "SPAM", "BULK", "NONE"] | Omit = omit, @@ -199,6 +202,7 @@ def list( timeout=timeout, query=maybe_transform( { + "customer_status": customer_status, "end": end, "original_disposition": original_disposition, "outcome_disposition": outcome_disposition, diff --git a/src/cloudflare/resources/magic_transit/apps.py b/src/cloudflare/resources/magic_transit/apps.py index 11604493a1f..9a394b05499 100644 --- a/src/cloudflare/resources/magic_transit/apps.py +++ b/src/cloudflare/resources/magic_transit/apps.py @@ -57,6 +57,7 @@ def create( type: str, hostnames: SequenceNotStr[str] | Omit = omit, ip_subnets: SequenceNotStr[str] | Omit = omit, + source_subnets: SequenceNotStr[str] | Omit = omit, # 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, @@ -79,6 +80,9 @@ def create( ip_subnets: IPv4 CIDRs to associate with traffic decisions. (IPv6 CIDRs are currently unsupported) + source_subnets: IPv4 CIDRs to associate with traffic decisions. (IPv6 CIDRs are currently + unsupported) + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -97,6 +101,7 @@ def create( "type": type, "hostnames": hostnames, "ip_subnets": ip_subnets, + "source_subnets": source_subnets, }, app_create_params.AppCreateParams, ), @@ -118,6 +123,7 @@ def update( hostnames: SequenceNotStr[str] | Omit = omit, ip_subnets: SequenceNotStr[str] | Omit = omit, name: str | Omit = omit, + source_subnets: SequenceNotStr[str] | Omit = omit, type: str | Omit = omit, # 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. @@ -141,6 +147,9 @@ def update( name: Display name for the app. + source_subnets: IPv4 CIDRs to associate with traffic decisions. (IPv6 CIDRs are currently + unsupported) + type: Category of the app. extra_headers: Send extra headers @@ -162,6 +171,7 @@ def update( "hostnames": hostnames, "ip_subnets": ip_subnets, "name": name, + "source_subnets": source_subnets, "type": type, }, app_update_params.AppUpdateParams, @@ -264,6 +274,7 @@ def edit( hostnames: SequenceNotStr[str] | Omit = omit, ip_subnets: SequenceNotStr[str] | Omit = omit, name: str | Omit = omit, + source_subnets: SequenceNotStr[str] | Omit = omit, type: str | Omit = omit, # 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. @@ -287,6 +298,9 @@ def edit( name: Display name for the app. + source_subnets: IPv4 CIDRs to associate with traffic decisions. (IPv6 CIDRs are currently + unsupported) + type: Category of the app. extra_headers: Send extra headers @@ -308,6 +322,7 @@ def edit( "hostnames": hostnames, "ip_subnets": ip_subnets, "name": name, + "source_subnets": source_subnets, "type": type, }, app_edit_params.AppEditParams, @@ -351,6 +366,7 @@ async def create( type: str, hostnames: SequenceNotStr[str] | Omit = omit, ip_subnets: SequenceNotStr[str] | Omit = omit, + source_subnets: SequenceNotStr[str] | Omit = omit, # 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, @@ -373,6 +389,9 @@ async def create( ip_subnets: IPv4 CIDRs to associate with traffic decisions. (IPv6 CIDRs are currently unsupported) + source_subnets: IPv4 CIDRs to associate with traffic decisions. (IPv6 CIDRs are currently + unsupported) + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -391,6 +410,7 @@ async def create( "type": type, "hostnames": hostnames, "ip_subnets": ip_subnets, + "source_subnets": source_subnets, }, app_create_params.AppCreateParams, ), @@ -412,6 +432,7 @@ async def update( hostnames: SequenceNotStr[str] | Omit = omit, ip_subnets: SequenceNotStr[str] | Omit = omit, name: str | Omit = omit, + source_subnets: SequenceNotStr[str] | Omit = omit, type: str | Omit = omit, # 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. @@ -435,6 +456,9 @@ async def update( name: Display name for the app. + source_subnets: IPv4 CIDRs to associate with traffic decisions. (IPv6 CIDRs are currently + unsupported) + type: Category of the app. extra_headers: Send extra headers @@ -456,6 +480,7 @@ async def update( "hostnames": hostnames, "ip_subnets": ip_subnets, "name": name, + "source_subnets": source_subnets, "type": type, }, app_update_params.AppUpdateParams, @@ -558,6 +583,7 @@ async def edit( hostnames: SequenceNotStr[str] | Omit = omit, ip_subnets: SequenceNotStr[str] | Omit = omit, name: str | Omit = omit, + source_subnets: SequenceNotStr[str] | Omit = omit, type: str | Omit = omit, # 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. @@ -581,6 +607,9 @@ async def edit( name: Display name for the app. + source_subnets: IPv4 CIDRs to associate with traffic decisions. (IPv6 CIDRs are currently + unsupported) + type: Category of the app. extra_headers: Send extra headers @@ -602,6 +631,7 @@ async def edit( "hostnames": hostnames, "ip_subnets": ip_subnets, "name": name, + "source_subnets": source_subnets, "type": type, }, app_edit_params.AppEditParams, diff --git a/src/cloudflare/resources/magic_transit/connectors/connectors.py b/src/cloudflare/resources/magic_transit/connectors/connectors.py index 961707d44dc..f757d6a4b8d 100644 --- a/src/cloudflare/resources/magic_transit/connectors/connectors.py +++ b/src/cloudflare/resources/magic_transit/connectors/connectors.py @@ -2,11 +2,12 @@ from __future__ import annotations -from typing import Type, cast +from typing import List, Type, cast +from typing_extensions import Literal import httpx -from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given from ...._utils import maybe_transform, async_maybe_transform from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource @@ -80,7 +81,12 @@ def create( account_id: str, device: connector_create_params.Device, activated: bool | Omit = omit, + interrupt_window_days_of_week: List[ + Literal["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] + ] + | Omit = omit, interrupt_window_duration_hours: float | Omit = omit, + interrupt_window_embargo_dates: SequenceNotStr[str] | Omit = omit, interrupt_window_hour_of_day: float | Omit = omit, notes: str | Omit = omit, timezone: str | Omit = omit, @@ -99,6 +105,10 @@ def create( device: Exactly one of id, serial_number, or provision_license must be provided. + interrupt_window_days_of_week: Allowed days of the week for upgrades. Default is all days. + + interrupt_window_embargo_dates: List of dates (YYYY-MM-DD) when upgrades are blocked. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -115,7 +125,9 @@ def create( { "device": device, "activated": activated, + "interrupt_window_days_of_week": interrupt_window_days_of_week, "interrupt_window_duration_hours": interrupt_window_duration_hours, + "interrupt_window_embargo_dates": interrupt_window_embargo_dates, "interrupt_window_hour_of_day": interrupt_window_hour_of_day, "notes": notes, "timezone": timezone, @@ -138,7 +150,12 @@ def update( *, account_id: str, activated: bool | Omit = omit, + interrupt_window_days_of_week: List[ + Literal["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] + ] + | Omit = omit, interrupt_window_duration_hours: float | Omit = omit, + interrupt_window_embargo_dates: SequenceNotStr[str] | Omit = omit, interrupt_window_hour_of_day: float | Omit = omit, notes: str | Omit = omit, provision_license: bool | Omit = omit, @@ -156,6 +173,10 @@ def update( Args: account_id: Account identifier + interrupt_window_days_of_week: Allowed days of the week for upgrades. Default is all days. + + interrupt_window_embargo_dates: List of dates (YYYY-MM-DD) when upgrades are blocked. + provision_license: When true, regenerate license key for the connector. extra_headers: Send extra headers @@ -175,7 +196,9 @@ def update( body=maybe_transform( { "activated": activated, + "interrupt_window_days_of_week": interrupt_window_days_of_week, "interrupt_window_duration_hours": interrupt_window_duration_hours, + "interrupt_window_embargo_dates": interrupt_window_embargo_dates, "interrupt_window_hour_of_day": interrupt_window_hour_of_day, "notes": notes, "provision_license": provision_license, @@ -277,7 +300,12 @@ def edit( *, account_id: str, activated: bool | Omit = omit, + interrupt_window_days_of_week: List[ + Literal["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] + ] + | Omit = omit, interrupt_window_duration_hours: float | Omit = omit, + interrupt_window_embargo_dates: SequenceNotStr[str] | Omit = omit, interrupt_window_hour_of_day: float | Omit = omit, notes: str | Omit = omit, provision_license: bool | Omit = omit, @@ -295,6 +323,10 @@ def edit( Args: account_id: Account identifier + interrupt_window_days_of_week: Allowed days of the week for upgrades. Default is all days. + + interrupt_window_embargo_dates: List of dates (YYYY-MM-DD) when upgrades are blocked. + provision_license: When true, regenerate license key for the connector. extra_headers: Send extra headers @@ -314,7 +346,9 @@ def edit( body=maybe_transform( { "activated": activated, + "interrupt_window_days_of_week": interrupt_window_days_of_week, "interrupt_window_duration_hours": interrupt_window_duration_hours, + "interrupt_window_embargo_dates": interrupt_window_embargo_dates, "interrupt_window_hour_of_day": interrupt_window_hour_of_day, "notes": notes, "provision_license": provision_license, @@ -409,7 +443,12 @@ async def create( account_id: str, device: connector_create_params.Device, activated: bool | Omit = omit, + interrupt_window_days_of_week: List[ + Literal["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] + ] + | Omit = omit, interrupt_window_duration_hours: float | Omit = omit, + interrupt_window_embargo_dates: SequenceNotStr[str] | Omit = omit, interrupt_window_hour_of_day: float | Omit = omit, notes: str | Omit = omit, timezone: str | Omit = omit, @@ -428,6 +467,10 @@ async def create( device: Exactly one of id, serial_number, or provision_license must be provided. + interrupt_window_days_of_week: Allowed days of the week for upgrades. Default is all days. + + interrupt_window_embargo_dates: List of dates (YYYY-MM-DD) when upgrades are blocked. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -444,7 +487,9 @@ async def create( { "device": device, "activated": activated, + "interrupt_window_days_of_week": interrupt_window_days_of_week, "interrupt_window_duration_hours": interrupt_window_duration_hours, + "interrupt_window_embargo_dates": interrupt_window_embargo_dates, "interrupt_window_hour_of_day": interrupt_window_hour_of_day, "notes": notes, "timezone": timezone, @@ -467,7 +512,12 @@ async def update( *, account_id: str, activated: bool | Omit = omit, + interrupt_window_days_of_week: List[ + Literal["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] + ] + | Omit = omit, interrupt_window_duration_hours: float | Omit = omit, + interrupt_window_embargo_dates: SequenceNotStr[str] | Omit = omit, interrupt_window_hour_of_day: float | Omit = omit, notes: str | Omit = omit, provision_license: bool | Omit = omit, @@ -485,6 +535,10 @@ async def update( Args: account_id: Account identifier + interrupt_window_days_of_week: Allowed days of the week for upgrades. Default is all days. + + interrupt_window_embargo_dates: List of dates (YYYY-MM-DD) when upgrades are blocked. + provision_license: When true, regenerate license key for the connector. extra_headers: Send extra headers @@ -504,7 +558,9 @@ async def update( body=await async_maybe_transform( { "activated": activated, + "interrupt_window_days_of_week": interrupt_window_days_of_week, "interrupt_window_duration_hours": interrupt_window_duration_hours, + "interrupt_window_embargo_dates": interrupt_window_embargo_dates, "interrupt_window_hour_of_day": interrupt_window_hour_of_day, "notes": notes, "provision_license": provision_license, @@ -606,7 +662,12 @@ async def edit( *, account_id: str, activated: bool | Omit = omit, + interrupt_window_days_of_week: List[ + Literal["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] + ] + | Omit = omit, interrupt_window_duration_hours: float | Omit = omit, + interrupt_window_embargo_dates: SequenceNotStr[str] | Omit = omit, interrupt_window_hour_of_day: float | Omit = omit, notes: str | Omit = omit, provision_license: bool | Omit = omit, @@ -624,6 +685,10 @@ async def edit( Args: account_id: Account identifier + interrupt_window_days_of_week: Allowed days of the week for upgrades. Default is all days. + + interrupt_window_embargo_dates: List of dates (YYYY-MM-DD) when upgrades are blocked. + provision_license: When true, regenerate license key for the connector. extra_headers: Send extra headers @@ -643,7 +708,9 @@ async def edit( body=await async_maybe_transform( { "activated": activated, + "interrupt_window_days_of_week": interrupt_window_days_of_week, "interrupt_window_duration_hours": interrupt_window_duration_hours, + "interrupt_window_embargo_dates": interrupt_window_embargo_dates, "interrupt_window_hour_of_day": interrupt_window_hour_of_day, "notes": notes, "provision_license": provision_license, diff --git a/src/cloudflare/resources/magic_transit/sites/lans.py b/src/cloudflare/resources/magic_transit/sites/lans.py index a38a961f721..baab5990753 100644 --- a/src/cloudflare/resources/magic_transit/sites/lans.py +++ b/src/cloudflare/resources/magic_transit/sites/lans.py @@ -59,6 +59,8 @@ def create( account_id: str, bond_id: int | Omit = omit, ha_link: bool | Omit = omit, + is_breakout: bool | Omit = omit, + is_prioritized: bool | Omit = omit, name: str | Omit = omit, nat: NatParam | Omit = omit, physport: int | Omit = omit, @@ -85,6 +87,10 @@ def create( ha_link: mark true to use this LAN for HA probing. only works for site with HA turned on. only one LAN can be set as the ha_link. + is_breakout: mark true to use this LAN for source-based breakout traffic + + is_prioritized: mark true to use this LAN for source-based prioritized traffic + static_addressing: If the site is not configured in high availability mode, this configuration is optional (if omitted, use DHCP). However, if in high availability mode, static_address is required along with secondary and virtual address. @@ -110,6 +116,8 @@ def create( { "bond_id": bond_id, "ha_link": ha_link, + "is_breakout": is_breakout, + "is_prioritized": is_prioritized, "name": name, "nat": nat, "physport": physport, @@ -133,6 +141,8 @@ def update( account_id: str, site_id: str, bond_id: int | Omit = omit, + is_breakout: bool | Omit = omit, + is_prioritized: bool | Omit = omit, name: str | Omit = omit, nat: NatParam | Omit = omit, physport: int | Omit = omit, @@ -156,6 +166,10 @@ def update( lan_id: Identifier + is_breakout: mark true to use this LAN for source-based breakout traffic + + is_prioritized: mark true to use this LAN for source-based prioritized traffic + static_addressing: If the site is not configured in high availability mode, this configuration is optional (if omitted, use DHCP). However, if in high availability mode, static_address is required along with secondary and virtual address. @@ -181,6 +195,8 @@ def update( body=maybe_transform( { "bond_id": bond_id, + "is_breakout": is_breakout, + "is_prioritized": is_prioritized, "name": name, "nat": nat, "physport": physport, @@ -297,6 +313,8 @@ def edit( account_id: str, site_id: str, bond_id: int | Omit = omit, + is_breakout: bool | Omit = omit, + is_prioritized: bool | Omit = omit, name: str | Omit = omit, nat: NatParam | Omit = omit, physport: int | Omit = omit, @@ -320,6 +338,10 @@ def edit( lan_id: Identifier + is_breakout: mark true to use this LAN for source-based breakout traffic + + is_prioritized: mark true to use this LAN for source-based prioritized traffic + static_addressing: If the site is not configured in high availability mode, this configuration is optional (if omitted, use DHCP). However, if in high availability mode, static_address is required along with secondary and virtual address. @@ -345,6 +367,8 @@ def edit( body=maybe_transform( { "bond_id": bond_id, + "is_breakout": is_breakout, + "is_prioritized": is_prioritized, "name": name, "nat": nat, "physport": physport, @@ -441,6 +465,8 @@ def create( account_id: str, bond_id: int | Omit = omit, ha_link: bool | Omit = omit, + is_breakout: bool | Omit = omit, + is_prioritized: bool | Omit = omit, name: str | Omit = omit, nat: NatParam | Omit = omit, physport: int | Omit = omit, @@ -467,6 +493,10 @@ def create( ha_link: mark true to use this LAN for HA probing. only works for site with HA turned on. only one LAN can be set as the ha_link. + is_breakout: mark true to use this LAN for source-based breakout traffic + + is_prioritized: mark true to use this LAN for source-based prioritized traffic + static_addressing: If the site is not configured in high availability mode, this configuration is optional (if omitted, use DHCP). However, if in high availability mode, static_address is required along with secondary and virtual address. @@ -492,6 +522,8 @@ def create( { "bond_id": bond_id, "ha_link": ha_link, + "is_breakout": is_breakout, + "is_prioritized": is_prioritized, "name": name, "nat": nat, "physport": physport, @@ -515,6 +547,8 @@ async def update( account_id: str, site_id: str, bond_id: int | Omit = omit, + is_breakout: bool | Omit = omit, + is_prioritized: bool | Omit = omit, name: str | Omit = omit, nat: NatParam | Omit = omit, physport: int | Omit = omit, @@ -538,6 +572,10 @@ async def update( lan_id: Identifier + is_breakout: mark true to use this LAN for source-based breakout traffic + + is_prioritized: mark true to use this LAN for source-based prioritized traffic + static_addressing: If the site is not configured in high availability mode, this configuration is optional (if omitted, use DHCP). However, if in high availability mode, static_address is required along with secondary and virtual address. @@ -563,6 +601,8 @@ async def update( body=await async_maybe_transform( { "bond_id": bond_id, + "is_breakout": is_breakout, + "is_prioritized": is_prioritized, "name": name, "nat": nat, "physport": physport, @@ -679,6 +719,8 @@ async def edit( account_id: str, site_id: str, bond_id: int | Omit = omit, + is_breakout: bool | Omit = omit, + is_prioritized: bool | Omit = omit, name: str | Omit = omit, nat: NatParam | Omit = omit, physport: int | Omit = omit, @@ -702,6 +744,10 @@ async def edit( lan_id: Identifier + is_breakout: mark true to use this LAN for source-based breakout traffic + + is_prioritized: mark true to use this LAN for source-based prioritized traffic + static_addressing: If the site is not configured in high availability mode, this configuration is optional (if omitted, use DHCP). However, if in high availability mode, static_address is required along with secondary and virtual address. @@ -727,6 +773,8 @@ async def edit( body=await async_maybe_transform( { "bond_id": bond_id, + "is_breakout": is_breakout, + "is_prioritized": is_prioritized, "name": name, "nat": nat, "physport": physport, diff --git a/src/cloudflare/resources/radar/ai/inference/inference.py b/src/cloudflare/resources/radar/ai/inference/inference.py index 8a3e3da863e..08ae1e5b9ce 100644 --- a/src/cloudflare/resources/radar/ai/inference/inference.py +++ b/src/cloudflare/resources/radar/ai/inference/inference.py @@ -177,7 +177,7 @@ def timeseries_groups_v2( limit_per_group: int | Omit = omit, location: SequenceNotStr[str] | Omit = omit, name: SequenceNotStr[str] | Omit = omit, - normalization: Literal["PERCENTAGE_CHANGE", "MIN0_MAX"] | Omit = omit, + normalization: Literal["PERCENTAGE", "MIN0_MAX"] | Omit = omit, # 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, @@ -401,7 +401,7 @@ async def timeseries_groups_v2( limit_per_group: int | Omit = omit, location: SequenceNotStr[str] | Omit = omit, name: SequenceNotStr[str] | Omit = omit, - normalization: Literal["PERCENTAGE_CHANGE", "MIN0_MAX"] | Omit = omit, + normalization: Literal["PERCENTAGE", "MIN0_MAX"] | Omit = omit, # 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, diff --git a/src/cloudflare/resources/radar/ai/to_markdown.py b/src/cloudflare/resources/radar/ai/to_markdown.py index 8c4db60fd81..1e675de3355 100644 --- a/src/cloudflare/resources/radar/ai/to_markdown.py +++ b/src/cloudflare/resources/radar/ai/to_markdown.py @@ -69,7 +69,7 @@ def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncSinglePage[ToMarkdownCreateResponse]: """ - Convert Files into Markdown + Converts uploaded files into Markdown format using Workers AI. Args: extra_headers: Send extra headers @@ -137,7 +137,7 @@ def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[ToMarkdownCreateResponse, AsyncSinglePage[ToMarkdownCreateResponse]]: """ - Convert Files into Markdown + Converts uploaded files into Markdown format using Workers AI. Args: extra_headers: Send extra headers diff --git a/src/cloudflare/resources/radar/dns/dns.py b/src/cloudflare/resources/radar/dns/dns.py index fd383b017c0..539c48177f4 100644 --- a/src/cloudflare/resources/radar/dns/dns.py +++ b/src/cloudflare/resources/radar/dns/dns.py @@ -87,11 +87,13 @@ def with_streaming_response(self) -> DNSResourceWithStreamingResponse: def summary_v2( self, dimension: Literal[ - "IP_VERSION", + "AS", "CACHE_HIT", "DNSSEC", "DNSSEC_AWARE", "DNSSEC_E2E", + "IP_VERSION", + "LOCATION", "MATCHING_ANSWER", "PROTOCOL", "QUERY_TYPE", @@ -613,11 +615,13 @@ def timeseries( def timeseries_groups_v2( self, dimension: Literal[ - "IP_VERSION", + "AS", "CACHE_HIT", "DNSSEC", "DNSSEC_AWARE", "DNSSEC_E2E", + "IP_VERSION", + "LOCATION", "MATCHING_ANSWER", "PROTOCOL", "QUERY_TYPE", @@ -928,11 +932,13 @@ def with_streaming_response(self) -> AsyncDNSResourceWithStreamingResponse: async def summary_v2( self, dimension: Literal[ - "IP_VERSION", + "AS", "CACHE_HIT", "DNSSEC", "DNSSEC_AWARE", "DNSSEC_E2E", + "IP_VERSION", + "LOCATION", "MATCHING_ANSWER", "PROTOCOL", "QUERY_TYPE", @@ -1454,11 +1460,13 @@ async def timeseries( async def timeseries_groups_v2( self, dimension: Literal[ - "IP_VERSION", + "AS", "CACHE_HIT", "DNSSEC", "DNSSEC_AWARE", "DNSSEC_E2E", + "IP_VERSION", + "LOCATION", "MATCHING_ANSWER", "PROTOCOL", "QUERY_TYPE", diff --git a/src/cloudflare/resources/radar/http/http.py b/src/cloudflare/resources/radar/http/http.py index 9754cb0f2e0..90dc011257e 100644 --- a/src/cloudflare/resources/radar/http/http.py +++ b/src/cloudflare/resources/radar/http/http.py @@ -112,6 +112,7 @@ def summary_v2( self, dimension: Literal[ "ADM1", + "AS", "BOT_CLASS", "BROWSER", "BROWSER_FAMILY", @@ -119,6 +120,7 @@ def summary_v2( "HTTP_PROTOCOL", "HTTP_VERSION", "IP_VERSION", + "LOCATION", "OS", "POST_QUANTUM", "TLS_VERSION", @@ -382,6 +384,7 @@ def timeseries_groups_v2( self, dimension: Literal[ "ADM1", + "AS", "BOT_CLASS", "BROWSER", "BROWSER_FAMILY", @@ -389,6 +392,7 @@ def timeseries_groups_v2( "HTTP_PROTOCOL", "HTTP_VERSION", "IP_VERSION", + "LOCATION", "OS", "POST_QUANTUM", "TLS_VERSION", @@ -573,6 +577,7 @@ async def summary_v2( self, dimension: Literal[ "ADM1", + "AS", "BOT_CLASS", "BROWSER", "BROWSER_FAMILY", @@ -580,6 +585,7 @@ async def summary_v2( "HTTP_PROTOCOL", "HTTP_VERSION", "IP_VERSION", + "LOCATION", "OS", "POST_QUANTUM", "TLS_VERSION", @@ -843,6 +849,7 @@ async def timeseries_groups_v2( self, dimension: Literal[ "ADM1", + "AS", "BOT_CLASS", "BROWSER", "BROWSER_FAMILY", @@ -850,6 +857,7 @@ async def timeseries_groups_v2( "HTTP_PROTOCOL", "HTTP_VERSION", "IP_VERSION", + "LOCATION", "OS", "POST_QUANTUM", "TLS_VERSION", diff --git a/src/cloudflare/resources/radar/netflows/netflows.py b/src/cloudflare/resources/radar/netflows/netflows.py index 829305489be..04cfe8a3157 100644 --- a/src/cloudflare/resources/radar/netflows/netflows.py +++ b/src/cloudflare/resources/radar/netflows/netflows.py @@ -160,7 +160,7 @@ def summary( def summary_v2( self, - dimension: Literal["ADM1", "PRODUCT"], + dimension: Literal["ADM1", "AS", "LOCATION", "PRODUCT"], *, asn: SequenceNotStr[str] | Omit = omit, continent: SequenceNotStr[str] | Omit = omit, @@ -365,7 +365,7 @@ def timeseries( def timeseries_groups( self, - dimension: Literal["ADM1", "PRODUCT"], + dimension: Literal["ADM1", "AS", "LOCATION", "PRODUCT"], *, agg_interval: Literal["15m", "1h", "1d", "1w"] | Omit = omit, asn: SequenceNotStr[str] | Omit = omit, @@ -595,7 +595,7 @@ async def summary( async def summary_v2( self, - dimension: Literal["ADM1", "PRODUCT"], + dimension: Literal["ADM1", "AS", "LOCATION", "PRODUCT"], *, asn: SequenceNotStr[str] | Omit = omit, continent: SequenceNotStr[str] | Omit = omit, @@ -800,7 +800,7 @@ async def timeseries( async def timeseries_groups( self, - dimension: Literal["ADM1", "PRODUCT"], + dimension: Literal["ADM1", "AS", "LOCATION", "PRODUCT"], *, agg_interval: Literal["15m", "1h", "1d", "1w"] | Omit = omit, asn: SequenceNotStr[str] | Omit = omit, diff --git a/src/cloudflare/resources/rulesets/rules.py b/src/cloudflare/resources/rulesets/rules.py index e1f991a9e29..85c818be54b 100644 --- a/src/cloudflare/resources/rulesets/rules.py +++ b/src/cloudflare/resources/rulesets/rules.py @@ -1083,6 +1083,75 @@ def create( """ ... + @overload + def create( + self, + ruleset_id: str, + *, + account_id: str | Omit = omit, + zone_id: str | Omit = omit, + id: str | Omit = omit, + action: Literal["set_cache_control"] | Omit = omit, + action_parameters: rule_create_params.SetCacheControlRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.SetCacheControlRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.SetCacheControlRulePosition | Omit = omit, + ratelimit: rule_create_params.SetCacheControlRuleRatelimit | Omit = omit, + ref: str | Omit = omit, + # 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + 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 + """ + ... + @overload def create( self, @@ -1152,6 +1221,75 @@ def create( """ ... + @overload + def create( + self, + ruleset_id: str, + *, + account_id: str | Omit = omit, + zone_id: str | Omit = omit, + id: str | Omit = omit, + action: Literal["set_cache_tags"] | Omit = omit, + action_parameters: rule_create_params.SetCacheTagsRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.SetCacheTagsRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.SetCacheTagsRulePosition | Omit = omit, + ratelimit: rule_create_params.SetCacheTagsRuleRatelimit | Omit = omit, + ref: str | Omit = omit, + # 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + 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 + """ + ... + @overload def create( self, @@ -1312,7 +1450,9 @@ def create( | Literal["route"] | Literal["score"] | Literal["serve_error"] + | Literal["set_cache_control"] | Literal["set_cache_settings"] + | Literal["set_cache_tags"] | Literal["set_config"] | Literal["skip"] | Omit = omit, @@ -1326,7 +1466,9 @@ def create( | rule_create_params.RouteRuleActionParameters | rule_create_params.ScoreRuleActionParameters | rule_create_params.ServeErrorRuleActionParameters + | rule_create_params.SetCacheControlRuleActionParameters | rule_create_params.SetCacheSettingsRuleActionParameters + | rule_create_params.SetCacheTagsRuleActionParameters | rule_create_params.SetConfigurationRuleActionParameters | rule_create_params.SkipRuleActionParameters | Omit = omit, @@ -1347,7 +1489,9 @@ def create( | rule_create_params.RouteRuleExposedCredentialCheck | rule_create_params.ScoreRuleExposedCredentialCheck | rule_create_params.ServeErrorRuleExposedCredentialCheck + | rule_create_params.SetCacheControlRuleExposedCredentialCheck | rule_create_params.SetCacheSettingsRuleExposedCredentialCheck + | rule_create_params.SetCacheTagsRuleExposedCredentialCheck | rule_create_params.SetConfigurationRuleExposedCredentialCheck | rule_create_params.SkipRuleExposedCredentialCheck | Omit = omit, @@ -1368,7 +1512,9 @@ def create( | rule_create_params.RouteRulePosition | rule_create_params.ScoreRulePosition | rule_create_params.ServeErrorRulePosition + | rule_create_params.SetCacheControlRulePosition | rule_create_params.SetCacheSettingsRulePosition + | rule_create_params.SetCacheTagsRulePosition | rule_create_params.SetConfigurationRulePosition | rule_create_params.SkipRulePosition | Omit = omit, @@ -1387,7 +1533,9 @@ def create( | rule_create_params.RouteRuleRatelimit | rule_create_params.ScoreRuleRatelimit | rule_create_params.ServeErrorRuleRatelimit + | rule_create_params.SetCacheControlRuleRatelimit | rule_create_params.SetCacheSettingsRuleRatelimit + | rule_create_params.SetCacheTagsRuleRatelimit | rule_create_params.SetConfigurationRuleRatelimit | rule_create_params.SkipRuleRatelimit | Omit = omit, @@ -2553,6 +2701,76 @@ def edit( """ ... + @overload + def edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | Omit = omit, + zone_id: str | Omit = omit, + id: str | Omit = omit, + action: Literal["set_cache_control"] | Omit = omit, + action_parameters: rule_edit_params.SetCacheControlRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.SetCacheControlRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.SetCacheControlRulePosition | Omit = omit, + ratelimit: rule_edit_params.SetCacheControlRuleRatelimit | Omit = omit, + ref: str | Omit = omit, + # 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + 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 + """ + ... + @overload def edit( self, @@ -2623,6 +2841,76 @@ def edit( """ ... + @overload + def edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | Omit = omit, + zone_id: str | Omit = omit, + id: str | Omit = omit, + action: Literal["set_cache_tags"] | Omit = omit, + action_parameters: rule_edit_params.SetCacheTagsRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.SetCacheTagsRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.SetCacheTagsRulePosition | Omit = omit, + ratelimit: rule_edit_params.SetCacheTagsRuleRatelimit | Omit = omit, + ref: str | Omit = omit, + # 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + 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 + """ + ... + @overload def edit( self, @@ -2787,7 +3075,9 @@ def edit( | Literal["route"] | Literal["score"] | Literal["serve_error"] + | Literal["set_cache_control"] | Literal["set_cache_settings"] + | Literal["set_cache_tags"] | Literal["set_config"] | Literal["skip"] | Omit = omit, @@ -2801,7 +3091,9 @@ def edit( | rule_edit_params.RouteRuleActionParameters | rule_edit_params.ScoreRuleActionParameters | rule_edit_params.ServeErrorRuleActionParameters + | rule_edit_params.SetCacheControlRuleActionParameters | rule_edit_params.SetCacheSettingsRuleActionParameters + | rule_edit_params.SetCacheTagsRuleActionParameters | rule_edit_params.SetConfigurationRuleActionParameters | rule_edit_params.SkipRuleActionParameters | Omit = omit, @@ -2822,7 +3114,9 @@ def edit( | rule_edit_params.RouteRuleExposedCredentialCheck | rule_edit_params.ScoreRuleExposedCredentialCheck | rule_edit_params.ServeErrorRuleExposedCredentialCheck + | rule_edit_params.SetCacheControlRuleExposedCredentialCheck | rule_edit_params.SetCacheSettingsRuleExposedCredentialCheck + | rule_edit_params.SetCacheTagsRuleExposedCredentialCheck | rule_edit_params.SetConfigurationRuleExposedCredentialCheck | rule_edit_params.SkipRuleExposedCredentialCheck | Omit = omit, @@ -2843,7 +3137,9 @@ def edit( | rule_edit_params.RouteRulePosition | rule_edit_params.ScoreRulePosition | rule_edit_params.ServeErrorRulePosition + | rule_edit_params.SetCacheControlRulePosition | rule_edit_params.SetCacheSettingsRulePosition + | rule_edit_params.SetCacheTagsRulePosition | rule_edit_params.SetConfigurationRulePosition | rule_edit_params.SkipRulePosition | Omit = omit, @@ -2862,7 +3158,9 @@ def edit( | rule_edit_params.RouteRuleRatelimit | rule_edit_params.ScoreRuleRatelimit | rule_edit_params.ServeErrorRuleRatelimit + | rule_edit_params.SetCacheControlRuleRatelimit | rule_edit_params.SetCacheSettingsRuleRatelimit + | rule_edit_params.SetCacheTagsRuleRatelimit | rule_edit_params.SetConfigurationRuleRatelimit | rule_edit_params.SkipRuleRatelimit | Omit = omit, @@ -3085,15 +3383,153 @@ async def create( account_id: str | Omit = omit, zone_id: str | Omit = omit, id: str | Omit = omit, - action: Literal["compress_response"] | Omit = omit, - action_parameters: rule_create_params.ResponseCompressionRuleActionParameters | Omit = omit, + action: Literal["compress_response"] | Omit = omit, + action_parameters: rule_create_params.ResponseCompressionRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.ResponseCompressionRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.ResponseCompressionRulePosition | Omit = omit, + ratelimit: rule_create_params.ResponseCompressionRuleRatelimit | Omit = omit, + ref: str | Omit = omit, + # 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + 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 + """ + ... + + @overload + async def create( + self, + ruleset_id: str, + *, + account_id: str | Omit = omit, + zone_id: str | Omit = omit, + id: str | Omit = omit, + action: Literal["ddos_dynamic"] | Omit = omit, + action_parameters: object | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_create_params.DDoSDynamicRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_create_params.DDoSDynamicRulePosition | Omit = omit, + ratelimit: rule_create_params.DDoSDynamicRuleRatelimit | Omit = omit, + ref: str | Omit = omit, + # 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, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + 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 + """ + ... + + @overload + async def create( + self, + ruleset_id: str, + *, + account_id: str | Omit = omit, + zone_id: str | Omit = omit, + id: str | Omit = omit, + action: Literal["execute"] | Omit = omit, + action_parameters: rule_create_params.ExecuteRuleActionParameters | Omit = omit, description: str | Omit = omit, enabled: bool | Omit = omit, - exposed_credential_check: rule_create_params.ResponseCompressionRuleExposedCredentialCheck | Omit = omit, + exposed_credential_check: rule_create_params.ExecuteRuleExposedCredentialCheck | Omit = omit, expression: str | Omit = omit, logging: LoggingParam | Omit = omit, - position: rule_create_params.ResponseCompressionRulePosition | Omit = omit, - ratelimit: rule_create_params.ResponseCompressionRuleRatelimit | Omit = omit, + position: rule_create_params.ExecuteRulePosition | Omit = omit, + ratelimit: rule_create_params.ExecuteRuleRatelimit | Omit = omit, ref: str | Omit = omit, # 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. @@ -3154,15 +3590,15 @@ async def create( account_id: str | Omit = omit, zone_id: str | Omit = omit, id: str | Omit = omit, - action: Literal["ddos_dynamic"] | Omit = omit, + action: Literal["force_connection_close"] | Omit = omit, action_parameters: object | Omit = omit, description: str | Omit = omit, enabled: bool | Omit = omit, - exposed_credential_check: rule_create_params.DDoSDynamicRuleExposedCredentialCheck | Omit = omit, + exposed_credential_check: rule_create_params.ForceConnectionCloseRuleExposedCredentialCheck | Omit = omit, expression: str | Omit = omit, logging: LoggingParam | Omit = omit, - position: rule_create_params.DDoSDynamicRulePosition | Omit = omit, - ratelimit: rule_create_params.DDoSDynamicRuleRatelimit | Omit = omit, + position: rule_create_params.ForceConnectionCloseRulePosition | Omit = omit, + ratelimit: rule_create_params.ForceConnectionCloseRuleRatelimit | Omit = omit, ref: str | Omit = omit, # 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. @@ -3223,15 +3659,15 @@ async def create( account_id: str | Omit = omit, zone_id: str | Omit = omit, id: str | Omit = omit, - action: Literal["execute"] | Omit = omit, - action_parameters: rule_create_params.ExecuteRuleActionParameters | Omit = omit, + action: Literal["js_challenge"] | Omit = omit, + action_parameters: object | Omit = omit, description: str | Omit = omit, enabled: bool | Omit = omit, - exposed_credential_check: rule_create_params.ExecuteRuleExposedCredentialCheck | Omit = omit, + exposed_credential_check: rule_create_params.JavaScriptChallengeRuleExposedCredentialCheck | Omit = omit, expression: str | Omit = omit, logging: LoggingParam | Omit = omit, - position: rule_create_params.ExecuteRulePosition | Omit = omit, - ratelimit: rule_create_params.ExecuteRuleRatelimit | Omit = omit, + position: rule_create_params.JavaScriptChallengeRulePosition | Omit = omit, + ratelimit: rule_create_params.JavaScriptChallengeRuleRatelimit | Omit = omit, ref: str | Omit = omit, # 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. @@ -3292,15 +3728,15 @@ async def create( account_id: str | Omit = omit, zone_id: str | Omit = omit, id: str | Omit = omit, - action: Literal["force_connection_close"] | Omit = omit, + action: Literal["log"] | Omit = omit, action_parameters: object | Omit = omit, description: str | Omit = omit, enabled: bool | Omit = omit, - exposed_credential_check: rule_create_params.ForceConnectionCloseRuleExposedCredentialCheck | Omit = omit, + exposed_credential_check: rule_create_params.LogRuleExposedCredentialCheck | Omit = omit, expression: str | Omit = omit, logging: LoggingParam | Omit = omit, - position: rule_create_params.ForceConnectionCloseRulePosition | Omit = omit, - ratelimit: rule_create_params.ForceConnectionCloseRuleRatelimit | Omit = omit, + position: rule_create_params.LogRulePosition | Omit = omit, + ratelimit: rule_create_params.LogRuleRatelimit | Omit = omit, ref: str | Omit = omit, # 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. @@ -3361,15 +3797,15 @@ async def create( account_id: str | Omit = omit, zone_id: str | Omit = omit, id: str | Omit = omit, - action: Literal["js_challenge"] | Omit = omit, - action_parameters: object | Omit = omit, + action: Literal["log_custom_field"] | Omit = omit, + action_parameters: rule_create_params.LogCustomFieldRuleActionParameters | Omit = omit, description: str | Omit = omit, enabled: bool | Omit = omit, - exposed_credential_check: rule_create_params.JavaScriptChallengeRuleExposedCredentialCheck | Omit = omit, + exposed_credential_check: rule_create_params.LogCustomFieldRuleExposedCredentialCheck | Omit = omit, expression: str | Omit = omit, logging: LoggingParam | Omit = omit, - position: rule_create_params.JavaScriptChallengeRulePosition | Omit = omit, - ratelimit: rule_create_params.JavaScriptChallengeRuleRatelimit | Omit = omit, + position: rule_create_params.LogCustomFieldRulePosition | Omit = omit, + ratelimit: rule_create_params.LogCustomFieldRuleRatelimit | Omit = omit, ref: str | Omit = omit, # 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. @@ -3430,15 +3866,15 @@ async def create( account_id: str | Omit = omit, zone_id: str | Omit = omit, id: str | Omit = omit, - action: Literal["log"] | Omit = omit, + action: Literal["managed_challenge"] | Omit = omit, action_parameters: object | Omit = omit, description: str | Omit = omit, enabled: bool | Omit = omit, - exposed_credential_check: rule_create_params.LogRuleExposedCredentialCheck | Omit = omit, + exposed_credential_check: rule_create_params.ManagedChallengeRuleExposedCredentialCheck | Omit = omit, expression: str | Omit = omit, logging: LoggingParam | Omit = omit, - position: rule_create_params.LogRulePosition | Omit = omit, - ratelimit: rule_create_params.LogRuleRatelimit | Omit = omit, + position: rule_create_params.ManagedChallengeRulePosition | Omit = omit, + ratelimit: rule_create_params.ManagedChallengeRuleRatelimit | Omit = omit, ref: str | Omit = omit, # 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. @@ -3499,15 +3935,15 @@ async def create( account_id: str | Omit = omit, zone_id: str | Omit = omit, id: str | Omit = omit, - action: Literal["log_custom_field"] | Omit = omit, - action_parameters: rule_create_params.LogCustomFieldRuleActionParameters | Omit = omit, + action: Literal["redirect"] | Omit = omit, + action_parameters: rule_create_params.RedirectRuleActionParameters | Omit = omit, description: str | Omit = omit, enabled: bool | Omit = omit, - exposed_credential_check: rule_create_params.LogCustomFieldRuleExposedCredentialCheck | Omit = omit, + exposed_credential_check: rule_create_params.RedirectRuleExposedCredentialCheck | Omit = omit, expression: str | Omit = omit, logging: LoggingParam | Omit = omit, - position: rule_create_params.LogCustomFieldRulePosition | Omit = omit, - ratelimit: rule_create_params.LogCustomFieldRuleRatelimit | Omit = omit, + position: rule_create_params.RedirectRulePosition | Omit = omit, + ratelimit: rule_create_params.RedirectRuleRatelimit | Omit = omit, ref: str | Omit = omit, # 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. @@ -3568,15 +4004,15 @@ async def create( account_id: str | Omit = omit, zone_id: str | Omit = omit, id: str | Omit = omit, - action: Literal["managed_challenge"] | Omit = omit, - action_parameters: object | Omit = omit, + action: Literal["rewrite"] | Omit = omit, + action_parameters: rule_create_params.RewriteRuleActionParameters | Omit = omit, description: str | Omit = omit, enabled: bool | Omit = omit, - exposed_credential_check: rule_create_params.ManagedChallengeRuleExposedCredentialCheck | Omit = omit, + exposed_credential_check: rule_create_params.RewriteRuleExposedCredentialCheck | Omit = omit, expression: str | Omit = omit, logging: LoggingParam | Omit = omit, - position: rule_create_params.ManagedChallengeRulePosition | Omit = omit, - ratelimit: rule_create_params.ManagedChallengeRuleRatelimit | Omit = omit, + position: rule_create_params.RewriteRulePosition | Omit = omit, + ratelimit: rule_create_params.RewriteRuleRatelimit | Omit = omit, ref: str | Omit = omit, # 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. @@ -3637,15 +4073,15 @@ async def create( account_id: str | Omit = omit, zone_id: str | Omit = omit, id: str | Omit = omit, - action: Literal["redirect"] | Omit = omit, - action_parameters: rule_create_params.RedirectRuleActionParameters | Omit = omit, + action: Literal["route"] | Omit = omit, + action_parameters: rule_create_params.RouteRuleActionParameters | Omit = omit, description: str | Omit = omit, enabled: bool | Omit = omit, - exposed_credential_check: rule_create_params.RedirectRuleExposedCredentialCheck | Omit = omit, + exposed_credential_check: rule_create_params.RouteRuleExposedCredentialCheck | Omit = omit, expression: str | Omit = omit, logging: LoggingParam | Omit = omit, - position: rule_create_params.RedirectRulePosition | Omit = omit, - ratelimit: rule_create_params.RedirectRuleRatelimit | Omit = omit, + position: rule_create_params.RouteRulePosition | Omit = omit, + ratelimit: rule_create_params.RouteRuleRatelimit | Omit = omit, ref: str | Omit = omit, # 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. @@ -3706,15 +4142,15 @@ async def create( account_id: str | Omit = omit, zone_id: str | Omit = omit, id: str | Omit = omit, - action: Literal["rewrite"] | Omit = omit, - action_parameters: rule_create_params.RewriteRuleActionParameters | Omit = omit, + action: Literal["score"] | Omit = omit, + action_parameters: rule_create_params.ScoreRuleActionParameters | Omit = omit, description: str | Omit = omit, enabled: bool | Omit = omit, - exposed_credential_check: rule_create_params.RewriteRuleExposedCredentialCheck | Omit = omit, + exposed_credential_check: rule_create_params.ScoreRuleExposedCredentialCheck | Omit = omit, expression: str | Omit = omit, logging: LoggingParam | Omit = omit, - position: rule_create_params.RewriteRulePosition | Omit = omit, - ratelimit: rule_create_params.RewriteRuleRatelimit | Omit = omit, + position: rule_create_params.ScoreRulePosition | Omit = omit, + ratelimit: rule_create_params.ScoreRuleRatelimit | Omit = omit, ref: str | Omit = omit, # 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. @@ -3775,15 +4211,15 @@ async def create( account_id: str | Omit = omit, zone_id: str | Omit = omit, id: str | Omit = omit, - action: Literal["route"] | Omit = omit, - action_parameters: rule_create_params.RouteRuleActionParameters | Omit = omit, + action: Literal["serve_error"] | Omit = omit, + action_parameters: rule_create_params.ServeErrorRuleActionParameters | Omit = omit, description: str | Omit = omit, enabled: bool | Omit = omit, - exposed_credential_check: rule_create_params.RouteRuleExposedCredentialCheck | Omit = omit, + exposed_credential_check: rule_create_params.ServeErrorRuleExposedCredentialCheck | Omit = omit, expression: str | Omit = omit, logging: LoggingParam | Omit = omit, - position: rule_create_params.RouteRulePosition | Omit = omit, - ratelimit: rule_create_params.RouteRuleRatelimit | Omit = omit, + position: rule_create_params.ServeErrorRulePosition | Omit = omit, + ratelimit: rule_create_params.ServeErrorRuleRatelimit | Omit = omit, ref: str | Omit = omit, # 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. @@ -3844,15 +4280,15 @@ async def create( account_id: str | Omit = omit, zone_id: str | Omit = omit, id: str | Omit = omit, - action: Literal["score"] | Omit = omit, - action_parameters: rule_create_params.ScoreRuleActionParameters | Omit = omit, + action: Literal["set_cache_control"] | Omit = omit, + action_parameters: rule_create_params.SetCacheControlRuleActionParameters | Omit = omit, description: str | Omit = omit, enabled: bool | Omit = omit, - exposed_credential_check: rule_create_params.ScoreRuleExposedCredentialCheck | Omit = omit, + exposed_credential_check: rule_create_params.SetCacheControlRuleExposedCredentialCheck | Omit = omit, expression: str | Omit = omit, logging: LoggingParam | Omit = omit, - position: rule_create_params.ScoreRulePosition | Omit = omit, - ratelimit: rule_create_params.ScoreRuleRatelimit | Omit = omit, + position: rule_create_params.SetCacheControlRulePosition | Omit = omit, + ratelimit: rule_create_params.SetCacheControlRuleRatelimit | Omit = omit, ref: str | Omit = omit, # 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. @@ -3913,15 +4349,15 @@ async def create( account_id: str | Omit = omit, zone_id: str | Omit = omit, id: str | Omit = omit, - action: Literal["serve_error"] | Omit = omit, - action_parameters: rule_create_params.ServeErrorRuleActionParameters | Omit = omit, + action: Literal["set_cache_settings"] | Omit = omit, + action_parameters: rule_create_params.SetCacheSettingsRuleActionParameters | Omit = omit, description: str | Omit = omit, enabled: bool | Omit = omit, - exposed_credential_check: rule_create_params.ServeErrorRuleExposedCredentialCheck | Omit = omit, + exposed_credential_check: rule_create_params.SetCacheSettingsRuleExposedCredentialCheck | Omit = omit, expression: str | Omit = omit, logging: LoggingParam | Omit = omit, - position: rule_create_params.ServeErrorRulePosition | Omit = omit, - ratelimit: rule_create_params.ServeErrorRuleRatelimit | Omit = omit, + position: rule_create_params.SetCacheSettingsRulePosition | Omit = omit, + ratelimit: rule_create_params.SetCacheSettingsRuleRatelimit | Omit = omit, ref: str | Omit = omit, # 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. @@ -3982,15 +4418,15 @@ async def create( account_id: str | Omit = omit, zone_id: str | Omit = omit, id: str | Omit = omit, - action: Literal["set_cache_settings"] | Omit = omit, - action_parameters: rule_create_params.SetCacheSettingsRuleActionParameters | Omit = omit, + action: Literal["set_cache_tags"] | Omit = omit, + action_parameters: rule_create_params.SetCacheTagsRuleActionParameters | Omit = omit, description: str | Omit = omit, enabled: bool | Omit = omit, - exposed_credential_check: rule_create_params.SetCacheSettingsRuleExposedCredentialCheck | Omit = omit, + exposed_credential_check: rule_create_params.SetCacheTagsRuleExposedCredentialCheck | Omit = omit, expression: str | Omit = omit, logging: LoggingParam | Omit = omit, - position: rule_create_params.SetCacheSettingsRulePosition | Omit = omit, - ratelimit: rule_create_params.SetCacheSettingsRuleRatelimit | Omit = omit, + position: rule_create_params.SetCacheTagsRulePosition | Omit = omit, + ratelimit: rule_create_params.SetCacheTagsRuleRatelimit | Omit = omit, ref: str | Omit = omit, # 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. @@ -4203,7 +4639,9 @@ async def create( | Literal["route"] | Literal["score"] | Literal["serve_error"] + | Literal["set_cache_control"] | Literal["set_cache_settings"] + | Literal["set_cache_tags"] | Literal["set_config"] | Literal["skip"] | Omit = omit, @@ -4217,7 +4655,9 @@ async def create( | rule_create_params.RouteRuleActionParameters | rule_create_params.ScoreRuleActionParameters | rule_create_params.ServeErrorRuleActionParameters + | rule_create_params.SetCacheControlRuleActionParameters | rule_create_params.SetCacheSettingsRuleActionParameters + | rule_create_params.SetCacheTagsRuleActionParameters | rule_create_params.SetConfigurationRuleActionParameters | rule_create_params.SkipRuleActionParameters | Omit = omit, @@ -4238,7 +4678,9 @@ async def create( | rule_create_params.RouteRuleExposedCredentialCheck | rule_create_params.ScoreRuleExposedCredentialCheck | rule_create_params.ServeErrorRuleExposedCredentialCheck + | rule_create_params.SetCacheControlRuleExposedCredentialCheck | rule_create_params.SetCacheSettingsRuleExposedCredentialCheck + | rule_create_params.SetCacheTagsRuleExposedCredentialCheck | rule_create_params.SetConfigurationRuleExposedCredentialCheck | rule_create_params.SkipRuleExposedCredentialCheck | Omit = omit, @@ -4259,7 +4701,9 @@ async def create( | rule_create_params.RouteRulePosition | rule_create_params.ScoreRulePosition | rule_create_params.ServeErrorRulePosition + | rule_create_params.SetCacheControlRulePosition | rule_create_params.SetCacheSettingsRulePosition + | rule_create_params.SetCacheTagsRulePosition | rule_create_params.SetConfigurationRulePosition | rule_create_params.SkipRulePosition | Omit = omit, @@ -4278,7 +4722,9 @@ async def create( | rule_create_params.RouteRuleRatelimit | rule_create_params.ScoreRuleRatelimit | rule_create_params.ServeErrorRuleRatelimit + | rule_create_params.SetCacheControlRuleRatelimit | rule_create_params.SetCacheSettingsRuleRatelimit + | rule_create_params.SetCacheTagsRuleRatelimit | rule_create_params.SetConfigurationRuleRatelimit | rule_create_params.SkipRuleRatelimit | Omit = omit, @@ -5444,6 +5890,76 @@ async def edit( """ ... + @overload + async def edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | Omit = omit, + zone_id: str | Omit = omit, + id: str | Omit = omit, + action: Literal["set_cache_control"] | Omit = omit, + action_parameters: rule_edit_params.SetCacheControlRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.SetCacheControlRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.SetCacheControlRulePosition | Omit = omit, + ratelimit: rule_edit_params.SetCacheControlRuleRatelimit | Omit = omit, + ref: str | Omit = omit, + # 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + 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 + """ + ... + @overload async def edit( self, @@ -5514,6 +6030,76 @@ async def edit( """ ... + @overload + async def edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | Omit = omit, + zone_id: str | Omit = omit, + id: str | Omit = omit, + action: Literal["set_cache_tags"] | Omit = omit, + action_parameters: rule_edit_params.SetCacheTagsRuleActionParameters | Omit = omit, + description: str | Omit = omit, + enabled: bool | Omit = omit, + exposed_credential_check: rule_edit_params.SetCacheTagsRuleExposedCredentialCheck | Omit = omit, + expression: str | Omit = omit, + logging: LoggingParam | Omit = omit, + position: rule_edit_params.SetCacheTagsRulePosition | Omit = omit, + ratelimit: rule_edit_params.SetCacheTagsRuleRatelimit | Omit = omit, + ref: str | Omit = omit, + # 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, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + exposed_credential_check: Configuration for exposed credential checking. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + position: An object configuring where the rule will be placed. + + ratelimit: An object configuring the rule's rate limit behavior. + + ref: The reference of the rule (the rule's ID by default). + + 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 + """ + ... + @overload async def edit( self, @@ -5678,7 +6264,9 @@ async def edit( | Literal["route"] | Literal["score"] | Literal["serve_error"] + | Literal["set_cache_control"] | Literal["set_cache_settings"] + | Literal["set_cache_tags"] | Literal["set_config"] | Literal["skip"] | Omit = omit, @@ -5692,7 +6280,9 @@ async def edit( | rule_edit_params.RouteRuleActionParameters | rule_edit_params.ScoreRuleActionParameters | rule_edit_params.ServeErrorRuleActionParameters + | rule_edit_params.SetCacheControlRuleActionParameters | rule_edit_params.SetCacheSettingsRuleActionParameters + | rule_edit_params.SetCacheTagsRuleActionParameters | rule_edit_params.SetConfigurationRuleActionParameters | rule_edit_params.SkipRuleActionParameters | Omit = omit, @@ -5713,7 +6303,9 @@ async def edit( | rule_edit_params.RouteRuleExposedCredentialCheck | rule_edit_params.ScoreRuleExposedCredentialCheck | rule_edit_params.ServeErrorRuleExposedCredentialCheck + | rule_edit_params.SetCacheControlRuleExposedCredentialCheck | rule_edit_params.SetCacheSettingsRuleExposedCredentialCheck + | rule_edit_params.SetCacheTagsRuleExposedCredentialCheck | rule_edit_params.SetConfigurationRuleExposedCredentialCheck | rule_edit_params.SkipRuleExposedCredentialCheck | Omit = omit, @@ -5734,7 +6326,9 @@ async def edit( | rule_edit_params.RouteRulePosition | rule_edit_params.ScoreRulePosition | rule_edit_params.ServeErrorRulePosition + | rule_edit_params.SetCacheControlRulePosition | rule_edit_params.SetCacheSettingsRulePosition + | rule_edit_params.SetCacheTagsRulePosition | rule_edit_params.SetConfigurationRulePosition | rule_edit_params.SkipRulePosition | Omit = omit, @@ -5753,7 +6347,9 @@ async def edit( | rule_edit_params.RouteRuleRatelimit | rule_edit_params.ScoreRuleRatelimit | rule_edit_params.ServeErrorRuleRatelimit + | rule_edit_params.SetCacheControlRuleRatelimit | rule_edit_params.SetCacheSettingsRuleRatelimit + | rule_edit_params.SetCacheTagsRuleRatelimit | rule_edit_params.SetConfigurationRuleRatelimit | rule_edit_params.SkipRuleRatelimit | Omit = omit, diff --git a/src/cloudflare/resources/schema_validation/schemas.py b/src/cloudflare/resources/schema_validation/schemas.py index cd6e4a9fb30..22ed24d85c9 100644 --- a/src/cloudflare/resources/schema_validation/schemas.py +++ b/src/cloudflare/resources/schema_validation/schemas.py @@ -62,8 +62,10 @@ def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> PublicSchema: - """ - Upload a schema + """Uploads a new OpenAPI schema for API Shield schema validation. + + The schema + defines expected request/response formats for API endpoints. Args: zone_id: Identifier. @@ -123,7 +125,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncV4PagePaginationArray[PublicSchema]: """ - List all uploaded schemas + Lists all OpenAPI schemas uploaded to API Shield with pagination support. Args: zone_id: Identifier. @@ -179,8 +181,10 @@ def delete( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SchemaDeleteResponse: - """ - Delete a schema + """Permanently removes an uploaded OpenAPI schema from API Shield. + + Operations using + this schema will lose their validation rules. Args: zone_id: Identifier. @@ -225,7 +229,8 @@ def edit( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> PublicSchema: """ - Edit details of a schema to enable validation + Modifies an existing OpenAPI schema in API Shield, updating the validation rules + for associated API operations. Args: zone_id: Identifier. @@ -273,7 +278,8 @@ def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> PublicSchema: """ - Get details of a schema + Gets the contents and metadata of a specific OpenAPI schema uploaded to API + Shield. Args: zone_id: Identifier. @@ -343,8 +349,10 @@ async def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> PublicSchema: - """ - Upload a schema + """Uploads a new OpenAPI schema for API Shield schema validation. + + The schema + defines expected request/response formats for API endpoints. Args: zone_id: Identifier. @@ -404,7 +412,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[PublicSchema, AsyncV4PagePaginationArray[PublicSchema]]: """ - List all uploaded schemas + Lists all OpenAPI schemas uploaded to API Shield with pagination support. Args: zone_id: Identifier. @@ -460,8 +468,10 @@ async def delete( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SchemaDeleteResponse: - """ - Delete a schema + """Permanently removes an uploaded OpenAPI schema from API Shield. + + Operations using + this schema will lose their validation rules. Args: zone_id: Identifier. @@ -506,7 +516,8 @@ async def edit( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> PublicSchema: """ - Edit details of a schema to enable validation + Modifies an existing OpenAPI schema in API Shield, updating the validation rules + for associated API operations. Args: zone_id: Identifier. @@ -556,7 +567,8 @@ async def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> PublicSchema: """ - Get details of a schema + Gets the contents and metadata of a specific OpenAPI schema uploaded to API + Shield. Args: zone_id: Identifier. diff --git a/src/cloudflare/resources/schema_validation/settings/operations.py b/src/cloudflare/resources/schema_validation/settings/operations.py index 1212c275f42..7d0f9568591 100644 --- a/src/cloudflare/resources/schema_validation/settings/operations.py +++ b/src/cloudflare/resources/schema_validation/settings/operations.py @@ -68,7 +68,7 @@ def update( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> OperationUpdateResponse: """ - Update per-operation schema validation setting + Fully updates schema validation settings for a specific API operation. Args: zone_id: Identifier. @@ -125,7 +125,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncV4PagePaginationArray[OperationListResponse]: """ - List per-operation schema validation settings + Lists all per-operation schema validation settings configured for the zone. Args: zone_id: Identifier. @@ -176,7 +176,8 @@ def delete( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> OperationDeleteResponse: """ - Delete per-operation schema validation setting + Removes custom schema validation settings for a specific API operation, + reverting to zone-level defaults. Args: zone_id: Identifier. @@ -220,7 +221,8 @@ def bulk_edit( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> OperationBulkEditResponse: """ - Bulk edit per-operation schema validation settings + Updates schema validation settings for multiple API operations in a single + request. Efficient for applying consistent validation rules across endpoints. Args: zone_id: Identifier. @@ -261,7 +263,8 @@ def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> OperationGetResponse: """ - Get per-operation schema validation setting + Retrieves the schema validation settings configured for a specific API + operation. Args: zone_id: Identifier. @@ -327,7 +330,7 @@ async def update( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> OperationUpdateResponse: """ - Update per-operation schema validation setting + Fully updates schema validation settings for a specific API operation. Args: zone_id: Identifier. @@ -384,7 +387,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[OperationListResponse, AsyncV4PagePaginationArray[OperationListResponse]]: """ - List per-operation schema validation settings + Lists all per-operation schema validation settings configured for the zone. Args: zone_id: Identifier. @@ -435,7 +438,8 @@ async def delete( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> OperationDeleteResponse: """ - Delete per-operation schema validation setting + Removes custom schema validation settings for a specific API operation, + reverting to zone-level defaults. Args: zone_id: Identifier. @@ -479,7 +483,8 @@ async def bulk_edit( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> OperationBulkEditResponse: """ - Bulk edit per-operation schema validation settings + Updates schema validation settings for multiple API operations in a single + request. Efficient for applying consistent validation rules across endpoints. Args: zone_id: Identifier. @@ -520,7 +525,8 @@ async def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> OperationGetResponse: """ - Get per-operation schema validation setting + Retrieves the schema validation settings configured for a specific API + operation. Args: zone_id: Identifier. diff --git a/src/cloudflare/resources/schema_validation/settings/settings.py b/src/cloudflare/resources/schema_validation/settings/settings.py index 82b061c1624..fad14610c3a 100644 --- a/src/cloudflare/resources/schema_validation/settings/settings.py +++ b/src/cloudflare/resources/schema_validation/settings/settings.py @@ -73,7 +73,8 @@ def update( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SettingUpdateResponse: """ - Update global schema validation settings + Fully updates global schema validation settings for a zone, replacing existing + configuration. Args: zone_id: Identifier. @@ -133,7 +134,8 @@ def edit( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SettingEditResponse: """ - Edit global schema validation settings + Partially updates global schema validation settings for a zone using PATCH + semantics. Args: zone_id: Identifier. @@ -191,7 +193,7 @@ def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SettingGetResponse: """ - Get global schema validation settings + Retrieves the current global schema validation settings for a zone. Args: zone_id: Identifier. @@ -257,7 +259,8 @@ async def update( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SettingUpdateResponse: """ - Update global schema validation settings + Fully updates global schema validation settings for a zone, replacing existing + configuration. Args: zone_id: Identifier. @@ -317,7 +320,8 @@ async def edit( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SettingEditResponse: """ - Edit global schema validation settings + Partially updates global schema validation settings for a zone using PATCH + semantics. Args: zone_id: Identifier. @@ -375,7 +379,7 @@ async def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SettingGetResponse: """ - Get global schema validation settings + Retrieves the current global schema validation settings for a zone. Args: zone_id: Identifier. diff --git a/src/cloudflare/resources/speed/schedule.py b/src/cloudflare/resources/speed/schedule.py index 6c822983901..eb8e477807e 100644 --- a/src/cloudflare/resources/speed/schedule.py +++ b/src/cloudflare/resources/speed/schedule.py @@ -52,6 +52,7 @@ def create( url: str, *, zone_id: str, + frequency: Literal["DAILY", "WEEKLY"] | Omit = omit, region: Literal[ "asia-east1", "asia-northeast1", @@ -91,6 +92,9 @@ def create( url: A URL. + frequency: The frequency of the scheduled test. Defaults to WEEKLY for free plans, DAILY + for paid plans. + region: A test region. extra_headers: Send extra headers @@ -112,7 +116,13 @@ def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - query=maybe_transform({"region": region}, schedule_create_params.ScheduleCreateParams), + query=maybe_transform( + { + "frequency": frequency, + "region": region, + }, + schedule_create_params.ScheduleCreateParams, + ), post_parser=ResultWrapper[Optional[ScheduleCreateResponse]]._unwrapper, ), cast_to=cast(Type[Optional[ScheduleCreateResponse]], ResultWrapper[ScheduleCreateResponse]), @@ -286,6 +296,7 @@ async def create( url: str, *, zone_id: str, + frequency: Literal["DAILY", "WEEKLY"] | Omit = omit, region: Literal[ "asia-east1", "asia-northeast1", @@ -325,6 +336,9 @@ async def create( url: A URL. + frequency: The frequency of the scheduled test. Defaults to WEEKLY for free plans, DAILY + for paid plans. + region: A test region. extra_headers: Send extra headers @@ -346,7 +360,13 @@ async def create( extra_query=extra_query, extra_body=extra_body, timeout=timeout, - query=await async_maybe_transform({"region": region}, schedule_create_params.ScheduleCreateParams), + query=await async_maybe_transform( + { + "frequency": frequency, + "region": region, + }, + schedule_create_params.ScheduleCreateParams, + ), post_parser=ResultWrapper[Optional[ScheduleCreateResponse]]._unwrapper, ), cast_to=cast(Type[Optional[ScheduleCreateResponse]], ResultWrapper[ScheduleCreateResponse]), diff --git a/src/cloudflare/resources/workers/scripts/versions.py b/src/cloudflare/resources/workers/scripts/versions.py index bb39678aaa4..3c8f95ecbc1 100644 --- a/src/cloudflare/resources/workers/scripts/versions.py +++ b/src/cloudflare/resources/workers/scripts/versions.py @@ -215,7 +215,7 @@ def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> VersionGetResponse: """ - Get Version Detail + Retrieves detailed information about a specific version of a Workers script. Args: account_id: Identifier. @@ -425,7 +425,7 @@ async def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> VersionGetResponse: """ - Get Version Detail + Retrieves detailed information about a specific version of a Workers script. Args: account_id: Identifier. diff --git a/src/cloudflare/resources/workflows/instances/events.py b/src/cloudflare/resources/workflows/instances/events.py index 6c8885c538a..1509e234b2b 100644 --- a/src/cloudflare/resources/workflows/instances/events.py +++ b/src/cloudflare/resources/workflows/instances/events.py @@ -59,7 +59,7 @@ def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> object: """ - Send event to instance + Sends an event to a running workflow instance to trigger state transitions. Args: extra_headers: Send extra headers @@ -128,7 +128,7 @@ async def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> object: """ - Send event to instance + Sends an event to a running workflow instance to trigger state transitions. Args: extra_headers: Send extra headers diff --git a/src/cloudflare/resources/workflows/instances/instances.py b/src/cloudflare/resources/workflows/instances/instances.py index 7ce3dfdeb52..46a72edc33c 100644 --- a/src/cloudflare/resources/workflows/instances/instances.py +++ b/src/cloudflare/resources/workflows/instances/instances.py @@ -37,7 +37,7 @@ from ...._wrappers import ResultWrapper from ....pagination import SyncSinglePage, AsyncSinglePage, SyncV4PagePaginationArray, AsyncV4PagePaginationArray from ...._base_client import AsyncPaginator, make_request_options -from ....types.workflows import instance_bulk_params, instance_list_params, instance_create_params +from ....types.workflows import instance_get_params, instance_bulk_params, instance_list_params, instance_create_params from ....types.workflows.instance_get_response import InstanceGetResponse from ....types.workflows.instance_bulk_response import InstanceBulkResponse from ....types.workflows.instance_list_response import InstanceListResponse @@ -90,7 +90,7 @@ def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> InstanceCreateResponse: """ - Create a new workflow instance + Creates a new instance of a workflow, starting its execution. Args: extra_headers: Send extra headers @@ -148,7 +148,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncV4PagePaginationArray[InstanceListResponse]: """ - List of workflow instances + Lists all instances of a workflow with their execution status. Args: cursor: `page` and `cursor` are mutually exclusive, use one or the other. @@ -212,7 +212,7 @@ def bulk( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncSinglePage[InstanceBulkResponse]: """ - Batch create new Workflow instances + Creates multiple workflow instances in a single batch operation. Args: extra_headers: Send extra headers @@ -244,6 +244,8 @@ def get( *, account_id: str, workflow_name: str, + order: Literal["asc", "desc"] | Omit = omit, + simple: Literal["true", "false"] | Omit = omit, # 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, @@ -252,9 +254,13 @@ def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> InstanceGetResponse: """ - Get logs and status from instance + Retrieves logs and execution status for a specific workflow instance. Args: + order: Step ordering: "asc" (default, oldest first) or "desc" (newest first). + + simple: When true, omits step details and returns only metadata with step_count. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -276,6 +282,13 @@ def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, + query=maybe_transform( + { + "order": order, + "simple": simple, + }, + instance_get_params.InstanceGetParams, + ), post_parser=ResultWrapper[InstanceGetResponse]._unwrapper, ), cast_to=cast(Type[InstanceGetResponse], ResultWrapper[InstanceGetResponse]), @@ -326,7 +339,7 @@ async def create( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> InstanceCreateResponse: """ - Create a new workflow instance + Creates a new instance of a workflow, starting its execution. Args: extra_headers: Send extra headers @@ -384,7 +397,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[InstanceListResponse, AsyncV4PagePaginationArray[InstanceListResponse]]: """ - List of workflow instances + Lists all instances of a workflow with their execution status. Args: cursor: `page` and `cursor` are mutually exclusive, use one or the other. @@ -448,7 +461,7 @@ def bulk( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[InstanceBulkResponse, AsyncSinglePage[InstanceBulkResponse]]: """ - Batch create new Workflow instances + Creates multiple workflow instances in a single batch operation. Args: extra_headers: Send extra headers @@ -480,6 +493,8 @@ async def get( *, account_id: str, workflow_name: str, + order: Literal["asc", "desc"] | Omit = omit, + simple: Literal["true", "false"] | Omit = omit, # 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, @@ -488,9 +503,13 @@ async def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> InstanceGetResponse: """ - Get logs and status from instance + Retrieves logs and execution status for a specific workflow instance. Args: + order: Step ordering: "asc" (default, oldest first) or "desc" (newest first). + + simple: When true, omits step details and returns only metadata with step_count. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -512,6 +531,13 @@ async def get( extra_query=extra_query, extra_body=extra_body, timeout=timeout, + query=await async_maybe_transform( + { + "order": order, + "simple": simple, + }, + instance_get_params.InstanceGetParams, + ), post_parser=ResultWrapper[InstanceGetResponse]._unwrapper, ), cast_to=cast(Type[InstanceGetResponse], ResultWrapper[InstanceGetResponse]), diff --git a/src/cloudflare/resources/workflows/instances/status.py b/src/cloudflare/resources/workflows/instances/status.py index 462b4c4be21..3b23b17a5bc 100644 --- a/src/cloudflare/resources/workflows/instances/status.py +++ b/src/cloudflare/resources/workflows/instances/status.py @@ -60,7 +60,8 @@ def edit( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> StatusEditResponse: """ - Change status of instance + Changes the execution status of a workflow instance (e.g., pause, resume, + terminate). Args: status: Apply action to instance. @@ -128,7 +129,8 @@ async def edit( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> StatusEditResponse: """ - Change status of instance + Changes the execution status of a workflow instance (e.g., pause, resume, + terminate). Args: status: Apply action to instance. diff --git a/src/cloudflare/resources/workflows/versions.py b/src/cloudflare/resources/workflows/versions.py index 6a965a68a7e..2a683b3a473 100644 --- a/src/cloudflare/resources/workflows/versions.py +++ b/src/cloudflare/resources/workflows/versions.py @@ -61,7 +61,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncV4PagePaginationArray[VersionListResponse]: """ - List deployed Workflow versions + Lists all deployed versions of a workflow. Args: extra_headers: Send extra headers @@ -109,7 +109,7 @@ def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> VersionGetResponse: """ - Get Workflow version details + Retrieves details for a specific deployed workflow version. Args: extra_headers: Send extra headers @@ -174,7 +174,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[VersionListResponse, AsyncV4PagePaginationArray[VersionListResponse]]: """ - List deployed Workflow versions + Lists all deployed versions of a workflow. Args: extra_headers: Send extra headers @@ -222,7 +222,7 @@ async def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> VersionGetResponse: """ - Get Workflow version details + Retrieves details for a specific deployed workflow version. Args: extra_headers: Send extra headers diff --git a/src/cloudflare/resources/workflows/workflows.py b/src/cloudflare/resources/workflows/workflows.py index 8d7d5fba510..049fdee3dd5 100644 --- a/src/cloudflare/resources/workflows/workflows.py +++ b/src/cloudflare/resources/workflows/workflows.py @@ -79,6 +79,7 @@ def update( account_id: str, class_name: str, script_name: str, + limits: workflow_update_params.Limits | Omit = omit, # 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, @@ -87,7 +88,7 @@ def update( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> WorkflowUpdateResponse: """ - Create/modify Workflow + Creates a new workflow or updates an existing workflow definition. Args: extra_headers: Send extra headers @@ -108,6 +109,7 @@ def update( { "class_name": class_name, "script_name": script_name, + "limits": limits, }, workflow_update_params.WorkflowUpdateParams, ), @@ -136,7 +138,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> SyncV4PagePaginationArray[WorkflowListResponse]: """ - List all Workflows + Lists all workflows configured for the account. Args: search: Allows filtering workflows` name. @@ -226,7 +228,7 @@ def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> WorkflowGetResponse: """ - Get Workflow details + Retrieves configuration and metadata for a specific workflow. Args: extra_headers: Send extra headers @@ -289,6 +291,7 @@ async def update( account_id: str, class_name: str, script_name: str, + limits: workflow_update_params.Limits | Omit = omit, # 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, @@ -297,7 +300,7 @@ async def update( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> WorkflowUpdateResponse: """ - Create/modify Workflow + Creates a new workflow or updates an existing workflow definition. Args: extra_headers: Send extra headers @@ -318,6 +321,7 @@ async def update( { "class_name": class_name, "script_name": script_name, + "limits": limits, }, workflow_update_params.WorkflowUpdateParams, ), @@ -346,7 +350,7 @@ def list( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> AsyncPaginator[WorkflowListResponse, AsyncV4PagePaginationArray[WorkflowListResponse]]: """ - List all Workflows + Lists all workflows configured for the account. Args: search: Allows filtering workflows` name. @@ -436,7 +440,7 @@ async def get( timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> WorkflowGetResponse: """ - Get Workflow details + Retrieves configuration and metadata for a specific workflow. Args: extra_headers: Send extra headers diff --git a/src/cloudflare/resources/zero_trust/dlp/profiles/custom.py b/src/cloudflare/resources/zero_trust/dlp/profiles/custom.py index 586ccceee16..e7c0036747e 100644 --- a/src/cloudflare/resources/zero_trust/dlp/profiles/custom.py +++ b/src/cloudflare/resources/zero_trust/dlp/profiles/custom.py @@ -6,7 +6,7 @@ import httpx -from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ....._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given from ....._utils import maybe_transform, async_maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource @@ -54,9 +54,12 @@ def create( allowed_match_count: int | Omit = omit, confidence_threshold: Optional[str] | Omit = omit, context_awareness: ContextAwarenessParam | Omit = omit, + data_classes: SequenceNotStr[str] | Omit = omit, + data_tags: SequenceNotStr[str] | Omit = omit, description: Optional[str] | Omit = omit, entries: Iterable[custom_create_params.Entry] | Omit = omit, ocr_enabled: bool | Omit = omit, + sensitivity_levels: Iterable[SequenceNotStr[str]] | Omit = omit, shared_entries: Iterable[custom_create_params.SharedEntry] | Omit = omit, # 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. @@ -74,8 +77,14 @@ def create( context_awareness: Scan the context of predefined entries to only return matches surrounded by keywords. + data_classes: Data class IDs to associate with the profile. + + data_tags: Data tag IDs to associate with the profile. + description: The description of the profile. + sensitivity_levels: Sensitivity levels to associate with the profile as (group_id, level_id) tuples. + shared_entries: Entries from other profiles (e.g. pre-defined Cloudflare profiles, or your Microsoft Information Protection profiles). @@ -100,9 +109,12 @@ def create( "allowed_match_count": allowed_match_count, "confidence_threshold": confidence_threshold, "context_awareness": context_awareness, + "data_classes": data_classes, + "data_tags": data_tags, "description": description, "entries": entries, "ocr_enabled": ocr_enabled, + "sensitivity_levels": sensitivity_levels, "shared_entries": shared_entries, }, custom_create_params.CustomCreateParams, @@ -130,9 +142,12 @@ def update( allowed_match_count: Optional[int] | Omit = omit, confidence_threshold: Optional[str] | Omit = omit, context_awareness: ContextAwarenessParam | Omit = omit, + data_classes: Optional[SequenceNotStr[str]] | Omit = omit, + data_tags: Optional[SequenceNotStr[str]] | Omit = omit, description: Optional[str] | Omit = omit, entries: Optional[Iterable[custom_update_params.Entry]] | Omit = omit, ocr_enabled: bool | Omit = omit, + sensitivity_levels: Optional[Iterable[SequenceNotStr[str]]] | Omit = omit, shared_entries: Iterable[custom_update_params.SharedEntry] | Omit = omit, # 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. @@ -148,11 +163,20 @@ def update( context_awareness: Scan the context of predefined entries to only return matches surrounded by keywords. + data_classes: Data class IDs to associate with the profile. If omitted, existing associations + are unchanged. + + data_tags: Data tag IDs to associate with the profile. If omitted, existing associations + are unchanged. + description: The description of the profile. entries: Custom entries from this profile. If this field is omitted, entries owned by this profile will not be changed. + sensitivity_levels: Sensitivity levels to associate with the profile. If omitted, existing + associations are unchanged. + shared_entries: Other entries, e.g. predefined or integration. extra_headers: Send extra headers @@ -178,9 +202,12 @@ def update( "allowed_match_count": allowed_match_count, "confidence_threshold": confidence_threshold, "context_awareness": context_awareness, + "data_classes": data_classes, + "data_tags": data_tags, "description": description, "entries": entries, "ocr_enabled": ocr_enabled, + "sensitivity_levels": sensitivity_levels, "shared_entries": shared_entries, }, custom_update_params.CustomUpdateParams, @@ -313,9 +340,12 @@ async def create( allowed_match_count: int | Omit = omit, confidence_threshold: Optional[str] | Omit = omit, context_awareness: ContextAwarenessParam | Omit = omit, + data_classes: SequenceNotStr[str] | Omit = omit, + data_tags: SequenceNotStr[str] | Omit = omit, description: Optional[str] | Omit = omit, entries: Iterable[custom_create_params.Entry] | Omit = omit, ocr_enabled: bool | Omit = omit, + sensitivity_levels: Iterable[SequenceNotStr[str]] | Omit = omit, shared_entries: Iterable[custom_create_params.SharedEntry] | Omit = omit, # 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. @@ -333,8 +363,14 @@ async def create( context_awareness: Scan the context of predefined entries to only return matches surrounded by keywords. + data_classes: Data class IDs to associate with the profile. + + data_tags: Data tag IDs to associate with the profile. + description: The description of the profile. + sensitivity_levels: Sensitivity levels to associate with the profile as (group_id, level_id) tuples. + shared_entries: Entries from other profiles (e.g. pre-defined Cloudflare profiles, or your Microsoft Information Protection profiles). @@ -359,9 +395,12 @@ async def create( "allowed_match_count": allowed_match_count, "confidence_threshold": confidence_threshold, "context_awareness": context_awareness, + "data_classes": data_classes, + "data_tags": data_tags, "description": description, "entries": entries, "ocr_enabled": ocr_enabled, + "sensitivity_levels": sensitivity_levels, "shared_entries": shared_entries, }, custom_create_params.CustomCreateParams, @@ -389,9 +428,12 @@ async def update( allowed_match_count: Optional[int] | Omit = omit, confidence_threshold: Optional[str] | Omit = omit, context_awareness: ContextAwarenessParam | Omit = omit, + data_classes: Optional[SequenceNotStr[str]] | Omit = omit, + data_tags: Optional[SequenceNotStr[str]] | Omit = omit, description: Optional[str] | Omit = omit, entries: Optional[Iterable[custom_update_params.Entry]] | Omit = omit, ocr_enabled: bool | Omit = omit, + sensitivity_levels: Optional[Iterable[SequenceNotStr[str]]] | Omit = omit, shared_entries: Iterable[custom_update_params.SharedEntry] | Omit = omit, # 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. @@ -407,11 +449,20 @@ async def update( context_awareness: Scan the context of predefined entries to only return matches surrounded by keywords. + data_classes: Data class IDs to associate with the profile. If omitted, existing associations + are unchanged. + + data_tags: Data tag IDs to associate with the profile. If omitted, existing associations + are unchanged. + description: The description of the profile. entries: Custom entries from this profile. If this field is omitted, entries owned by this profile will not be changed. + sensitivity_levels: Sensitivity levels to associate with the profile. If omitted, existing + associations are unchanged. + shared_entries: Other entries, e.g. predefined or integration. extra_headers: Send extra headers @@ -437,9 +488,12 @@ async def update( "allowed_match_count": allowed_match_count, "confidence_threshold": confidence_threshold, "context_awareness": context_awareness, + "data_classes": data_classes, + "data_tags": data_tags, "description": description, "entries": entries, "ocr_enabled": ocr_enabled, + "sensitivity_levels": sensitivity_levels, "shared_entries": shared_entries, }, custom_update_params.CustomUpdateParams, diff --git a/src/cloudflare/types/abuse_reports/abuse_report_create_params.py b/src/cloudflare/types/abuse_reports/abuse_report_create_params.py index 9d6ae29ffc0..b004cdd1a1c 100644 --- a/src/cloudflare/types/abuse_reports/abuse_report_create_params.py +++ b/src/cloudflare/types/abuse_reports/abuse_report_create_params.py @@ -262,7 +262,7 @@ class AbuseReportsGeneralReport(TypedDict, total=False): Database (https://lumendatabase.org/). """ - owner_notification: Required[Literal["send", "send-anon", "none"]] + owner_notification: Required[Literal["send", "send-anon"]] """Notification type based on the abuse type. NOTE: Copyright (DMCA) and Trademark reports cannot be anonymous. diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_create_params.py b/src/cloudflare/types/ai_gateway/ai_gateway_create_params.py index be112a797dc..213071208f8 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_create_params.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_create_params.py @@ -28,8 +28,6 @@ class AIGatewayCreateParams(TypedDict, total=False): authentication: bool - is_default: bool - log_management: Optional[int] log_management_strategy: Optional[Literal["STOP_INSERTING", "DELETE_OLDEST"]] @@ -38,4 +36,7 @@ class AIGatewayCreateParams(TypedDict, total=False): logpush_public_key: Optional[str] + workers_ai_billing_mode: Literal["postpaid", "unified"] + """Controls how Workers AI inference calls routed through this gateway are billed""" + zdr: bool diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_create_response.py b/src/cloudflare/types/ai_gateway/ai_gateway_create_response.py index 690cf4b30d1..d4c88925c6f 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_create_response.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_create_response.py @@ -54,6 +54,8 @@ class Otel(BaseModel): url: str + content_type: Optional[Literal["json", "protobuf"]] = None + class StripeUsageEvent(BaseModel): payload: str @@ -69,10 +71,6 @@ class AIGatewayCreateResponse(BaseModel): id: str """gateway id""" - account_id: str - - account_tag: str - cache_invalidate_on_update: bool cache_ttl: Optional[int] = None @@ -81,8 +79,6 @@ class AIGatewayCreateResponse(BaseModel): created_at: datetime - internal_id: str - modified_at: datetime rate_limiting_interval: Optional[int] = None @@ -111,4 +107,7 @@ class AIGatewayCreateResponse(BaseModel): stripe: Optional[Stripe] = None + workers_ai_billing_mode: Optional[Literal["postpaid", "unified"]] = None + """Controls how Workers AI inference calls routed through this gateway are billed""" + zdr: Optional[bool] = None diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_delete_response.py b/src/cloudflare/types/ai_gateway/ai_gateway_delete_response.py index 3575a8d62ad..9a38af08300 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_delete_response.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_delete_response.py @@ -54,6 +54,8 @@ class Otel(BaseModel): url: str + content_type: Optional[Literal["json", "protobuf"]] = None + class StripeUsageEvent(BaseModel): payload: str @@ -69,10 +71,6 @@ class AIGatewayDeleteResponse(BaseModel): id: str """gateway id""" - account_id: str - - account_tag: str - cache_invalidate_on_update: bool cache_ttl: Optional[int] = None @@ -81,8 +79,6 @@ class AIGatewayDeleteResponse(BaseModel): created_at: datetime - internal_id: str - modified_at: datetime rate_limiting_interval: Optional[int] = None @@ -111,4 +107,7 @@ class AIGatewayDeleteResponse(BaseModel): stripe: Optional[Stripe] = None + workers_ai_billing_mode: Optional[Literal["postpaid", "unified"]] = None + """Controls how Workers AI inference calls routed through this gateway are billed""" + zdr: Optional[bool] = None diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_get_response.py b/src/cloudflare/types/ai_gateway/ai_gateway_get_response.py index ad13af400f9..866ec00a7cd 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_get_response.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_get_response.py @@ -54,6 +54,8 @@ class Otel(BaseModel): url: str + content_type: Optional[Literal["json", "protobuf"]] = None + class StripeUsageEvent(BaseModel): payload: str @@ -69,10 +71,6 @@ class AIGatewayGetResponse(BaseModel): id: str """gateway id""" - account_id: str - - account_tag: str - cache_invalidate_on_update: bool cache_ttl: Optional[int] = None @@ -81,8 +79,6 @@ class AIGatewayGetResponse(BaseModel): created_at: datetime - internal_id: str - modified_at: datetime rate_limiting_interval: Optional[int] = None @@ -111,4 +107,7 @@ class AIGatewayGetResponse(BaseModel): stripe: Optional[Stripe] = None + workers_ai_billing_mode: Optional[Literal["postpaid", "unified"]] = None + """Controls how Workers AI inference calls routed through this gateway are billed""" + zdr: Optional[bool] = None diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_list_response.py b/src/cloudflare/types/ai_gateway/ai_gateway_list_response.py index 99681cb27c7..17e5fa98cbc 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_list_response.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_list_response.py @@ -54,6 +54,8 @@ class Otel(BaseModel): url: str + content_type: Optional[Literal["json", "protobuf"]] = None + class StripeUsageEvent(BaseModel): payload: str @@ -69,10 +71,6 @@ class AIGatewayListResponse(BaseModel): id: str """gateway id""" - account_id: str - - account_tag: str - cache_invalidate_on_update: bool cache_ttl: Optional[int] = None @@ -81,8 +79,6 @@ class AIGatewayListResponse(BaseModel): created_at: datetime - internal_id: str - modified_at: datetime rate_limiting_interval: Optional[int] = None @@ -111,4 +107,7 @@ class AIGatewayListResponse(BaseModel): stripe: Optional[Stripe] = None + workers_ai_billing_mode: Optional[Literal["postpaid", "unified"]] = None + """Controls how Workers AI inference calls routed through this gateway are billed""" + zdr: Optional[bool] = None diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_update_params.py b/src/cloudflare/types/ai_gateway/ai_gateway_update_params.py index b59349236ae..9ab63b83479 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_update_params.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_update_params.py @@ -38,8 +38,6 @@ class AIGatewayUpdateParams(TypedDict, total=False): dlp: DLP - is_default: bool - log_management: Optional[int] log_management_strategy: Optional[Literal["STOP_INSERTING", "DELETE_OLDEST"]] @@ -54,6 +52,9 @@ class AIGatewayUpdateParams(TypedDict, total=False): stripe: Optional[Stripe] + workers_ai_billing_mode: Literal["postpaid", "unified"] + """Controls how Workers AI inference calls routed through this gateway are billed""" + zdr: bool @@ -93,6 +94,8 @@ class Otel(TypedDict, total=False): url: Required[str] + content_type: Literal["json", "protobuf"] + class StripeUsageEvent(TypedDict, total=False): payload: Required[str] diff --git a/src/cloudflare/types/ai_gateway/ai_gateway_update_response.py b/src/cloudflare/types/ai_gateway/ai_gateway_update_response.py index 6250e1cc8ba..69cf2d1702e 100644 --- a/src/cloudflare/types/ai_gateway/ai_gateway_update_response.py +++ b/src/cloudflare/types/ai_gateway/ai_gateway_update_response.py @@ -54,6 +54,8 @@ class Otel(BaseModel): url: str + content_type: Optional[Literal["json", "protobuf"]] = None + class StripeUsageEvent(BaseModel): payload: str @@ -69,10 +71,6 @@ class AIGatewayUpdateResponse(BaseModel): id: str """gateway id""" - account_id: str - - account_tag: str - cache_invalidate_on_update: bool cache_ttl: Optional[int] = None @@ -81,8 +79,6 @@ class AIGatewayUpdateResponse(BaseModel): created_at: datetime - internal_id: str - modified_at: datetime rate_limiting_interval: Optional[int] = None @@ -111,4 +107,7 @@ class AIGatewayUpdateResponse(BaseModel): stripe: Optional[Stripe] = None + workers_ai_billing_mode: Optional[Literal["postpaid", "unified"]] = None + """Controls how Workers AI inference calls routed through this gateway are billed""" + zdr: Optional[bool] = None diff --git a/src/cloudflare/types/ai_gateway/dataset_create_response.py b/src/cloudflare/types/ai_gateway/dataset_create_response.py index 5be90be4a14..806584ab12e 100644 --- a/src/cloudflare/types/ai_gateway/dataset_create_response.py +++ b/src/cloudflare/types/ai_gateway/dataset_create_response.py @@ -34,10 +34,6 @@ class Filter(BaseModel): class DatasetCreateResponse(BaseModel): id: str - account_id: str - - account_tag: str - created_at: datetime enable: bool diff --git a/src/cloudflare/types/ai_gateway/dataset_delete_response.py b/src/cloudflare/types/ai_gateway/dataset_delete_response.py index 9b9ede756f2..b097128ba3c 100644 --- a/src/cloudflare/types/ai_gateway/dataset_delete_response.py +++ b/src/cloudflare/types/ai_gateway/dataset_delete_response.py @@ -34,10 +34,6 @@ class Filter(BaseModel): class DatasetDeleteResponse(BaseModel): id: str - account_id: str - - account_tag: str - created_at: datetime enable: bool diff --git a/src/cloudflare/types/ai_gateway/dataset_get_response.py b/src/cloudflare/types/ai_gateway/dataset_get_response.py index 102c0cd1b49..1641c723f9e 100644 --- a/src/cloudflare/types/ai_gateway/dataset_get_response.py +++ b/src/cloudflare/types/ai_gateway/dataset_get_response.py @@ -34,10 +34,6 @@ class Filter(BaseModel): class DatasetGetResponse(BaseModel): id: str - account_id: str - - account_tag: str - created_at: datetime enable: bool diff --git a/src/cloudflare/types/ai_gateway/dataset_list_response.py b/src/cloudflare/types/ai_gateway/dataset_list_response.py index cf9d6e28bd3..710a48b322d 100644 --- a/src/cloudflare/types/ai_gateway/dataset_list_response.py +++ b/src/cloudflare/types/ai_gateway/dataset_list_response.py @@ -34,10 +34,6 @@ class Filter(BaseModel): class DatasetListResponse(BaseModel): id: str - account_id: str - - account_tag: str - created_at: datetime enable: bool diff --git a/src/cloudflare/types/ai_gateway/dataset_update_response.py b/src/cloudflare/types/ai_gateway/dataset_update_response.py index 2cfeca9e20c..a68021d1647 100644 --- a/src/cloudflare/types/ai_gateway/dataset_update_response.py +++ b/src/cloudflare/types/ai_gateway/dataset_update_response.py @@ -34,10 +34,6 @@ class Filter(BaseModel): class DatasetUpdateResponse(BaseModel): id: str - account_id: str - - account_tag: str - created_at: datetime enable: bool diff --git a/src/cloudflare/types/ai_gateway/dynamic_routing_create_deployment_response.py b/src/cloudflare/types/ai_gateway/dynamic_routing_create_deployment_response.py index 52f0bcbcfae..9952e6e63f5 100644 --- a/src/cloudflare/types/ai_gateway/dynamic_routing_create_deployment_response.py +++ b/src/cloudflare/types/ai_gateway/dynamic_routing_create_deployment_response.py @@ -185,8 +185,6 @@ class ElementUnionMember5(BaseModel): class DynamicRoutingCreateDeploymentResponse(BaseModel): id: str - account_tag: str - created_at: datetime elements: List[Element] diff --git a/src/cloudflare/types/ai_gateway/dynamic_routing_create_response.py b/src/cloudflare/types/ai_gateway/dynamic_routing_create_response.py index c474ddb8514..bd50d5adc66 100644 --- a/src/cloudflare/types/ai_gateway/dynamic_routing_create_response.py +++ b/src/cloudflare/types/ai_gateway/dynamic_routing_create_response.py @@ -209,8 +209,6 @@ class Version(BaseModel): class DynamicRoutingCreateResponse(BaseModel): id: str - account_tag: str - created_at: datetime deployment: Deployment diff --git a/src/cloudflare/types/ai_gateway/dynamic_routing_create_version_response.py b/src/cloudflare/types/ai_gateway/dynamic_routing_create_version_response.py index 7ceef2f3a58..737c0292956 100644 --- a/src/cloudflare/types/ai_gateway/dynamic_routing_create_version_response.py +++ b/src/cloudflare/types/ai_gateway/dynamic_routing_create_version_response.py @@ -185,8 +185,6 @@ class ElementUnionMember5(BaseModel): class DynamicRoutingCreateVersionResponse(BaseModel): id: str - account_tag: str - created_at: datetime elements: List[Element] diff --git a/src/cloudflare/types/ai_gateway/dynamic_routing_delete_response.py b/src/cloudflare/types/ai_gateway/dynamic_routing_delete_response.py index 32a4772e569..d57a51826a7 100644 --- a/src/cloudflare/types/ai_gateway/dynamic_routing_delete_response.py +++ b/src/cloudflare/types/ai_gateway/dynamic_routing_delete_response.py @@ -185,8 +185,6 @@ class ElementUnionMember5(BaseModel): class DynamicRoutingDeleteResponse(BaseModel): id: str - account_tag: str - created_at: datetime elements: List[Element] diff --git a/src/cloudflare/types/ai_gateway/dynamic_routing_get_response.py b/src/cloudflare/types/ai_gateway/dynamic_routing_get_response.py index d2641a522fb..ec592a02639 100644 --- a/src/cloudflare/types/ai_gateway/dynamic_routing_get_response.py +++ b/src/cloudflare/types/ai_gateway/dynamic_routing_get_response.py @@ -209,8 +209,6 @@ class Version(BaseModel): class DynamicRoutingGetResponse(BaseModel): id: str - account_tag: str - created_at: datetime deployment: Deployment diff --git a/src/cloudflare/types/ai_gateway/dynamic_routing_get_version_response.py b/src/cloudflare/types/ai_gateway/dynamic_routing_get_version_response.py index 649d4cf78e2..7770fb981cb 100644 --- a/src/cloudflare/types/ai_gateway/dynamic_routing_get_version_response.py +++ b/src/cloudflare/types/ai_gateway/dynamic_routing_get_version_response.py @@ -185,8 +185,6 @@ class ElementUnionMember5(BaseModel): class DynamicRoutingGetVersionResponse(BaseModel): id: str - account_tag: str - active: Literal["true", "false"] created_at: str diff --git a/src/cloudflare/types/ai_gateway/evaluation_create_response.py b/src/cloudflare/types/ai_gateway/evaluation_create_response.py index 40b1b09254b..cf8a74f977d 100644 --- a/src/cloudflare/types/ai_gateway/evaluation_create_response.py +++ b/src/cloudflare/types/ai_gateway/evaluation_create_response.py @@ -75,10 +75,6 @@ class Result(BaseModel): class EvaluationCreateResponse(BaseModel): id: str - account_id: str - - account_tag: str - created_at: datetime datasets: List[Dataset] diff --git a/src/cloudflare/types/ai_gateway/evaluation_delete_response.py b/src/cloudflare/types/ai_gateway/evaluation_delete_response.py index 163d4406dd6..b5a129bfe57 100644 --- a/src/cloudflare/types/ai_gateway/evaluation_delete_response.py +++ b/src/cloudflare/types/ai_gateway/evaluation_delete_response.py @@ -75,10 +75,6 @@ class Result(BaseModel): class EvaluationDeleteResponse(BaseModel): id: str - account_id: str - - account_tag: str - created_at: datetime datasets: List[Dataset] diff --git a/src/cloudflare/types/ai_gateway/evaluation_get_response.py b/src/cloudflare/types/ai_gateway/evaluation_get_response.py index 2ac71bd4a18..b5742ab63cf 100644 --- a/src/cloudflare/types/ai_gateway/evaluation_get_response.py +++ b/src/cloudflare/types/ai_gateway/evaluation_get_response.py @@ -75,10 +75,6 @@ class Result(BaseModel): class EvaluationGetResponse(BaseModel): id: str - account_id: str - - account_tag: str - created_at: datetime datasets: List[Dataset] diff --git a/src/cloudflare/types/ai_gateway/evaluation_list_response.py b/src/cloudflare/types/ai_gateway/evaluation_list_response.py index e40b09a38aa..055f50727c4 100644 --- a/src/cloudflare/types/ai_gateway/evaluation_list_response.py +++ b/src/cloudflare/types/ai_gateway/evaluation_list_response.py @@ -75,10 +75,6 @@ class Result(BaseModel): class EvaluationListResponse(BaseModel): id: str - account_id: str - - account_tag: str - created_at: datetime datasets: List[Dataset] diff --git a/src/cloudflare/types/ai_gateway/provider_config_create_response.py b/src/cloudflare/types/ai_gateway/provider_config_create_response.py index 7beec1a3a36..1b0a0bcf2c6 100644 --- a/src/cloudflare/types/ai_gateway/provider_config_create_response.py +++ b/src/cloudflare/types/ai_gateway/provider_config_create_response.py @@ -11,10 +11,6 @@ class ProviderConfigCreateResponse(BaseModel): id: str - account_id: str - - account_tag: str - alias: str default_config: bool diff --git a/src/cloudflare/types/ai_gateway/provider_config_list_response.py b/src/cloudflare/types/ai_gateway/provider_config_list_response.py index 6c2fa3aef29..2998e9f70fa 100644 --- a/src/cloudflare/types/ai_gateway/provider_config_list_response.py +++ b/src/cloudflare/types/ai_gateway/provider_config_list_response.py @@ -11,10 +11,6 @@ class ProviderConfigListResponse(BaseModel): id: str - account_id: str - - account_tag: str - alias: str default_config: bool diff --git a/src/cloudflare/types/aisearch/instance_chat_completions_params.py b/src/cloudflare/types/aisearch/instance_chat_completions_params.py index a60d3a9a458..47445b63283 100644 --- a/src/cloudflare/types/aisearch/instance_chat_completions_params.py +++ b/src/cloudflare/types/aisearch/instance_chat_completions_params.py @@ -14,6 +14,7 @@ "AISearchOptionsQueryRewrite", "AISearchOptionsReranking", "AISearchOptionsRetrieval", + "AISearchOptionsRetrievalBoostBy", ] @@ -112,7 +113,34 @@ class AISearchOptionsReranking(TypedDict, total=False): model: Literal["@cf/baai/bge-reranker-base", ""] +class AISearchOptionsRetrievalBoostBy(TypedDict, total=False): + field: Required[str] + """Metadata field name to boost by. + + Use 'timestamp' for document freshness, or any custom_metadata field. Numeric + fields support asc/desc directions; text/boolean fields support + exists/not_exists. + """ + + direction: Literal["asc", "desc", "exists", "not_exists"] + """Boost direction. + + 'desc' = higher values rank higher (e.g. newer timestamps). 'asc' = lower values + rank higher. 'exists' = boost chunks that have the field. 'not_exists' = boost + chunks that lack the field. Optional ��� defaults to 'asc' for numeric fields, + 'exists' for text/boolean fields. + """ + + class AISearchOptionsRetrieval(TypedDict, total=False): + boost_by: Iterable[AISearchOptionsRetrievalBoostBy] + """Metadata fields to boost search results by. + + Overrides the instance-level boost_by config. Direction defaults to 'asc' for + numeric fields, 'exists' for text/boolean fields. Fields must match 'timestamp' + or a defined custom_metadata field. + """ + context_expansion: int filters: Dict[str, object] diff --git a/src/cloudflare/types/aisearch/instance_create_params.py b/src/cloudflare/types/aisearch/instance_create_params.py index 19f94e53997..ed3f9e19263 100644 --- a/src/cloudflare/types/aisearch/instance_create_params.py +++ b/src/cloudflare/types/aisearch/instance_create_params.py @@ -19,9 +19,11 @@ "PublicEndpointParamsRateLimit", "PublicEndpointParamsSearchEndpoint", "RetrievalOptions", + "RetrievalOptionsBoostBy", "SourceParams", "SourceParamsWebCrawler", "SourceParamsWebCrawlerParseOptions", + "SourceParamsWebCrawlerParseOptionsContentSelector", "SourceParamsWebCrawlerStoreOptions", ] @@ -32,10 +34,6 @@ class InstanceCreateParams(TypedDict, total=False): id: Required[str] """Use your AI Search ID.""" - source: Required[str] - - type: Required[Literal["r2", "web-crawler"]] - ai_gateway_id: Optional[str] aisearch_model: Annotated[ @@ -72,6 +70,10 @@ class InstanceCreateParams(TypedDict, total=False): PropertyInfo(alias="ai_search_model"), ] + cache: bool + + cache_threshold: Literal["super_strict_match", "close_enough", "flexible_friend", "anything_goes"] + chunk: bool chunk_overlap: int @@ -142,10 +144,14 @@ class InstanceCreateParams(TypedDict, total=False): score_threshold: float + source: str + source_params: Optional[SourceParams] token_id: str + type: Literal["r2", "web-crawler"] + class CustomMetadata(TypedDict, total=False): data_type: Required[Literal["text", "number", "boolean"]] @@ -198,7 +204,34 @@ class PublicEndpointParams(TypedDict, total=False): search_endpoint: PublicEndpointParamsSearchEndpoint +class RetrievalOptionsBoostBy(TypedDict, total=False): + field: Required[str] + """Metadata field name to boost by. + + Use 'timestamp' for document freshness, or any custom_metadata field. Numeric + fields support asc/desc directions; text/boolean fields support + exists/not_exists. + """ + + direction: Literal["asc", "desc", "exists", "not_exists"] + """Boost direction. + + 'desc' = higher values rank higher (e.g. newer timestamps). 'asc' = lower values + rank higher. 'exists' = boost chunks that have the field. 'not_exists' = boost + chunks that lack the field. Optional ��� defaults to 'asc' for numeric fields, + 'exists' for text/boolean fields. + """ + + class RetrievalOptions(TypedDict, total=False): + boost_by: Iterable[RetrievalOptionsBoostBy] + """Metadata fields to boost search results by. + + Each entry specifies a metadata field and an optional direction. Direction + defaults to 'asc' for numeric fields and 'exists' for text/boolean fields. + Fields must match 'timestamp' or a defined custom_metadata field. + """ + keyword_match_mode: Literal["exact_match", "fuzzy_match"] """Controls how keyword search terms are matched. @@ -207,7 +240,30 @@ class RetrievalOptions(TypedDict, total=False): """ +class SourceParamsWebCrawlerParseOptionsContentSelector(TypedDict, total=False): + path: Required[str] + """Glob pattern to match against the page URL path. + + Uses standard glob syntax: \\** matches within a segment, \\**\\** crosses + directories. + """ + + selector: Required[str] + """CSS selector to extract content from pages matching the path pattern. + + Supports standard CSS selectors including class, ID, element, and attribute + selectors. + """ + + class SourceParamsWebCrawlerParseOptions(TypedDict, total=False): + content_selector: Iterable[SourceParamsWebCrawlerParseOptionsContentSelector] + """ + List of path-to-selector mappings for extracting specific content from crawled + pages. Each entry pairs a URL glob pattern with a CSS selector. The first + matching path wins. Only the matched HTML fragment is stored and indexed. + """ + include_headers: Dict[str, str] include_images: bool diff --git a/src/cloudflare/types/aisearch/instance_create_response.py b/src/cloudflare/types/aisearch/instance_create_response.py index 4a81cf1c492..8509a055875 100644 --- a/src/cloudflare/types/aisearch/instance_create_response.py +++ b/src/cloudflare/types/aisearch/instance_create_response.py @@ -19,9 +19,11 @@ "PublicEndpointParamsRateLimit", "PublicEndpointParamsSearchEndpoint", "RetrievalOptions", + "RetrievalOptionsBoostBy", "SourceParams", "SourceParamsWebCrawler", "SourceParamsWebCrawlerParseOptions", + "SourceParamsWebCrawlerParseOptionsContentSelector", "SourceParamsWebCrawlerStoreOptions", ] @@ -77,7 +79,34 @@ class PublicEndpointParams(BaseModel): search_endpoint: Optional[PublicEndpointParamsSearchEndpoint] = None +class RetrievalOptionsBoostBy(BaseModel): + field: str + """Metadata field name to boost by. + + Use 'timestamp' for document freshness, or any custom_metadata field. Numeric + fields support asc/desc directions; text/boolean fields support + exists/not_exists. + """ + + direction: Optional[Literal["asc", "desc", "exists", "not_exists"]] = None + """Boost direction. + + 'desc' = higher values rank higher (e.g. newer timestamps). 'asc' = lower values + rank higher. 'exists' = boost chunks that have the field. 'not_exists' = boost + chunks that lack the field. Optional ��� defaults to 'asc' for numeric fields, + 'exists' for text/boolean fields. + """ + + class RetrievalOptions(BaseModel): + boost_by: Optional[List[RetrievalOptionsBoostBy]] = None + """Metadata fields to boost search results by. + + Each entry specifies a metadata field and an optional direction. Direction + defaults to 'asc' for numeric fields and 'exists' for text/boolean fields. + Fields must match 'timestamp' or a defined custom_metadata field. + """ + keyword_match_mode: Optional[Literal["exact_match", "fuzzy_match"]] = None """Controls how keyword search terms are matched. @@ -86,7 +115,30 @@ class RetrievalOptions(BaseModel): """ +class SourceParamsWebCrawlerParseOptionsContentSelector(BaseModel): + path: str + """Glob pattern to match against the page URL path. + + Uses standard glob syntax: \\** matches within a segment, \\**\\** crosses + directories. + """ + + selector: str + """CSS selector to extract content from pages matching the path pattern. + + Supports standard CSS selectors including class, ID, element, and attribute + selectors. + """ + + class SourceParamsWebCrawlerParseOptions(BaseModel): + content_selector: Optional[List[SourceParamsWebCrawlerParseOptionsContentSelector]] = None + """ + List of path-to-selector mappings for extracting specific content from crawled + pages. Each entry pairs a URL glob pattern with a CSS selector. The first + matching path wins. Only the matched HTML fragment is stored and indexed. + """ + include_headers: Optional[Dict[str, str]] = None include_images: Optional[bool] = None @@ -147,10 +199,6 @@ class InstanceCreateResponse(BaseModel): modified_at: datetime - source: str - - type: Literal["r2", "web-crawler"] - vectorize_name: str ai_gateway_id: Optional[str] = None @@ -276,8 +324,12 @@ class InstanceCreateResponse(BaseModel): score_threshold: Optional[float] = None + source: Optional[str] = None + source_params: Optional[SourceParams] = None status: Optional[str] = None token_id: Optional[str] = None + + type: Optional[Literal["r2", "web-crawler"]] = None diff --git a/src/cloudflare/types/aisearch/instance_delete_response.py b/src/cloudflare/types/aisearch/instance_delete_response.py index 8c19423fa88..b12dd8839ec 100644 --- a/src/cloudflare/types/aisearch/instance_delete_response.py +++ b/src/cloudflare/types/aisearch/instance_delete_response.py @@ -19,9 +19,11 @@ "PublicEndpointParamsRateLimit", "PublicEndpointParamsSearchEndpoint", "RetrievalOptions", + "RetrievalOptionsBoostBy", "SourceParams", "SourceParamsWebCrawler", "SourceParamsWebCrawlerParseOptions", + "SourceParamsWebCrawlerParseOptionsContentSelector", "SourceParamsWebCrawlerStoreOptions", ] @@ -77,7 +79,34 @@ class PublicEndpointParams(BaseModel): search_endpoint: Optional[PublicEndpointParamsSearchEndpoint] = None +class RetrievalOptionsBoostBy(BaseModel): + field: str + """Metadata field name to boost by. + + Use 'timestamp' for document freshness, or any custom_metadata field. Numeric + fields support asc/desc directions; text/boolean fields support + exists/not_exists. + """ + + direction: Optional[Literal["asc", "desc", "exists", "not_exists"]] = None + """Boost direction. + + 'desc' = higher values rank higher (e.g. newer timestamps). 'asc' = lower values + rank higher. 'exists' = boost chunks that have the field. 'not_exists' = boost + chunks that lack the field. Optional ��� defaults to 'asc' for numeric fields, + 'exists' for text/boolean fields. + """ + + class RetrievalOptions(BaseModel): + boost_by: Optional[List[RetrievalOptionsBoostBy]] = None + """Metadata fields to boost search results by. + + Each entry specifies a metadata field and an optional direction. Direction + defaults to 'asc' for numeric fields and 'exists' for text/boolean fields. + Fields must match 'timestamp' or a defined custom_metadata field. + """ + keyword_match_mode: Optional[Literal["exact_match", "fuzzy_match"]] = None """Controls how keyword search terms are matched. @@ -86,7 +115,30 @@ class RetrievalOptions(BaseModel): """ +class SourceParamsWebCrawlerParseOptionsContentSelector(BaseModel): + path: str + """Glob pattern to match against the page URL path. + + Uses standard glob syntax: \\** matches within a segment, \\**\\** crosses + directories. + """ + + selector: str + """CSS selector to extract content from pages matching the path pattern. + + Supports standard CSS selectors including class, ID, element, and attribute + selectors. + """ + + class SourceParamsWebCrawlerParseOptions(BaseModel): + content_selector: Optional[List[SourceParamsWebCrawlerParseOptionsContentSelector]] = None + """ + List of path-to-selector mappings for extracting specific content from crawled + pages. Each entry pairs a URL glob pattern with a CSS selector. The first + matching path wins. Only the matched HTML fragment is stored and indexed. + """ + include_headers: Optional[Dict[str, str]] = None include_images: Optional[bool] = None @@ -147,10 +199,6 @@ class InstanceDeleteResponse(BaseModel): modified_at: datetime - source: str - - type: Literal["r2", "web-crawler"] - vectorize_name: str ai_gateway_id: Optional[str] = None @@ -276,8 +324,12 @@ class InstanceDeleteResponse(BaseModel): score_threshold: Optional[float] = None + source: Optional[str] = None + source_params: Optional[SourceParams] = None status: Optional[str] = None token_id: Optional[str] = None + + type: Optional[Literal["r2", "web-crawler"]] = None diff --git a/src/cloudflare/types/aisearch/instance_list_params.py b/src/cloudflare/types/aisearch/instance_list_params.py index 543926bdaee..6433ba8e007 100644 --- a/src/cloudflare/types/aisearch/instance_list_params.py +++ b/src/cloudflare/types/aisearch/instance_list_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import Literal, Required, TypedDict __all__ = ["InstanceListParams"] @@ -10,6 +10,12 @@ class InstanceListParams(TypedDict, total=False): account_id: Required[str] + order_by: Literal["created_at"] + """Order By Column Name""" + + order_by_direction: Literal["asc", "desc"] + """Order By Direction""" + page: int per_page: int diff --git a/src/cloudflare/types/aisearch/instance_list_response.py b/src/cloudflare/types/aisearch/instance_list_response.py index 5a72892e3aa..0030fc823f4 100644 --- a/src/cloudflare/types/aisearch/instance_list_response.py +++ b/src/cloudflare/types/aisearch/instance_list_response.py @@ -19,9 +19,11 @@ "PublicEndpointParamsRateLimit", "PublicEndpointParamsSearchEndpoint", "RetrievalOptions", + "RetrievalOptionsBoostBy", "SourceParams", "SourceParamsWebCrawler", "SourceParamsWebCrawlerParseOptions", + "SourceParamsWebCrawlerParseOptionsContentSelector", "SourceParamsWebCrawlerStoreOptions", ] @@ -77,7 +79,34 @@ class PublicEndpointParams(BaseModel): search_endpoint: Optional[PublicEndpointParamsSearchEndpoint] = None +class RetrievalOptionsBoostBy(BaseModel): + field: str + """Metadata field name to boost by. + + Use 'timestamp' for document freshness, or any custom_metadata field. Numeric + fields support asc/desc directions; text/boolean fields support + exists/not_exists. + """ + + direction: Optional[Literal["asc", "desc", "exists", "not_exists"]] = None + """Boost direction. + + 'desc' = higher values rank higher (e.g. newer timestamps). 'asc' = lower values + rank higher. 'exists' = boost chunks that have the field. 'not_exists' = boost + chunks that lack the field. Optional ��� defaults to 'asc' for numeric fields, + 'exists' for text/boolean fields. + """ + + class RetrievalOptions(BaseModel): + boost_by: Optional[List[RetrievalOptionsBoostBy]] = None + """Metadata fields to boost search results by. + + Each entry specifies a metadata field and an optional direction. Direction + defaults to 'asc' for numeric fields and 'exists' for text/boolean fields. + Fields must match 'timestamp' or a defined custom_metadata field. + """ + keyword_match_mode: Optional[Literal["exact_match", "fuzzy_match"]] = None """Controls how keyword search terms are matched. @@ -86,7 +115,30 @@ class RetrievalOptions(BaseModel): """ +class SourceParamsWebCrawlerParseOptionsContentSelector(BaseModel): + path: str + """Glob pattern to match against the page URL path. + + Uses standard glob syntax: \\** matches within a segment, \\**\\** crosses + directories. + """ + + selector: str + """CSS selector to extract content from pages matching the path pattern. + + Supports standard CSS selectors including class, ID, element, and attribute + selectors. + """ + + class SourceParamsWebCrawlerParseOptions(BaseModel): + content_selector: Optional[List[SourceParamsWebCrawlerParseOptionsContentSelector]] = None + """ + List of path-to-selector mappings for extracting specific content from crawled + pages. Each entry pairs a URL glob pattern with a CSS selector. The first + matching path wins. Only the matched HTML fragment is stored and indexed. + """ + include_headers: Optional[Dict[str, str]] = None include_images: Optional[bool] = None @@ -147,10 +199,6 @@ class InstanceListResponse(BaseModel): modified_at: datetime - source: str - - type: Literal["r2", "web-crawler"] - vectorize_name: str ai_gateway_id: Optional[str] = None @@ -276,8 +324,12 @@ class InstanceListResponse(BaseModel): score_threshold: Optional[float] = None + source: Optional[str] = None + source_params: Optional[SourceParams] = None status: Optional[str] = None token_id: Optional[str] = None + + type: Optional[Literal["r2", "web-crawler"]] = None diff --git a/src/cloudflare/types/aisearch/instance_read_response.py b/src/cloudflare/types/aisearch/instance_read_response.py index b0d3f5996d9..5168fe0a540 100644 --- a/src/cloudflare/types/aisearch/instance_read_response.py +++ b/src/cloudflare/types/aisearch/instance_read_response.py @@ -19,9 +19,11 @@ "PublicEndpointParamsRateLimit", "PublicEndpointParamsSearchEndpoint", "RetrievalOptions", + "RetrievalOptionsBoostBy", "SourceParams", "SourceParamsWebCrawler", "SourceParamsWebCrawlerParseOptions", + "SourceParamsWebCrawlerParseOptionsContentSelector", "SourceParamsWebCrawlerStoreOptions", ] @@ -77,7 +79,34 @@ class PublicEndpointParams(BaseModel): search_endpoint: Optional[PublicEndpointParamsSearchEndpoint] = None +class RetrievalOptionsBoostBy(BaseModel): + field: str + """Metadata field name to boost by. + + Use 'timestamp' for document freshness, or any custom_metadata field. Numeric + fields support asc/desc directions; text/boolean fields support + exists/not_exists. + """ + + direction: Optional[Literal["asc", "desc", "exists", "not_exists"]] = None + """Boost direction. + + 'desc' = higher values rank higher (e.g. newer timestamps). 'asc' = lower values + rank higher. 'exists' = boost chunks that have the field. 'not_exists' = boost + chunks that lack the field. Optional ��� defaults to 'asc' for numeric fields, + 'exists' for text/boolean fields. + """ + + class RetrievalOptions(BaseModel): + boost_by: Optional[List[RetrievalOptionsBoostBy]] = None + """Metadata fields to boost search results by. + + Each entry specifies a metadata field and an optional direction. Direction + defaults to 'asc' for numeric fields and 'exists' for text/boolean fields. + Fields must match 'timestamp' or a defined custom_metadata field. + """ + keyword_match_mode: Optional[Literal["exact_match", "fuzzy_match"]] = None """Controls how keyword search terms are matched. @@ -86,7 +115,30 @@ class RetrievalOptions(BaseModel): """ +class SourceParamsWebCrawlerParseOptionsContentSelector(BaseModel): + path: str + """Glob pattern to match against the page URL path. + + Uses standard glob syntax: \\** matches within a segment, \\**\\** crosses + directories. + """ + + selector: str + """CSS selector to extract content from pages matching the path pattern. + + Supports standard CSS selectors including class, ID, element, and attribute + selectors. + """ + + class SourceParamsWebCrawlerParseOptions(BaseModel): + content_selector: Optional[List[SourceParamsWebCrawlerParseOptionsContentSelector]] = None + """ + List of path-to-selector mappings for extracting specific content from crawled + pages. Each entry pairs a URL glob pattern with a CSS selector. The first + matching path wins. Only the matched HTML fragment is stored and indexed. + """ + include_headers: Optional[Dict[str, str]] = None include_images: Optional[bool] = None @@ -147,10 +199,6 @@ class InstanceReadResponse(BaseModel): modified_at: datetime - source: str - - type: Literal["r2", "web-crawler"] - vectorize_name: str ai_gateway_id: Optional[str] = None @@ -276,8 +324,12 @@ class InstanceReadResponse(BaseModel): score_threshold: Optional[float] = None + source: Optional[str] = None + source_params: Optional[SourceParams] = None status: Optional[str] = None token_id: Optional[str] = None + + type: Optional[Literal["r2", "web-crawler"]] = None diff --git a/src/cloudflare/types/aisearch/instance_search_params.py b/src/cloudflare/types/aisearch/instance_search_params.py index fba9dbe2f6a..a8c23c9992c 100644 --- a/src/cloudflare/types/aisearch/instance_search_params.py +++ b/src/cloudflare/types/aisearch/instance_search_params.py @@ -14,6 +14,7 @@ "AISearchOptionsQueryRewrite", "AISearchOptionsReranking", "AISearchOptionsRetrieval", + "AISearchOptionsRetrievalBoostBy", ] @@ -79,7 +80,34 @@ class AISearchOptionsReranking(TypedDict, total=False): model: Literal["@cf/baai/bge-reranker-base", ""] +class AISearchOptionsRetrievalBoostBy(TypedDict, total=False): + field: Required[str] + """Metadata field name to boost by. + + Use 'timestamp' for document freshness, or any custom_metadata field. Numeric + fields support asc/desc directions; text/boolean fields support + exists/not_exists. + """ + + direction: Literal["asc", "desc", "exists", "not_exists"] + """Boost direction. + + 'desc' = higher values rank higher (e.g. newer timestamps). 'asc' = lower values + rank higher. 'exists' = boost chunks that have the field. 'not_exists' = boost + chunks that lack the field. Optional ��� defaults to 'asc' for numeric fields, + 'exists' for text/boolean fields. + """ + + class AISearchOptionsRetrieval(TypedDict, total=False): + boost_by: Iterable[AISearchOptionsRetrievalBoostBy] + """Metadata fields to boost search results by. + + Overrides the instance-level boost_by config. Direction defaults to 'asc' for + numeric fields, 'exists' for text/boolean fields. Fields must match 'timestamp' + or a defined custom_metadata field. + """ + context_expansion: int filters: Dict[str, object] diff --git a/src/cloudflare/types/aisearch/instance_update_params.py b/src/cloudflare/types/aisearch/instance_update_params.py index e1d481fb7ac..db2a4100f54 100644 --- a/src/cloudflare/types/aisearch/instance_update_params.py +++ b/src/cloudflare/types/aisearch/instance_update_params.py @@ -19,9 +19,11 @@ "PublicEndpointParamsRateLimit", "PublicEndpointParamsSearchEndpoint", "RetrievalOptions", + "RetrievalOptionsBoostBy", "SourceParams", "SourceParamsWebCrawler", "SourceParamsWebCrawlerParseOptions", + "SourceParamsWebCrawlerParseOptionsContentSelector", "SourceParamsWebCrawlerStoreOptions", ] @@ -236,7 +238,34 @@ class PublicEndpointParams(TypedDict, total=False): search_endpoint: PublicEndpointParamsSearchEndpoint +class RetrievalOptionsBoostBy(TypedDict, total=False): + field: Required[str] + """Metadata field name to boost by. + + Use 'timestamp' for document freshness, or any custom_metadata field. Numeric + fields support asc/desc directions; text/boolean fields support + exists/not_exists. + """ + + direction: Literal["asc", "desc", "exists", "not_exists"] + """Boost direction. + + 'desc' = higher values rank higher (e.g. newer timestamps). 'asc' = lower values + rank higher. 'exists' = boost chunks that have the field. 'not_exists' = boost + chunks that lack the field. Optional ��� defaults to 'asc' for numeric fields, + 'exists' for text/boolean fields. + """ + + class RetrievalOptions(TypedDict, total=False): + boost_by: Iterable[RetrievalOptionsBoostBy] + """Metadata fields to boost search results by. + + Each entry specifies a metadata field and an optional direction. Direction + defaults to 'asc' for numeric fields and 'exists' for text/boolean fields. + Fields must match 'timestamp' or a defined custom_metadata field. + """ + keyword_match_mode: Literal["exact_match", "fuzzy_match"] """Controls how keyword search terms are matched. @@ -245,7 +274,30 @@ class RetrievalOptions(TypedDict, total=False): """ +class SourceParamsWebCrawlerParseOptionsContentSelector(TypedDict, total=False): + path: Required[str] + """Glob pattern to match against the page URL path. + + Uses standard glob syntax: \\** matches within a segment, \\**\\** crosses + directories. + """ + + selector: Required[str] + """CSS selector to extract content from pages matching the path pattern. + + Supports standard CSS selectors including class, ID, element, and attribute + selectors. + """ + + class SourceParamsWebCrawlerParseOptions(TypedDict, total=False): + content_selector: Iterable[SourceParamsWebCrawlerParseOptionsContentSelector] + """ + List of path-to-selector mappings for extracting specific content from crawled + pages. Each entry pairs a URL glob pattern with a CSS selector. The first + matching path wins. Only the matched HTML fragment is stored and indexed. + """ + include_headers: Dict[str, str] include_images: bool diff --git a/src/cloudflare/types/aisearch/instance_update_response.py b/src/cloudflare/types/aisearch/instance_update_response.py index 712c2a7bc1e..4ac93b2b86a 100644 --- a/src/cloudflare/types/aisearch/instance_update_response.py +++ b/src/cloudflare/types/aisearch/instance_update_response.py @@ -19,9 +19,11 @@ "PublicEndpointParamsRateLimit", "PublicEndpointParamsSearchEndpoint", "RetrievalOptions", + "RetrievalOptionsBoostBy", "SourceParams", "SourceParamsWebCrawler", "SourceParamsWebCrawlerParseOptions", + "SourceParamsWebCrawlerParseOptionsContentSelector", "SourceParamsWebCrawlerStoreOptions", ] @@ -77,7 +79,34 @@ class PublicEndpointParams(BaseModel): search_endpoint: Optional[PublicEndpointParamsSearchEndpoint] = None +class RetrievalOptionsBoostBy(BaseModel): + field: str + """Metadata field name to boost by. + + Use 'timestamp' for document freshness, or any custom_metadata field. Numeric + fields support asc/desc directions; text/boolean fields support + exists/not_exists. + """ + + direction: Optional[Literal["asc", "desc", "exists", "not_exists"]] = None + """Boost direction. + + 'desc' = higher values rank higher (e.g. newer timestamps). 'asc' = lower values + rank higher. 'exists' = boost chunks that have the field. 'not_exists' = boost + chunks that lack the field. Optional ��� defaults to 'asc' for numeric fields, + 'exists' for text/boolean fields. + """ + + class RetrievalOptions(BaseModel): + boost_by: Optional[List[RetrievalOptionsBoostBy]] = None + """Metadata fields to boost search results by. + + Each entry specifies a metadata field and an optional direction. Direction + defaults to 'asc' for numeric fields and 'exists' for text/boolean fields. + Fields must match 'timestamp' or a defined custom_metadata field. + """ + keyword_match_mode: Optional[Literal["exact_match", "fuzzy_match"]] = None """Controls how keyword search terms are matched. @@ -86,7 +115,30 @@ class RetrievalOptions(BaseModel): """ +class SourceParamsWebCrawlerParseOptionsContentSelector(BaseModel): + path: str + """Glob pattern to match against the page URL path. + + Uses standard glob syntax: \\** matches within a segment, \\**\\** crosses + directories. + """ + + selector: str + """CSS selector to extract content from pages matching the path pattern. + + Supports standard CSS selectors including class, ID, element, and attribute + selectors. + """ + + class SourceParamsWebCrawlerParseOptions(BaseModel): + content_selector: Optional[List[SourceParamsWebCrawlerParseOptionsContentSelector]] = None + """ + List of path-to-selector mappings for extracting specific content from crawled + pages. Each entry pairs a URL glob pattern with a CSS selector. The first + matching path wins. Only the matched HTML fragment is stored and indexed. + """ + include_headers: Optional[Dict[str, str]] = None include_images: Optional[bool] = None @@ -147,10 +199,6 @@ class InstanceUpdateResponse(BaseModel): modified_at: datetime - source: str - - type: Literal["r2", "web-crawler"] - vectorize_name: str ai_gateway_id: Optional[str] = None @@ -276,8 +324,12 @@ class InstanceUpdateResponse(BaseModel): score_threshold: Optional[float] = None + source: Optional[str] = None + source_params: Optional[SourceParams] = None status: Optional[str] = None token_id: Optional[str] = None + + type: Optional[Literal["r2", "web-crawler"]] = None diff --git a/src/cloudflare/types/aisearch/instances/__init__.py b/src/cloudflare/types/aisearch/instances/__init__.py index a9a19580c09..68c80804a2a 100644 --- a/src/cloudflare/types/aisearch/instances/__init__.py +++ b/src/cloudflare/types/aisearch/instances/__init__.py @@ -6,7 +6,7 @@ from .job_logs_params import JobLogsParams as JobLogsParams from .item_list_params import ItemListParams as ItemListParams from .job_get_response import JobGetResponse as JobGetResponse -from .item_get_response import ItemGetResponse as ItemGetResponse +from .job_create_params import JobCreateParams as JobCreateParams from .job_list_response import JobListResponse as JobListResponse from .job_logs_response import JobLogsResponse as JobLogsResponse from .item_list_response import ItemListResponse as ItemListResponse diff --git a/src/cloudflare/types/aisearch/instances/item_get_response.py b/src/cloudflare/types/aisearch/instances/item_get_response.py deleted file mode 100644 index 50eaf709682..00000000000 --- a/src/cloudflare/types/aisearch/instances/item_get_response.py +++ /dev/null @@ -1,35 +0,0 @@ -# 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__ = ["ItemGetResponse"] - - -class ItemGetResponse(BaseModel): - id: float - - checksum: str - - chunks_count: Optional[int] = None - - created_at: datetime - - file_size: Optional[float] = None - - key: str - - last_seen_at: datetime - - namespace: str - - next_action: Optional[Literal["INDEX", "DELETE"]] = None - - status: Literal["queued", "running", "completed", "error", "skipped"] - - error: Optional[str] = None - - public_id: Optional[str] = None diff --git a/src/cloudflare/types/aisearch/instances/job_create_params.py b/src/cloudflare/types/aisearch/instances/job_create_params.py new file mode 100644 index 00000000000..243c20584fb --- /dev/null +++ b/src/cloudflare/types/aisearch/instances/job_create_params.py @@ -0,0 +1,13 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["JobCreateParams"] + + +class JobCreateParams(TypedDict, total=False): + account_id: Required[str] + + description: str diff --git a/src/cloudflare/types/aisearch/instances/job_create_response.py b/src/cloudflare/types/aisearch/instances/job_create_response.py index 25ad1d27903..e50db7271da 100644 --- a/src/cloudflare/types/aisearch/instances/job_create_response.py +++ b/src/cloudflare/types/aisearch/instances/job_create_response.py @@ -13,6 +13,8 @@ class JobCreateResponse(BaseModel): source: Literal["user", "schedule"] + description: Optional[str] = None + end_reason: Optional[str] = None ended_at: Optional[str] = None diff --git a/src/cloudflare/types/aisearch/instances/job_get_response.py b/src/cloudflare/types/aisearch/instances/job_get_response.py index 6fbbda8a3ab..cbd4075812b 100644 --- a/src/cloudflare/types/aisearch/instances/job_get_response.py +++ b/src/cloudflare/types/aisearch/instances/job_get_response.py @@ -13,6 +13,8 @@ class JobGetResponse(BaseModel): source: Literal["user", "schedule"] + description: Optional[str] = None + end_reason: Optional[str] = None ended_at: Optional[str] = None diff --git a/src/cloudflare/types/aisearch/instances/job_list_response.py b/src/cloudflare/types/aisearch/instances/job_list_response.py index 1b550a45c10..f2cb59f4e17 100644 --- a/src/cloudflare/types/aisearch/instances/job_list_response.py +++ b/src/cloudflare/types/aisearch/instances/job_list_response.py @@ -13,6 +13,8 @@ class JobListResponse(BaseModel): source: Literal["user", "schedule"] + description: Optional[str] = None + end_reason: Optional[str] = None ended_at: Optional[str] = None diff --git a/src/cloudflare/types/aisearch/token_list_params.py b/src/cloudflare/types/aisearch/token_list_params.py index 2133c57baba..01a1a0f2add 100644 --- a/src/cloudflare/types/aisearch/token_list_params.py +++ b/src/cloudflare/types/aisearch/token_list_params.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing_extensions import Literal, Required, TypedDict __all__ = ["TokenListParams"] @@ -10,6 +10,12 @@ class TokenListParams(TypedDict, total=False): account_id: Required[str] + order_by: Literal["created_at"] + """Order By Column Name""" + + order_by_direction: Literal["asc", "desc"] + """Order By Direction""" + page: int per_page: int diff --git a/src/cloudflare/types/cloudforce_one/threat_events/dataset_raw_response.py b/src/cloudflare/types/cloudforce_one/threat_events/dataset_raw_response.py index 6baf8e4b567..aaec6178749 100644 --- a/src/cloudflare/types/cloudforce_one/threat_events/dataset_raw_response.py +++ b/src/cloudflare/types/cloudforce_one/threat_events/dataset_raw_response.py @@ -8,13 +8,13 @@ class DatasetRawResponse(BaseModel): - id: str + id: float account_id: float = FieldInfo(alias="accountId") created: str - data: object + data: str source: str diff --git a/src/cloudflare/types/d1/d1.py b/src/cloudflare/types/d1/d1.py index 41fe1cb45a3..d1e8af72b22 100644 --- a/src/cloudflare/types/d1/d1.py +++ b/src/cloudflare/types/d1/d1.py @@ -30,6 +30,12 @@ class D1(BaseModel): file_size: Optional[float] = None """The D1 database's size, in bytes.""" + jurisdiction: Optional[Literal["eu", "fedramp"]] = None + """Specify the location to restrict the D1 database to run and store data. + + If this option is present, the location hint is ignored. + """ + name: Optional[str] = None """D1 database name.""" diff --git a/src/cloudflare/types/d1/database_list_response.py b/src/cloudflare/types/d1/database_list_response.py index bdcb159357d..1332df02199 100644 --- a/src/cloudflare/types/d1/database_list_response.py +++ b/src/cloudflare/types/d1/database_list_response.py @@ -2,6 +2,7 @@ from typing import Optional from datetime import datetime +from typing_extensions import Literal from ..._models import BaseModel @@ -12,6 +13,12 @@ class DatabaseListResponse(BaseModel): created_at: Optional[datetime] = None """Specifies the timestamp the resource was created as an ISO8601 string.""" + jurisdiction: Optional[Literal["eu", "fedramp"]] = None + """Specify the location to restrict the D1 database to run and store data. + + If this option is present, the location hint is ignored. + """ + name: Optional[str] = None """D1 database name.""" diff --git a/src/cloudflare/types/email_security/investigate_get_response.py b/src/cloudflare/types/email_security/investigate_get_response.py index c3bb7927ab0..7cdee54bd4d 100644 --- a/src/cloudflare/types/email_security/investigate_get_response.py +++ b/src/cloudflare/types/email_security/investigate_get_response.py @@ -156,6 +156,8 @@ class InvestigateGetResponse(BaseModel): message_id: Optional[str] = None + post_delivery_operations: Optional[List[Literal["PREVIEW", "QUARANTINE_RELEASE", "SUBMISSION", "MOVE"]]] = None + postfix_id_outbound: Optional[str] = None replyto: Optional[str] = None diff --git a/src/cloudflare/types/email_security/investigate_list_params.py b/src/cloudflare/types/email_security/investigate_list_params.py index 9c5fa4e2ab5..e3fcf105d4d 100644 --- a/src/cloudflare/types/email_security/investigate_list_params.py +++ b/src/cloudflare/types/email_security/investigate_list_params.py @@ -26,11 +26,17 @@ class InvestigateListParams(TypedDict, total=False): """Determines if the search results will include detections or not.""" domain: str - """The sender domains the search filters by.""" + """ + Filter by a domain found in the email: sender domain, recipient domain, or a + domain in a link. + """ end: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")] """The end of the search date range. Defaults to `now` if not provided.""" + exact_subject: str + """Search for messages with an exact subject match.""" + final_disposition: Literal["MALICIOUS", "SUSPICIOUS", "SPOOF", "SPAM", "BULK", "NONE"] """The dispositions the search filters by.""" @@ -75,8 +81,10 @@ class InvestigateListParams(TypedDict, total=False): """ recipient: str + """Filter by recipient. Matches either an email address or a domain.""" sender: str + """Filter by sender. Matches either an email address or a domain.""" start: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")] """ @@ -85,3 +93,7 @@ class InvestigateListParams(TypedDict, total=False): """ subject: str + """ + Search for messages containing individual keywords in any order within the + subject. + """ diff --git a/src/cloudflare/types/email_security/investigate_list_response.py b/src/cloudflare/types/email_security/investigate_list_response.py index dbf5f9c25e6..b0fdb523b72 100644 --- a/src/cloudflare/types/email_security/investigate_list_response.py +++ b/src/cloudflare/types/email_security/investigate_list_response.py @@ -156,6 +156,8 @@ class InvestigateListResponse(BaseModel): message_id: Optional[str] = None + post_delivery_operations: Optional[List[Literal["PREVIEW", "QUARANTINE_RELEASE", "SUBMISSION", "MOVE"]]] = None + postfix_id_outbound: Optional[str] = None replyto: Optional[str] = None diff --git a/src/cloudflare/types/email_security/submission_list_params.py b/src/cloudflare/types/email_security/submission_list_params.py index de2f513a2fc..225fb097290 100644 --- a/src/cloudflare/types/email_security/submission_list_params.py +++ b/src/cloudflare/types/email_security/submission_list_params.py @@ -15,6 +15,8 @@ class SubmissionListParams(TypedDict, total=False): account_id: Required[str] """Account Identifier""" + customer_status: Literal["escalated", "reviewed", "unreviewed"] + end: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")] """The end of the search date range. Defaults to `now` if not provided.""" diff --git a/src/cloudflare/types/email_security/submission_list_response.py b/src/cloudflare/types/email_security/submission_list_response.py index 841284d9801..9395ccdabd5 100644 --- a/src/cloudflare/types/email_security/submission_list_response.py +++ b/src/cloudflare/types/email_security/submission_list_response.py @@ -14,6 +14,8 @@ class SubmissionListResponse(BaseModel): submission_id: str + customer_status: Optional[Literal["escalated", "reviewed", "unreviewed"]] = None + original_disposition: Optional[ Literal[ "MALICIOUS", diff --git a/src/cloudflare/types/magic_transit/app_create_params.py b/src/cloudflare/types/magic_transit/app_create_params.py index 06e6ea07417..33512d9db4e 100644 --- a/src/cloudflare/types/magic_transit/app_create_params.py +++ b/src/cloudflare/types/magic_transit/app_create_params.py @@ -27,3 +27,9 @@ class AppCreateParams(TypedDict, total=False): (IPv6 CIDRs are currently unsupported) """ + + source_subnets: SequenceNotStr[str] + """IPv4 CIDRs to associate with traffic decisions. + + (IPv6 CIDRs are currently unsupported) + """ diff --git a/src/cloudflare/types/magic_transit/app_create_response.py b/src/cloudflare/types/magic_transit/app_create_response.py index 9dc78cc85e0..393051343b3 100644 --- a/src/cloudflare/types/magic_transit/app_create_response.py +++ b/src/cloudflare/types/magic_transit/app_create_response.py @@ -25,5 +25,11 @@ class AppCreateResponse(BaseModel): name: Optional[str] = None """Display name for the app.""" + source_subnets: Optional[List[str]] = None + """IPv4 CIDRs to associate with traffic decisions. + + (IPv6 CIDRs are currently unsupported) + """ + type: Optional[str] = None """Category of the app.""" diff --git a/src/cloudflare/types/magic_transit/app_delete_response.py b/src/cloudflare/types/magic_transit/app_delete_response.py index 034a9d740ed..5ef23a76449 100644 --- a/src/cloudflare/types/magic_transit/app_delete_response.py +++ b/src/cloudflare/types/magic_transit/app_delete_response.py @@ -25,5 +25,11 @@ class AppDeleteResponse(BaseModel): name: Optional[str] = None """Display name for the app.""" + source_subnets: Optional[List[str]] = None + """IPv4 CIDRs to associate with traffic decisions. + + (IPv6 CIDRs are currently unsupported) + """ + type: Optional[str] = None """Category of the app.""" diff --git a/src/cloudflare/types/magic_transit/app_edit_params.py b/src/cloudflare/types/magic_transit/app_edit_params.py index 8d0052ab142..c9702e77697 100644 --- a/src/cloudflare/types/magic_transit/app_edit_params.py +++ b/src/cloudflare/types/magic_transit/app_edit_params.py @@ -25,5 +25,11 @@ class AppEditParams(TypedDict, total=False): name: str """Display name for the app.""" + source_subnets: SequenceNotStr[str] + """IPv4 CIDRs to associate with traffic decisions. + + (IPv6 CIDRs are currently unsupported) + """ + type: str """Category of the app.""" diff --git a/src/cloudflare/types/magic_transit/app_edit_response.py b/src/cloudflare/types/magic_transit/app_edit_response.py index da5bda564f6..02e2c1c2563 100644 --- a/src/cloudflare/types/magic_transit/app_edit_response.py +++ b/src/cloudflare/types/magic_transit/app_edit_response.py @@ -25,5 +25,11 @@ class AppEditResponse(BaseModel): name: Optional[str] = None """Display name for the app.""" + source_subnets: Optional[List[str]] = None + """IPv4 CIDRs to associate with traffic decisions. + + (IPv6 CIDRs are currently unsupported) + """ + type: Optional[str] = None """Category of the app.""" diff --git a/src/cloudflare/types/magic_transit/app_list_response.py b/src/cloudflare/types/magic_transit/app_list_response.py index 4698cdc6883..888bec795c6 100644 --- a/src/cloudflare/types/magic_transit/app_list_response.py +++ b/src/cloudflare/types/magic_transit/app_list_response.py @@ -26,6 +26,12 @@ class MagicAccountApp(BaseModel): name: Optional[str] = None """Display name for the app.""" + source_subnets: Optional[List[str]] = None + """IPv4 CIDRs to associate with traffic decisions. + + (IPv6 CIDRs are currently unsupported) + """ + type: Optional[str] = None """Category of the app.""" @@ -48,6 +54,12 @@ class MagicManagedApp(BaseModel): name: Optional[str] = None """Display name for the app.""" + source_subnets: Optional[List[str]] = None + """IPv4 CIDRs to associate with traffic decisions. + + (IPv6 CIDRs are currently unsupported) + """ + type: Optional[str] = None """Category of the app.""" diff --git a/src/cloudflare/types/magic_transit/app_update_params.py b/src/cloudflare/types/magic_transit/app_update_params.py index 4ae6f412734..4af8c5f1a63 100644 --- a/src/cloudflare/types/magic_transit/app_update_params.py +++ b/src/cloudflare/types/magic_transit/app_update_params.py @@ -25,5 +25,11 @@ class AppUpdateParams(TypedDict, total=False): name: str """Display name for the app.""" + source_subnets: SequenceNotStr[str] + """IPv4 CIDRs to associate with traffic decisions. + + (IPv6 CIDRs are currently unsupported) + """ + type: str """Category of the app.""" diff --git a/src/cloudflare/types/magic_transit/app_update_response.py b/src/cloudflare/types/magic_transit/app_update_response.py index b32d7944666..7ec55a596d2 100644 --- a/src/cloudflare/types/magic_transit/app_update_response.py +++ b/src/cloudflare/types/magic_transit/app_update_response.py @@ -25,5 +25,11 @@ class AppUpdateResponse(BaseModel): name: Optional[str] = None """Display name for the app.""" + source_subnets: Optional[List[str]] = None + """IPv4 CIDRs to associate with traffic decisions. + + (IPv6 CIDRs are currently unsupported) + """ + type: Optional[str] = None """Category of the app.""" diff --git a/src/cloudflare/types/magic_transit/connector_create_params.py b/src/cloudflare/types/magic_transit/connector_create_params.py index f39191505a0..8ada6bdf956 100644 --- a/src/cloudflare/types/magic_transit/connector_create_params.py +++ b/src/cloudflare/types/magic_transit/connector_create_params.py @@ -2,7 +2,10 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing import List +from typing_extensions import Literal, Required, TypedDict + +from ..._types import SequenceNotStr __all__ = ["ConnectorCreateParams", "Device"] @@ -16,8 +19,16 @@ class ConnectorCreateParams(TypedDict, total=False): activated: bool + interrupt_window_days_of_week: List[ + Literal["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] + ] + """Allowed days of the week for upgrades. Default is all days.""" + interrupt_window_duration_hours: float + interrupt_window_embargo_dates: SequenceNotStr[str] + """List of dates (YYYY-MM-DD) when upgrades are blocked.""" + interrupt_window_hour_of_day: float notes: str diff --git a/src/cloudflare/types/magic_transit/connector_create_response.py b/src/cloudflare/types/magic_transit/connector_create_response.py index 9c0e39f9f1a..74053c83628 100644 --- a/src/cloudflare/types/magic_transit/connector_create_response.py +++ b/src/cloudflare/types/magic_transit/connector_create_response.py @@ -1,6 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Optional +from typing import List, Optional +from typing_extensions import Literal from ..._models import BaseModel @@ -18,8 +19,16 @@ class ConnectorCreateResponse(BaseModel): activated: bool + interrupt_window_days_of_week: List[ + Literal["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] + ] + """Allowed days of the week for upgrades. Default is all days.""" + interrupt_window_duration_hours: float + interrupt_window_embargo_dates: List[str] + """List of dates (YYYY-MM-DD) when upgrades are blocked.""" + interrupt_window_hour_of_day: float last_updated: str diff --git a/src/cloudflare/types/magic_transit/connector_delete_response.py b/src/cloudflare/types/magic_transit/connector_delete_response.py index 3337342f6aa..7dc21b7c70c 100644 --- a/src/cloudflare/types/magic_transit/connector_delete_response.py +++ b/src/cloudflare/types/magic_transit/connector_delete_response.py @@ -1,6 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Optional +from typing import List, Optional +from typing_extensions import Literal from ..._models import BaseModel @@ -18,8 +19,16 @@ class ConnectorDeleteResponse(BaseModel): activated: bool + interrupt_window_days_of_week: List[ + Literal["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] + ] + """Allowed days of the week for upgrades. Default is all days.""" + interrupt_window_duration_hours: float + interrupt_window_embargo_dates: List[str] + """List of dates (YYYY-MM-DD) when upgrades are blocked.""" + interrupt_window_hour_of_day: float last_updated: str diff --git a/src/cloudflare/types/magic_transit/connector_edit_params.py b/src/cloudflare/types/magic_transit/connector_edit_params.py index 0f2e12db6c8..56b44c01e3d 100644 --- a/src/cloudflare/types/magic_transit/connector_edit_params.py +++ b/src/cloudflare/types/magic_transit/connector_edit_params.py @@ -2,7 +2,10 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing import List +from typing_extensions import Literal, Required, TypedDict + +from ..._types import SequenceNotStr __all__ = ["ConnectorEditParams"] @@ -13,8 +16,16 @@ class ConnectorEditParams(TypedDict, total=False): activated: bool + interrupt_window_days_of_week: List[ + Literal["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] + ] + """Allowed days of the week for upgrades. Default is all days.""" + interrupt_window_duration_hours: float + interrupt_window_embargo_dates: SequenceNotStr[str] + """List of dates (YYYY-MM-DD) when upgrades are blocked.""" + interrupt_window_hour_of_day: float notes: str diff --git a/src/cloudflare/types/magic_transit/connector_edit_response.py b/src/cloudflare/types/magic_transit/connector_edit_response.py index d7e96504124..e65a54a4c14 100644 --- a/src/cloudflare/types/magic_transit/connector_edit_response.py +++ b/src/cloudflare/types/magic_transit/connector_edit_response.py @@ -1,6 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Optional +from typing import List, Optional +from typing_extensions import Literal from ..._models import BaseModel @@ -18,8 +19,16 @@ class ConnectorEditResponse(BaseModel): activated: bool + interrupt_window_days_of_week: List[ + Literal["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] + ] + """Allowed days of the week for upgrades. Default is all days.""" + interrupt_window_duration_hours: float + interrupt_window_embargo_dates: List[str] + """List of dates (YYYY-MM-DD) when upgrades are blocked.""" + interrupt_window_hour_of_day: float last_updated: str diff --git a/src/cloudflare/types/magic_transit/connector_get_response.py b/src/cloudflare/types/magic_transit/connector_get_response.py index bb1b53e6d78..00426f9c13b 100644 --- a/src/cloudflare/types/magic_transit/connector_get_response.py +++ b/src/cloudflare/types/magic_transit/connector_get_response.py @@ -1,6 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Optional +from typing import List, Optional +from typing_extensions import Literal from ..._models import BaseModel @@ -18,8 +19,16 @@ class ConnectorGetResponse(BaseModel): activated: bool + interrupt_window_days_of_week: List[ + Literal["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] + ] + """Allowed days of the week for upgrades. Default is all days.""" + interrupt_window_duration_hours: float + interrupt_window_embargo_dates: List[str] + """List of dates (YYYY-MM-DD) when upgrades are blocked.""" + interrupt_window_hour_of_day: float last_updated: str diff --git a/src/cloudflare/types/magic_transit/connector_list_response.py b/src/cloudflare/types/magic_transit/connector_list_response.py index 2de6b683db6..bb73ab1bbf3 100644 --- a/src/cloudflare/types/magic_transit/connector_list_response.py +++ b/src/cloudflare/types/magic_transit/connector_list_response.py @@ -1,6 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Optional +from typing import List, Optional +from typing_extensions import Literal from ..._models import BaseModel @@ -18,8 +19,16 @@ class ConnectorListResponse(BaseModel): activated: bool + interrupt_window_days_of_week: List[ + Literal["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] + ] + """Allowed days of the week for upgrades. Default is all days.""" + interrupt_window_duration_hours: float + interrupt_window_embargo_dates: List[str] + """List of dates (YYYY-MM-DD) when upgrades are blocked.""" + interrupt_window_hour_of_day: float last_updated: str diff --git a/src/cloudflare/types/magic_transit/connector_update_params.py b/src/cloudflare/types/magic_transit/connector_update_params.py index 44529b716a5..9b046f584cc 100644 --- a/src/cloudflare/types/magic_transit/connector_update_params.py +++ b/src/cloudflare/types/magic_transit/connector_update_params.py @@ -2,7 +2,10 @@ from __future__ import annotations -from typing_extensions import Required, TypedDict +from typing import List +from typing_extensions import Literal, Required, TypedDict + +from ..._types import SequenceNotStr __all__ = ["ConnectorUpdateParams"] @@ -13,8 +16,16 @@ class ConnectorUpdateParams(TypedDict, total=False): activated: bool + interrupt_window_days_of_week: List[ + Literal["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] + ] + """Allowed days of the week for upgrades. Default is all days.""" + interrupt_window_duration_hours: float + interrupt_window_embargo_dates: SequenceNotStr[str] + """List of dates (YYYY-MM-DD) when upgrades are blocked.""" + interrupt_window_hour_of_day: float notes: str diff --git a/src/cloudflare/types/magic_transit/connector_update_response.py b/src/cloudflare/types/magic_transit/connector_update_response.py index 6e6430b7df3..35d0ee9f20d 100644 --- a/src/cloudflare/types/magic_transit/connector_update_response.py +++ b/src/cloudflare/types/magic_transit/connector_update_response.py @@ -1,6 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Optional +from typing import List, Optional +from typing_extensions import Literal from ..._models import BaseModel @@ -18,8 +19,16 @@ class ConnectorUpdateResponse(BaseModel): activated: bool + interrupt_window_days_of_week: List[ + Literal["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] + ] + """Allowed days of the week for upgrades. Default is all days.""" + interrupt_window_duration_hours: float + interrupt_window_embargo_dates: List[str] + """List of dates (YYYY-MM-DD) when upgrades are blocked.""" + interrupt_window_hour_of_day: float last_updated: str diff --git a/src/cloudflare/types/magic_transit/sites/lan.py b/src/cloudflare/types/magic_transit/sites/lan.py index fa029373d9f..f9e0e821a2c 100644 --- a/src/cloudflare/types/magic_transit/sites/lan.py +++ b/src/cloudflare/types/magic_transit/sites/lan.py @@ -22,6 +22,12 @@ class LAN(BaseModel): only works for site with HA turned on. only one LAN can be set as the ha_link. """ + is_breakout: Optional[bool] = None + """mark true to use this LAN for source-based breakout traffic""" + + is_prioritized: Optional[bool] = None + """mark true to use this LAN for source-based prioritized traffic""" + name: Optional[str] = None nat: Optional[Nat] = None diff --git a/src/cloudflare/types/magic_transit/sites/lan_create_params.py b/src/cloudflare/types/magic_transit/sites/lan_create_params.py index e0cefcdc9e4..ba7ea87f1a4 100644 --- a/src/cloudflare/types/magic_transit/sites/lan_create_params.py +++ b/src/cloudflare/types/magic_transit/sites/lan_create_params.py @@ -24,6 +24,12 @@ class LANCreateParams(TypedDict, total=False): only works for site with HA turned on. only one LAN can be set as the ha_link. """ + is_breakout: bool + """mark true to use this LAN for source-based breakout traffic""" + + is_prioritized: bool + """mark true to use this LAN for source-based prioritized traffic""" + name: str nat: NatParam diff --git a/src/cloudflare/types/magic_transit/sites/lan_edit_params.py b/src/cloudflare/types/magic_transit/sites/lan_edit_params.py index 8ae626d9846..36fd58040bf 100644 --- a/src/cloudflare/types/magic_transit/sites/lan_edit_params.py +++ b/src/cloudflare/types/magic_transit/sites/lan_edit_params.py @@ -21,6 +21,12 @@ class LANEditParams(TypedDict, total=False): bond_id: int + is_breakout: bool + """mark true to use this LAN for source-based breakout traffic""" + + is_prioritized: bool + """mark true to use this LAN for source-based prioritized traffic""" + name: str nat: NatParam diff --git a/src/cloudflare/types/magic_transit/sites/lan_update_params.py b/src/cloudflare/types/magic_transit/sites/lan_update_params.py index 58c4bd03f1e..db47e847eee 100644 --- a/src/cloudflare/types/magic_transit/sites/lan_update_params.py +++ b/src/cloudflare/types/magic_transit/sites/lan_update_params.py @@ -21,6 +21,12 @@ class LANUpdateParams(TypedDict, total=False): bond_id: int + is_breakout: bool + """mark true to use this LAN for source-based breakout traffic""" + + is_prioritized: bool + """mark true to use this LAN for source-based prioritized traffic""" + name: str nat: NatParam diff --git a/src/cloudflare/types/pipelines/sink_get_response.py b/src/cloudflare/types/pipelines/sink_get_response.py index ba6144023c6..f5078211ff3 100644 --- a/src/cloudflare/types/pipelines/sink_get_response.py +++ b/src/cloudflare/types/pipelines/sink_get_response.py @@ -12,13 +12,12 @@ __all__ = [ "SinkGetResponse", "Config", - "ConfigCloudflarePipelinesR2Table", - "ConfigCloudflarePipelinesR2TableCredentials", - "ConfigCloudflarePipelinesR2TableFileNaming", - "ConfigCloudflarePipelinesR2TablePartitioning", - "ConfigCloudflarePipelinesR2TableRollingPolicy", - "ConfigCloudflarePipelinesR2DataCatalogTable", - "ConfigCloudflarePipelinesR2DataCatalogTableRollingPolicy", + "ConfigCloudflarePipelinesR2TablePublic", + "ConfigCloudflarePipelinesR2TablePublicFileNaming", + "ConfigCloudflarePipelinesR2TablePublicPartitioning", + "ConfigCloudflarePipelinesR2TablePublicRollingPolicy", + "ConfigCloudflarePipelinesR2DataCatalogTablePublic", + "ConfigCloudflarePipelinesR2DataCatalogTablePublicRollingPolicy", "Format", "FormatJson", "FormatParquet", @@ -41,15 +40,7 @@ ] -class ConfigCloudflarePipelinesR2TableCredentials(BaseModel): - access_key_id: str - """Cloudflare Account ID for the bucket""" - - secret_access_key: str - """Cloudflare Account ID for the bucket""" - - -class ConfigCloudflarePipelinesR2TableFileNaming(BaseModel): +class ConfigCloudflarePipelinesR2TablePublicFileNaming(BaseModel): """Controls filename prefix/suffix and strategy.""" prefix: Optional[str] = None @@ -62,14 +53,14 @@ class ConfigCloudflarePipelinesR2TableFileNaming(BaseModel): """This will overwrite the default file suffix. i.e .parquet, use with caution""" -class ConfigCloudflarePipelinesR2TablePartitioning(BaseModel): +class ConfigCloudflarePipelinesR2TablePublicPartitioning(BaseModel): """Data-layout partitioning for sinks.""" time_pattern: Optional[str] = None """The pattern of the date string""" -class ConfigCloudflarePipelinesR2TableRollingPolicy(BaseModel): +class ConfigCloudflarePipelinesR2TablePublicRollingPolicy(BaseModel): """Rolling policy for file sinks (when & why to close a file and open a new one).""" file_size_bytes: Optional[int] = None @@ -82,32 +73,32 @@ class ConfigCloudflarePipelinesR2TableRollingPolicy(BaseModel): """Number of seconds to wait before rolling over to a new file""" -class ConfigCloudflarePipelinesR2Table(BaseModel): +class ConfigCloudflarePipelinesR2TablePublic(BaseModel): + """R2 Sink public configuration.""" + account_id: str """Cloudflare Account ID for the bucket""" bucket: str """R2 Bucket to write to""" - credentials: ConfigCloudflarePipelinesR2TableCredentials - - file_naming: Optional[ConfigCloudflarePipelinesR2TableFileNaming] = None + file_naming: Optional[ConfigCloudflarePipelinesR2TablePublicFileNaming] = None """Controls filename prefix/suffix and strategy.""" jurisdiction: Optional[str] = None """Jurisdiction this bucket is hosted in""" - partitioning: Optional[ConfigCloudflarePipelinesR2TablePartitioning] = None + partitioning: Optional[ConfigCloudflarePipelinesR2TablePublicPartitioning] = None """Data-layout partitioning for sinks.""" path: Optional[str] = None """Subpath within the bucket to write to""" - rolling_policy: Optional[ConfigCloudflarePipelinesR2TableRollingPolicy] = None + rolling_policy: Optional[ConfigCloudflarePipelinesR2TablePublicRollingPolicy] = None """Rolling policy for file sinks (when & why to close a file and open a new one).""" -class ConfigCloudflarePipelinesR2DataCatalogTableRollingPolicy(BaseModel): +class ConfigCloudflarePipelinesR2DataCatalogTablePublicRollingPolicy(BaseModel): """Rolling policy for file sinks (when & why to close a file and open a new one).""" file_size_bytes: Optional[int] = None @@ -120,11 +111,8 @@ class ConfigCloudflarePipelinesR2DataCatalogTableRollingPolicy(BaseModel): """Number of seconds to wait before rolling over to a new file""" -class ConfigCloudflarePipelinesR2DataCatalogTable(BaseModel): - """R2 Data Catalog Sink""" - - token: str - """Authentication token""" +class ConfigCloudflarePipelinesR2DataCatalogTablePublic(BaseModel): + """R2 Data Catalog Sink public configuration.""" account_id: str """Cloudflare Account ID""" @@ -138,11 +126,11 @@ class ConfigCloudflarePipelinesR2DataCatalogTable(BaseModel): namespace: Optional[str] = None """Table namespace""" - rolling_policy: Optional[ConfigCloudflarePipelinesR2DataCatalogTableRollingPolicy] = None + rolling_policy: Optional[ConfigCloudflarePipelinesR2DataCatalogTablePublicRollingPolicy] = None """Rolling policy for file sinks (when & why to close a file and open a new one).""" -Config: TypeAlias = Union[ConfigCloudflarePipelinesR2Table, ConfigCloudflarePipelinesR2DataCatalogTable] +Config: TypeAlias = Union[ConfigCloudflarePipelinesR2TablePublic, ConfigCloudflarePipelinesR2DataCatalogTablePublic] class FormatJson(BaseModel): diff --git a/src/cloudflare/types/pipelines/sink_list_response.py b/src/cloudflare/types/pipelines/sink_list_response.py index 5509131b2e1..46a3d74822e 100644 --- a/src/cloudflare/types/pipelines/sink_list_response.py +++ b/src/cloudflare/types/pipelines/sink_list_response.py @@ -12,13 +12,12 @@ __all__ = [ "SinkListResponse", "Config", - "ConfigCloudflarePipelinesR2Table", - "ConfigCloudflarePipelinesR2TableCredentials", - "ConfigCloudflarePipelinesR2TableFileNaming", - "ConfigCloudflarePipelinesR2TablePartitioning", - "ConfigCloudflarePipelinesR2TableRollingPolicy", - "ConfigCloudflarePipelinesR2DataCatalogTable", - "ConfigCloudflarePipelinesR2DataCatalogTableRollingPolicy", + "ConfigCloudflarePipelinesR2TablePublic", + "ConfigCloudflarePipelinesR2TablePublicFileNaming", + "ConfigCloudflarePipelinesR2TablePublicPartitioning", + "ConfigCloudflarePipelinesR2TablePublicRollingPolicy", + "ConfigCloudflarePipelinesR2DataCatalogTablePublic", + "ConfigCloudflarePipelinesR2DataCatalogTablePublicRollingPolicy", "Format", "FormatJson", "FormatParquet", @@ -41,15 +40,7 @@ ] -class ConfigCloudflarePipelinesR2TableCredentials(BaseModel): - access_key_id: str - """Cloudflare Account ID for the bucket""" - - secret_access_key: str - """Cloudflare Account ID for the bucket""" - - -class ConfigCloudflarePipelinesR2TableFileNaming(BaseModel): +class ConfigCloudflarePipelinesR2TablePublicFileNaming(BaseModel): """Controls filename prefix/suffix and strategy.""" prefix: Optional[str] = None @@ -62,14 +53,14 @@ class ConfigCloudflarePipelinesR2TableFileNaming(BaseModel): """This will overwrite the default file suffix. i.e .parquet, use with caution""" -class ConfigCloudflarePipelinesR2TablePartitioning(BaseModel): +class ConfigCloudflarePipelinesR2TablePublicPartitioning(BaseModel): """Data-layout partitioning for sinks.""" time_pattern: Optional[str] = None """The pattern of the date string""" -class ConfigCloudflarePipelinesR2TableRollingPolicy(BaseModel): +class ConfigCloudflarePipelinesR2TablePublicRollingPolicy(BaseModel): """Rolling policy for file sinks (when & why to close a file and open a new one).""" file_size_bytes: Optional[int] = None @@ -82,32 +73,32 @@ class ConfigCloudflarePipelinesR2TableRollingPolicy(BaseModel): """Number of seconds to wait before rolling over to a new file""" -class ConfigCloudflarePipelinesR2Table(BaseModel): +class ConfigCloudflarePipelinesR2TablePublic(BaseModel): + """R2 Sink public configuration.""" + account_id: str """Cloudflare Account ID for the bucket""" bucket: str """R2 Bucket to write to""" - credentials: ConfigCloudflarePipelinesR2TableCredentials - - file_naming: Optional[ConfigCloudflarePipelinesR2TableFileNaming] = None + file_naming: Optional[ConfigCloudflarePipelinesR2TablePublicFileNaming] = None """Controls filename prefix/suffix and strategy.""" jurisdiction: Optional[str] = None """Jurisdiction this bucket is hosted in""" - partitioning: Optional[ConfigCloudflarePipelinesR2TablePartitioning] = None + partitioning: Optional[ConfigCloudflarePipelinesR2TablePublicPartitioning] = None """Data-layout partitioning for sinks.""" path: Optional[str] = None """Subpath within the bucket to write to""" - rolling_policy: Optional[ConfigCloudflarePipelinesR2TableRollingPolicy] = None + rolling_policy: Optional[ConfigCloudflarePipelinesR2TablePublicRollingPolicy] = None """Rolling policy for file sinks (when & why to close a file and open a new one).""" -class ConfigCloudflarePipelinesR2DataCatalogTableRollingPolicy(BaseModel): +class ConfigCloudflarePipelinesR2DataCatalogTablePublicRollingPolicy(BaseModel): """Rolling policy for file sinks (when & why to close a file and open a new one).""" file_size_bytes: Optional[int] = None @@ -120,11 +111,8 @@ class ConfigCloudflarePipelinesR2DataCatalogTableRollingPolicy(BaseModel): """Number of seconds to wait before rolling over to a new file""" -class ConfigCloudflarePipelinesR2DataCatalogTable(BaseModel): - """R2 Data Catalog Sink""" - - token: str - """Authentication token""" +class ConfigCloudflarePipelinesR2DataCatalogTablePublic(BaseModel): + """R2 Data Catalog Sink public configuration.""" account_id: str """Cloudflare Account ID""" @@ -138,11 +126,11 @@ class ConfigCloudflarePipelinesR2DataCatalogTable(BaseModel): namespace: Optional[str] = None """Table namespace""" - rolling_policy: Optional[ConfigCloudflarePipelinesR2DataCatalogTableRollingPolicy] = None + rolling_policy: Optional[ConfigCloudflarePipelinesR2DataCatalogTablePublicRollingPolicy] = None """Rolling policy for file sinks (when & why to close a file and open a new one).""" -Config: TypeAlias = Union[ConfigCloudflarePipelinesR2Table, ConfigCloudflarePipelinesR2DataCatalogTable] +Config: TypeAlias = Union[ConfigCloudflarePipelinesR2TablePublic, ConfigCloudflarePipelinesR2DataCatalogTablePublic] class FormatJson(BaseModel): diff --git a/src/cloudflare/types/radar/ai/inference_timeseries_groups_v2_params.py b/src/cloudflare/types/radar/ai/inference_timeseries_groups_v2_params.py index db5f948dee9..dd3309d32de 100644 --- a/src/cloudflare/types/radar/ai/inference_timeseries_groups_v2_params.py +++ b/src/cloudflare/types/radar/ai/inference_timeseries_groups_v2_params.py @@ -71,7 +71,7 @@ class InferenceTimeseriesGroupsV2Params(TypedDict, total=False): name: SequenceNotStr[str] """Array of names used to label the series in the response.""" - normalization: Literal["PERCENTAGE_CHANGE", "MIN0_MAX"] + normalization: Literal["PERCENTAGE", "MIN0_MAX"] """Normalization method applied to the results. Refer to diff --git a/src/cloudflare/types/radar/geolocation_get_response.py b/src/cloudflare/types/radar/geolocation_get_response.py index bc5aaecc88d..d172f8872e1 100644 --- a/src/cloudflare/types/radar/geolocation_get_response.py +++ b/src/cloudflare/types/radar/geolocation_get_response.py @@ -1,5 +1,6 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. +from typing import Optional from typing_extensions import Literal from pydantic import Field as FieldInfo @@ -23,6 +24,8 @@ class GeolocationParentParent(BaseModel): type: Literal["CONTINENT", "COUNTRY", "ADM1"] """The type of the geolocation.""" + code: Optional[str] = None + class GeolocationParent(BaseModel): geo_id: str = FieldInfo(alias="geoId") @@ -40,6 +43,8 @@ class GeolocationParent(BaseModel): type: Literal["CONTINENT", "COUNTRY", "ADM1"] """The type of the geolocation.""" + code: Optional[str] = None + class Geolocation(BaseModel): geo_id: str = FieldInfo(alias="geoId") @@ -57,6 +62,8 @@ class Geolocation(BaseModel): type: Literal["CONTINENT", "COUNTRY", "ADM1"] """The type of the geolocation.""" + code: Optional[str] = None + class GeolocationGetResponse(BaseModel): geolocation: Geolocation diff --git a/src/cloudflare/types/radar/geolocation_list_response.py b/src/cloudflare/types/radar/geolocation_list_response.py index 5dbd2bc4ebc..cb79a57d530 100644 --- a/src/cloudflare/types/radar/geolocation_list_response.py +++ b/src/cloudflare/types/radar/geolocation_list_response.py @@ -1,6 +1,6 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List +from typing import List, Optional from typing_extensions import Literal from pydantic import Field as FieldInfo @@ -24,6 +24,8 @@ class GeolocationParentParent(BaseModel): type: Literal["CONTINENT", "COUNTRY", "ADM1"] """The type of the geolocation.""" + code: Optional[str] = None + class GeolocationParent(BaseModel): geo_id: str = FieldInfo(alias="geoId") @@ -41,6 +43,8 @@ class GeolocationParent(BaseModel): type: Literal["CONTINENT", "COUNTRY", "ADM1"] """The type of the geolocation.""" + code: Optional[str] = None + class Geolocation(BaseModel): geo_id: str = FieldInfo(alias="geoId") @@ -58,6 +62,8 @@ class Geolocation(BaseModel): type: Literal["CONTINENT", "COUNTRY", "ADM1"] """The type of the geolocation.""" + code: Optional[str] = None + class GeolocationListResponse(BaseModel): geolocations: List[Geolocation] diff --git a/src/cloudflare/types/rulesets/phase.py b/src/cloudflare/types/rulesets/phase.py index f7918ae46f6..7993a770ba1 100644 --- a/src/cloudflare/types/rulesets/phase.py +++ b/src/cloudflare/types/rulesets/phase.py @@ -21,6 +21,7 @@ "http_request_sanitize", "http_request_sbfm", "http_request_transform", + "http_response_cache_settings", "http_response_compression", "http_response_firewall_managed", "http_response_headers_transform", diff --git a/src/cloudflare/types/rulesets/phase_get_response.py b/src/cloudflare/types/rulesets/phase_get_response.py index 3b3e517d373..b9552130335 100644 --- a/src/cloudflare/types/rulesets/phase_get_response.py +++ b/src/cloudflare/types/rulesets/phase_get_response.py @@ -4,6 +4,8 @@ from datetime import datetime from typing_extensions import Literal, Annotated, TypeAlias +from pydantic import Field as FieldInfo + from .kind import Kind from .phase import Phase from .logging import Logging @@ -35,6 +37,59 @@ "RuleRulesetsJSChallengeRule", "RuleRulesetsJSChallengeRuleExposedCredentialCheck", "RuleRulesetsJSChallengeRuleRatelimit", + "RuleRulesetsSetCacheControlRule", + "RuleRulesetsSetCacheControlRuleActionParameters", + "RuleRulesetsSetCacheControlRuleActionParametersImmutable", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAge", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCache", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStore", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransform", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivate", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublic", + "RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxage", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfError", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleExposedCredentialCheck", + "RuleRulesetsSetCacheControlRuleRatelimit", + "RuleRulesetsSetCacheTagsRule", + "RuleRulesetsSetCacheTagsRuleActionParameters", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleExposedCredentialCheck", + "RuleRulesetsSetCacheTagsRuleRatelimit", ] @@ -232,6 +287,711 @@ class RuleRulesetsJSChallengeRule(BaseModel): """The reference of the rule (the rule's ID by default).""" +class RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersImmutable: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMaxAge: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective(BaseModel): + """Set the directive with optional qualifiers.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: Optional[List[str]] = None + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoCache: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoStore: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoTransform: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective(BaseModel): + """Set the directive with optional qualifiers.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: Optional[List[str]] = None + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPrivate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPublic: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersSMaxage: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleIfError: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParameters(BaseModel): + """The parameters configuring the rule's action.""" + + immutable: Optional[RuleRulesetsSetCacheControlRuleActionParametersImmutable] = None + """A cache-control directive configuration.""" + + max_age: Optional[RuleRulesetsSetCacheControlRuleActionParametersMaxAge] = FieldInfo(alias="max-age", default=None) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + must_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate] = FieldInfo( + alias="must-revalidate", default=None + ) + """A cache-control directive configuration.""" + + must_understand: Optional[RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand] = FieldInfo( + alias="must-understand", default=None + ) + """A cache-control directive configuration.""" + + no_cache: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoCache] = FieldInfo( + alias="no-cache", default=None + ) + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + no_store: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoStore] = FieldInfo( + alias="no-store", default=None + ) + """A cache-control directive configuration.""" + + no_transform: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoTransform] = FieldInfo( + alias="no-transform", default=None + ) + """A cache-control directive configuration.""" + + private: Optional[RuleRulesetsSetCacheControlRuleActionParametersPrivate] = None + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + proxy_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate] = FieldInfo( + alias="proxy-revalidate", default=None + ) + """A cache-control directive configuration.""" + + public: Optional[RuleRulesetsSetCacheControlRuleActionParametersPublic] = None + """A cache-control directive configuration.""" + + s_maxage: Optional[RuleRulesetsSetCacheControlRuleActionParametersSMaxage] = FieldInfo( + alias="s-maxage", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_if_error: Optional[RuleRulesetsSetCacheControlRuleActionParametersStaleIfError] = FieldInfo( + alias="stale-if-error", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_while_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate] = FieldInfo( + alias="stale-while-revalidate", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + +class RuleRulesetsSetCacheControlRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheControlRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheControlRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["set_cache_control"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheControlRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsSetCacheControlRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsSetCacheControlRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues(BaseModel): + """Add cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression(BaseModel): + """Add cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues(BaseModel): + """Remove cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression(BaseModel): + """Remove cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues(BaseModel): + """Set cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression(BaseModel): + """Set cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +RuleRulesetsSetCacheTagsRuleActionParameters: TypeAlias = Union[ + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression, +] + + +class RuleRulesetsSetCacheTagsRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheTagsRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheTagsRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["set_cache_tags"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheTagsRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsSetCacheTagsRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsSetCacheTagsRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + Rule: TypeAlias = Annotated[ Union[ BlockRule, @@ -249,7 +1009,9 @@ class RuleRulesetsJSChallengeRule(BaseModel): RouteRule, ScoreRule, ServeErrorRule, + RuleRulesetsSetCacheControlRule, SetCacheSettingsRule, + RuleRulesetsSetCacheTagsRule, SetConfigRule, SkipRule, ], diff --git a/src/cloudflare/types/rulesets/phase_update_params.py b/src/cloudflare/types/rulesets/phase_update_params.py index 84e20caaf86..1a17a4c6063 100644 --- a/src/cloudflare/types/rulesets/phase_update_params.py +++ b/src/cloudflare/types/rulesets/phase_update_params.py @@ -3,9 +3,10 @@ from __future__ import annotations from typing import Union, Iterable -from typing_extensions import Literal, Required, TypeAlias, TypedDict +from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict from ..._types import SequenceNotStr +from ..._utils import PropertyInfo from .logging_param import LoggingParam from .log_rule_param import LogRuleParam from .skip_rule_param import SkipRuleParam @@ -33,6 +34,59 @@ "RuleRulesetsJSChallengeRule", "RuleRulesetsJSChallengeRuleExposedCredentialCheck", "RuleRulesetsJSChallengeRuleRatelimit", + "RuleRulesetsSetCacheControlRule", + "RuleRulesetsSetCacheControlRuleActionParameters", + "RuleRulesetsSetCacheControlRuleActionParametersImmutable", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAge", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCache", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStore", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransform", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivate", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublic", + "RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxage", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfError", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleExposedCredentialCheck", + "RuleRulesetsSetCacheControlRuleRatelimit", + "RuleRulesetsSetCacheTagsRule", + "RuleRulesetsSetCacheTagsRuleActionParameters", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleExposedCredentialCheck", + "RuleRulesetsSetCacheTagsRuleRatelimit", ] @@ -229,6 +283,688 @@ class RuleRulesetsJSChallengeRule(TypedDict, total=False): """The reference of the rule (the rule's ID by default).""" +class RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersImmutable: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective(TypedDict, total=False): + """Set the directive with a duration value in seconds.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + value: Required[int] + """The duration value in seconds for the directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMaxAge: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective(TypedDict, total=False): + """Set the directive with optional qualifiers.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: SequenceNotStr[str] + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoCache: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoStore: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoTransform: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective(TypedDict, total=False): + """Set the directive with optional qualifiers.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: SequenceNotStr[str] + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPrivate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPublic: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective(TypedDict, total=False): + """Set the directive with a duration value in seconds.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + value: Required[int] + """The duration value in seconds for the directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersSMaxage: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective(TypedDict, total=False): + """Set the directive with a duration value in seconds.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + value: Required[int] + """The duration value in seconds for the directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleIfError: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective(TypedDict, total=False): + """Set the directive with a duration value in seconds.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + value: Required[int] + """The duration value in seconds for the directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + immutable: RuleRulesetsSetCacheControlRuleActionParametersImmutable + """A cache-control directive configuration.""" + + max_age: Annotated[RuleRulesetsSetCacheControlRuleActionParametersMaxAge, PropertyInfo(alias="max-age")] + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + must_revalidate: Annotated[ + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate, PropertyInfo(alias="must-revalidate") + ] + """A cache-control directive configuration.""" + + must_understand: Annotated[ + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand, PropertyInfo(alias="must-understand") + ] + """A cache-control directive configuration.""" + + no_cache: Annotated[RuleRulesetsSetCacheControlRuleActionParametersNoCache, PropertyInfo(alias="no-cache")] + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + no_store: Annotated[RuleRulesetsSetCacheControlRuleActionParametersNoStore, PropertyInfo(alias="no-store")] + """A cache-control directive configuration.""" + + no_transform: Annotated[ + RuleRulesetsSetCacheControlRuleActionParametersNoTransform, PropertyInfo(alias="no-transform") + ] + """A cache-control directive configuration.""" + + private: RuleRulesetsSetCacheControlRuleActionParametersPrivate + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + proxy_revalidate: Annotated[ + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate, PropertyInfo(alias="proxy-revalidate") + ] + """A cache-control directive configuration.""" + + public: RuleRulesetsSetCacheControlRuleActionParametersPublic + """A cache-control directive configuration.""" + + s_maxage: Annotated[RuleRulesetsSetCacheControlRuleActionParametersSMaxage, PropertyInfo(alias="s-maxage")] + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_if_error: Annotated[ + RuleRulesetsSetCacheControlRuleActionParametersStaleIfError, PropertyInfo(alias="stale-if-error") + ] + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_while_revalidate: Annotated[ + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate, + PropertyInfo(alias="stale-while-revalidate"), + ] + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + +class RuleRulesetsSetCacheControlRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheControlRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheControlRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["set_cache_control"] + """The action to perform when the rule matches.""" + + action_parameters: RuleRulesetsSetCacheControlRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: RuleRulesetsSetCacheControlRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ratelimit: RuleRulesetsSetCacheControlRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues(TypedDict, total=False): + """Add cache tags using a list of values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + values: Required[SequenceNotStr[str]] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression(TypedDict, total=False): + """Add cache tags using an expression.""" + + expression: Required[str] + """An expression that evaluates to an array of cache tag values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues(TypedDict, total=False): + """Remove cache tags using a list of values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + values: Required[SequenceNotStr[str]] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression(TypedDict, total=False): + """Remove cache tags using an expression.""" + + expression: Required[str] + """An expression that evaluates to an array of cache tag values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues(TypedDict, total=False): + """Set cache tags using a list of values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + values: Required[SequenceNotStr[str]] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression(TypedDict, total=False): + """Set cache tags using an expression.""" + + expression: Required[str] + """An expression that evaluates to an array of cache tag values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + +RuleRulesetsSetCacheTagsRuleActionParameters: TypeAlias = Union[ + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression, +] + + +class RuleRulesetsSetCacheTagsRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheTagsRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheTagsRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["set_cache_tags"] + """The action to perform when the rule matches.""" + + action_parameters: RuleRulesetsSetCacheTagsRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: RuleRulesetsSetCacheTagsRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ratelimit: RuleRulesetsSetCacheTagsRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + Rule: TypeAlias = Union[ BlockRuleParam, RuleRulesetsChallengeRule, @@ -245,7 +981,9 @@ class RuleRulesetsJSChallengeRule(TypedDict, total=False): RouteRuleParam, ScoreRuleParam, ServeErrorRuleParam, + RuleRulesetsSetCacheControlRule, SetCacheSettingsRuleParam, + RuleRulesetsSetCacheTagsRule, SetConfigRuleParam, SkipRuleParam, ] diff --git a/src/cloudflare/types/rulesets/phase_update_response.py b/src/cloudflare/types/rulesets/phase_update_response.py index bae558d023c..9b06f4b181e 100644 --- a/src/cloudflare/types/rulesets/phase_update_response.py +++ b/src/cloudflare/types/rulesets/phase_update_response.py @@ -4,6 +4,8 @@ from datetime import datetime from typing_extensions import Literal, Annotated, TypeAlias +from pydantic import Field as FieldInfo + from .kind import Kind from .phase import Phase from .logging import Logging @@ -35,6 +37,59 @@ "RuleRulesetsJSChallengeRule", "RuleRulesetsJSChallengeRuleExposedCredentialCheck", "RuleRulesetsJSChallengeRuleRatelimit", + "RuleRulesetsSetCacheControlRule", + "RuleRulesetsSetCacheControlRuleActionParameters", + "RuleRulesetsSetCacheControlRuleActionParametersImmutable", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAge", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCache", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStore", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransform", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivate", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublic", + "RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxage", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfError", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleExposedCredentialCheck", + "RuleRulesetsSetCacheControlRuleRatelimit", + "RuleRulesetsSetCacheTagsRule", + "RuleRulesetsSetCacheTagsRuleActionParameters", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleExposedCredentialCheck", + "RuleRulesetsSetCacheTagsRuleRatelimit", ] @@ -232,6 +287,711 @@ class RuleRulesetsJSChallengeRule(BaseModel): """The reference of the rule (the rule's ID by default).""" +class RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersImmutable: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMaxAge: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective(BaseModel): + """Set the directive with optional qualifiers.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: Optional[List[str]] = None + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoCache: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoStore: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoTransform: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective(BaseModel): + """Set the directive with optional qualifiers.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: Optional[List[str]] = None + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPrivate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPublic: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersSMaxage: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleIfError: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParameters(BaseModel): + """The parameters configuring the rule's action.""" + + immutable: Optional[RuleRulesetsSetCacheControlRuleActionParametersImmutable] = None + """A cache-control directive configuration.""" + + max_age: Optional[RuleRulesetsSetCacheControlRuleActionParametersMaxAge] = FieldInfo(alias="max-age", default=None) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + must_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate] = FieldInfo( + alias="must-revalidate", default=None + ) + """A cache-control directive configuration.""" + + must_understand: Optional[RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand] = FieldInfo( + alias="must-understand", default=None + ) + """A cache-control directive configuration.""" + + no_cache: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoCache] = FieldInfo( + alias="no-cache", default=None + ) + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + no_store: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoStore] = FieldInfo( + alias="no-store", default=None + ) + """A cache-control directive configuration.""" + + no_transform: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoTransform] = FieldInfo( + alias="no-transform", default=None + ) + """A cache-control directive configuration.""" + + private: Optional[RuleRulesetsSetCacheControlRuleActionParametersPrivate] = None + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + proxy_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate] = FieldInfo( + alias="proxy-revalidate", default=None + ) + """A cache-control directive configuration.""" + + public: Optional[RuleRulesetsSetCacheControlRuleActionParametersPublic] = None + """A cache-control directive configuration.""" + + s_maxage: Optional[RuleRulesetsSetCacheControlRuleActionParametersSMaxage] = FieldInfo( + alias="s-maxage", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_if_error: Optional[RuleRulesetsSetCacheControlRuleActionParametersStaleIfError] = FieldInfo( + alias="stale-if-error", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_while_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate] = FieldInfo( + alias="stale-while-revalidate", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + +class RuleRulesetsSetCacheControlRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheControlRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheControlRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["set_cache_control"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheControlRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsSetCacheControlRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsSetCacheControlRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues(BaseModel): + """Add cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression(BaseModel): + """Add cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues(BaseModel): + """Remove cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression(BaseModel): + """Remove cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues(BaseModel): + """Set cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression(BaseModel): + """Set cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +RuleRulesetsSetCacheTagsRuleActionParameters: TypeAlias = Union[ + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression, +] + + +class RuleRulesetsSetCacheTagsRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheTagsRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheTagsRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["set_cache_tags"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheTagsRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsSetCacheTagsRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsSetCacheTagsRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + Rule: TypeAlias = Annotated[ Union[ BlockRule, @@ -249,7 +1009,9 @@ class RuleRulesetsJSChallengeRule(BaseModel): RouteRule, ScoreRule, ServeErrorRule, + RuleRulesetsSetCacheControlRule, SetCacheSettingsRule, + RuleRulesetsSetCacheTagsRule, SetConfigRule, SkipRule, ], diff --git a/src/cloudflare/types/rulesets/phases/version_get_response.py b/src/cloudflare/types/rulesets/phases/version_get_response.py index 1f7a8e398c8..d6f80e98ed8 100644 --- a/src/cloudflare/types/rulesets/phases/version_get_response.py +++ b/src/cloudflare/types/rulesets/phases/version_get_response.py @@ -4,6 +4,8 @@ from datetime import datetime from typing_extensions import Literal, Annotated, TypeAlias +from pydantic import Field as FieldInfo + from ..kind import Kind from ..phase import Phase from ..logging import Logging @@ -35,6 +37,59 @@ "RuleRulesetsJSChallengeRule", "RuleRulesetsJSChallengeRuleExposedCredentialCheck", "RuleRulesetsJSChallengeRuleRatelimit", + "RuleRulesetsSetCacheControlRule", + "RuleRulesetsSetCacheControlRuleActionParameters", + "RuleRulesetsSetCacheControlRuleActionParametersImmutable", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAge", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCache", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStore", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransform", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivate", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublic", + "RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxage", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfError", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleExposedCredentialCheck", + "RuleRulesetsSetCacheControlRuleRatelimit", + "RuleRulesetsSetCacheTagsRule", + "RuleRulesetsSetCacheTagsRuleActionParameters", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleExposedCredentialCheck", + "RuleRulesetsSetCacheTagsRuleRatelimit", ] @@ -232,6 +287,711 @@ class RuleRulesetsJSChallengeRule(BaseModel): """The reference of the rule (the rule's ID by default).""" +class RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersImmutable: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMaxAge: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective(BaseModel): + """Set the directive with optional qualifiers.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: Optional[List[str]] = None + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoCache: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoStore: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoTransform: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective(BaseModel): + """Set the directive with optional qualifiers.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: Optional[List[str]] = None + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPrivate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPublic: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersSMaxage: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleIfError: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParameters(BaseModel): + """The parameters configuring the rule's action.""" + + immutable: Optional[RuleRulesetsSetCacheControlRuleActionParametersImmutable] = None + """A cache-control directive configuration.""" + + max_age: Optional[RuleRulesetsSetCacheControlRuleActionParametersMaxAge] = FieldInfo(alias="max-age", default=None) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + must_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate] = FieldInfo( + alias="must-revalidate", default=None + ) + """A cache-control directive configuration.""" + + must_understand: Optional[RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand] = FieldInfo( + alias="must-understand", default=None + ) + """A cache-control directive configuration.""" + + no_cache: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoCache] = FieldInfo( + alias="no-cache", default=None + ) + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + no_store: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoStore] = FieldInfo( + alias="no-store", default=None + ) + """A cache-control directive configuration.""" + + no_transform: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoTransform] = FieldInfo( + alias="no-transform", default=None + ) + """A cache-control directive configuration.""" + + private: Optional[RuleRulesetsSetCacheControlRuleActionParametersPrivate] = None + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + proxy_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate] = FieldInfo( + alias="proxy-revalidate", default=None + ) + """A cache-control directive configuration.""" + + public: Optional[RuleRulesetsSetCacheControlRuleActionParametersPublic] = None + """A cache-control directive configuration.""" + + s_maxage: Optional[RuleRulesetsSetCacheControlRuleActionParametersSMaxage] = FieldInfo( + alias="s-maxage", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_if_error: Optional[RuleRulesetsSetCacheControlRuleActionParametersStaleIfError] = FieldInfo( + alias="stale-if-error", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_while_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate] = FieldInfo( + alias="stale-while-revalidate", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + +class RuleRulesetsSetCacheControlRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheControlRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheControlRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["set_cache_control"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheControlRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsSetCacheControlRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsSetCacheControlRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues(BaseModel): + """Add cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression(BaseModel): + """Add cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues(BaseModel): + """Remove cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression(BaseModel): + """Remove cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues(BaseModel): + """Set cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression(BaseModel): + """Set cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +RuleRulesetsSetCacheTagsRuleActionParameters: TypeAlias = Union[ + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression, +] + + +class RuleRulesetsSetCacheTagsRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheTagsRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheTagsRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["set_cache_tags"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheTagsRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsSetCacheTagsRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsSetCacheTagsRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + Rule: TypeAlias = Annotated[ Union[ BlockRule, @@ -249,7 +1009,9 @@ class RuleRulesetsJSChallengeRule(BaseModel): RouteRule, ScoreRule, ServeErrorRule, + RuleRulesetsSetCacheControlRule, SetCacheSettingsRule, + RuleRulesetsSetCacheTagsRule, SetConfigRule, SkipRule, ], diff --git a/src/cloudflare/types/rulesets/rule_create_params.py b/src/cloudflare/types/rulesets/rule_create_params.py index a8435dbd1c2..af5468057cd 100644 --- a/src/cloudflare/types/rulesets/rule_create_params.py +++ b/src/cloudflare/types/rulesets/rule_create_params.py @@ -3,10 +3,11 @@ from __future__ import annotations from typing import Dict, List, Union, Iterable -from typing_extensions import Literal, Required, TypeAlias, TypedDict +from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict from .phase import Phase from ..._types import SequenceNotStr +from ..._utils import PropertyInfo from .logging_param import LoggingParam __all__ = [ @@ -154,6 +155,53 @@ "ServeErrorRulePositionAfterPosition", "ServeErrorRulePositionIndexPosition", "ServeErrorRuleRatelimit", + "SetCacheControlRule", + "SetCacheControlRuleActionParameters", + "SetCacheControlRuleActionParametersImmutable", + "SetCacheControlRuleActionParametersImmutableSetDirective", + "SetCacheControlRuleActionParametersImmutableRemoveDirective", + "SetCacheControlRuleActionParametersMaxAge", + "SetCacheControlRuleActionParametersMaxAgeSetDirective", + "SetCacheControlRuleActionParametersMaxAgeRemoveDirective", + "SetCacheControlRuleActionParametersMustRevalidate", + "SetCacheControlRuleActionParametersMustRevalidateSetDirective", + "SetCacheControlRuleActionParametersMustRevalidateRemoveDirective", + "SetCacheControlRuleActionParametersMustUnderstand", + "SetCacheControlRuleActionParametersMustUnderstandSetDirective", + "SetCacheControlRuleActionParametersMustUnderstandRemoveDirective", + "SetCacheControlRuleActionParametersNoCache", + "SetCacheControlRuleActionParametersNoCacheSetDirective", + "SetCacheControlRuleActionParametersNoCacheRemoveDirective", + "SetCacheControlRuleActionParametersNoStore", + "SetCacheControlRuleActionParametersNoStoreSetDirective", + "SetCacheControlRuleActionParametersNoStoreRemoveDirective", + "SetCacheControlRuleActionParametersNoTransform", + "SetCacheControlRuleActionParametersNoTransformSetDirective", + "SetCacheControlRuleActionParametersNoTransformRemoveDirective", + "SetCacheControlRuleActionParametersPrivate", + "SetCacheControlRuleActionParametersPrivateSetDirective", + "SetCacheControlRuleActionParametersPrivateRemoveDirective", + "SetCacheControlRuleActionParametersProxyRevalidate", + "SetCacheControlRuleActionParametersProxyRevalidateSetDirective", + "SetCacheControlRuleActionParametersProxyRevalidateRemoveDirective", + "SetCacheControlRuleActionParametersPublic", + "SetCacheControlRuleActionParametersPublicSetDirective", + "SetCacheControlRuleActionParametersPublicRemoveDirective", + "SetCacheControlRuleActionParametersSMaxage", + "SetCacheControlRuleActionParametersSMaxageSetDirective", + "SetCacheControlRuleActionParametersSMaxageRemoveDirective", + "SetCacheControlRuleActionParametersStaleIfError", + "SetCacheControlRuleActionParametersStaleIfErrorSetDirective", + "SetCacheControlRuleActionParametersStaleIfErrorRemoveDirective", + "SetCacheControlRuleActionParametersStaleWhileRevalidate", + "SetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective", + "SetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective", + "SetCacheControlRuleExposedCredentialCheck", + "SetCacheControlRulePosition", + "SetCacheControlRulePositionBeforePosition", + "SetCacheControlRulePositionAfterPosition", + "SetCacheControlRulePositionIndexPosition", + "SetCacheControlRuleRatelimit", "SetCacheSettingsRule", "SetCacheSettingsRuleActionParameters", "SetCacheSettingsRuleActionParametersBrowserTTL", @@ -177,6 +225,20 @@ "SetCacheSettingsRulePositionAfterPosition", "SetCacheSettingsRulePositionIndexPosition", "SetCacheSettingsRuleRatelimit", + "SetCacheTagsRule", + "SetCacheTagsRuleActionParameters", + "SetCacheTagsRuleActionParametersAddCacheTagsValues", + "SetCacheTagsRuleActionParametersAddCacheTagsExpression", + "SetCacheTagsRuleActionParametersRemoveCacheTagsValues", + "SetCacheTagsRuleActionParametersRemoveCacheTagsExpression", + "SetCacheTagsRuleActionParametersSetCacheTagsValues", + "SetCacheTagsRuleActionParametersSetCacheTagsExpression", + "SetCacheTagsRuleExposedCredentialCheck", + "SetCacheTagsRulePosition", + "SetCacheTagsRulePositionBeforePosition", + "SetCacheTagsRulePositionAfterPosition", + "SetCacheTagsRulePositionIndexPosition", + "SetCacheTagsRuleRatelimit", "SetConfigurationRule", "SetConfigurationRuleActionParameters", "SetConfigurationRuleActionParametersAutominify", @@ -2541,6 +2603,558 @@ class ServeErrorRuleRatelimit(TypedDict, total=False): """ +class SetCacheControlRule(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["set_cache_control"] + """The action to perform when the rule matches.""" + + action_parameters: SetCacheControlRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: SetCacheControlRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: SetCacheControlRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: SetCacheControlRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class SetCacheControlRuleActionParametersImmutableSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersImmutableRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersImmutable: TypeAlias = Union[ + SetCacheControlRuleActionParametersImmutableSetDirective, + SetCacheControlRuleActionParametersImmutableRemoveDirective, +] + + +class SetCacheControlRuleActionParametersMaxAgeSetDirective(TypedDict, total=False): + """Set the directive with a duration value in seconds.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + value: Required[int] + """The duration value in seconds for the directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersMaxAgeRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersMaxAge: TypeAlias = Union[ + SetCacheControlRuleActionParametersMaxAgeSetDirective, SetCacheControlRuleActionParametersMaxAgeRemoveDirective +] + + +class SetCacheControlRuleActionParametersMustRevalidateSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersMustRevalidateRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersMustRevalidate: TypeAlias = Union[ + SetCacheControlRuleActionParametersMustRevalidateSetDirective, + SetCacheControlRuleActionParametersMustRevalidateRemoveDirective, +] + + +class SetCacheControlRuleActionParametersMustUnderstandSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersMustUnderstandRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersMustUnderstand: TypeAlias = Union[ + SetCacheControlRuleActionParametersMustUnderstandSetDirective, + SetCacheControlRuleActionParametersMustUnderstandRemoveDirective, +] + + +class SetCacheControlRuleActionParametersNoCacheSetDirective(TypedDict, total=False): + """Set the directive with optional qualifiers.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: SequenceNotStr[str] + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class SetCacheControlRuleActionParametersNoCacheRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersNoCache: TypeAlias = Union[ + SetCacheControlRuleActionParametersNoCacheSetDirective, SetCacheControlRuleActionParametersNoCacheRemoveDirective +] + + +class SetCacheControlRuleActionParametersNoStoreSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersNoStoreRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersNoStore: TypeAlias = Union[ + SetCacheControlRuleActionParametersNoStoreSetDirective, SetCacheControlRuleActionParametersNoStoreRemoveDirective +] + + +class SetCacheControlRuleActionParametersNoTransformSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersNoTransformRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersNoTransform: TypeAlias = Union[ + SetCacheControlRuleActionParametersNoTransformSetDirective, + SetCacheControlRuleActionParametersNoTransformRemoveDirective, +] + + +class SetCacheControlRuleActionParametersPrivateSetDirective(TypedDict, total=False): + """Set the directive with optional qualifiers.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: SequenceNotStr[str] + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class SetCacheControlRuleActionParametersPrivateRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersPrivate: TypeAlias = Union[ + SetCacheControlRuleActionParametersPrivateSetDirective, SetCacheControlRuleActionParametersPrivateRemoveDirective +] + + +class SetCacheControlRuleActionParametersProxyRevalidateSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersProxyRevalidateRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersProxyRevalidate: TypeAlias = Union[ + SetCacheControlRuleActionParametersProxyRevalidateSetDirective, + SetCacheControlRuleActionParametersProxyRevalidateRemoveDirective, +] + + +class SetCacheControlRuleActionParametersPublicSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersPublicRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersPublic: TypeAlias = Union[ + SetCacheControlRuleActionParametersPublicSetDirective, SetCacheControlRuleActionParametersPublicRemoveDirective +] + + +class SetCacheControlRuleActionParametersSMaxageSetDirective(TypedDict, total=False): + """Set the directive with a duration value in seconds.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + value: Required[int] + """The duration value in seconds for the directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersSMaxageRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersSMaxage: TypeAlias = Union[ + SetCacheControlRuleActionParametersSMaxageSetDirective, SetCacheControlRuleActionParametersSMaxageRemoveDirective +] + + +class SetCacheControlRuleActionParametersStaleIfErrorSetDirective(TypedDict, total=False): + """Set the directive with a duration value in seconds.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + value: Required[int] + """The duration value in seconds for the directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersStaleIfErrorRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersStaleIfError: TypeAlias = Union[ + SetCacheControlRuleActionParametersStaleIfErrorSetDirective, + SetCacheControlRuleActionParametersStaleIfErrorRemoveDirective, +] + + +class SetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective(TypedDict, total=False): + """Set the directive with a duration value in seconds.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + value: Required[int] + """The duration value in seconds for the directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersStaleWhileRevalidate: TypeAlias = Union[ + SetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective, + SetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective, +] + + +class SetCacheControlRuleActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + immutable: SetCacheControlRuleActionParametersImmutable + """A cache-control directive configuration.""" + + max_age: Annotated[SetCacheControlRuleActionParametersMaxAge, PropertyInfo(alias="max-age")] + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + must_revalidate: Annotated[SetCacheControlRuleActionParametersMustRevalidate, PropertyInfo(alias="must-revalidate")] + """A cache-control directive configuration.""" + + must_understand: Annotated[SetCacheControlRuleActionParametersMustUnderstand, PropertyInfo(alias="must-understand")] + """A cache-control directive configuration.""" + + no_cache: Annotated[SetCacheControlRuleActionParametersNoCache, PropertyInfo(alias="no-cache")] + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + no_store: Annotated[SetCacheControlRuleActionParametersNoStore, PropertyInfo(alias="no-store")] + """A cache-control directive configuration.""" + + no_transform: Annotated[SetCacheControlRuleActionParametersNoTransform, PropertyInfo(alias="no-transform")] + """A cache-control directive configuration.""" + + private: SetCacheControlRuleActionParametersPrivate + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + proxy_revalidate: Annotated[ + SetCacheControlRuleActionParametersProxyRevalidate, PropertyInfo(alias="proxy-revalidate") + ] + """A cache-control directive configuration.""" + + public: SetCacheControlRuleActionParametersPublic + """A cache-control directive configuration.""" + + s_maxage: Annotated[SetCacheControlRuleActionParametersSMaxage, PropertyInfo(alias="s-maxage")] + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_if_error: Annotated[SetCacheControlRuleActionParametersStaleIfError, PropertyInfo(alias="stale-if-error")] + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_while_revalidate: Annotated[ + SetCacheControlRuleActionParametersStaleWhileRevalidate, PropertyInfo(alias="stale-while-revalidate") + ] + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + +class SetCacheControlRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class SetCacheControlRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class SetCacheControlRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class SetCacheControlRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +SetCacheControlRulePosition: TypeAlias = Union[ + SetCacheControlRulePositionBeforePosition, + SetCacheControlRulePositionAfterPosition, + SetCacheControlRulePositionIndexPosition, +] + + +class SetCacheControlRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + class SetCacheSettingsRule(TypedDict, total=False): account_id: str """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" @@ -2856,6 +3470,15 @@ class SetCacheSettingsRuleActionParameters(TypedDict, total=False): serve_stale: SetCacheSettingsRuleActionParametersServeStale """When to serve stale content from cache.""" + strip_etags: bool + """Whether to strip ETag headers from the origin response before caching.""" + + strip_last_modified: bool + """Whether to strip Last-Modified headers from the origin response before caching.""" + + strip_set_cookie: bool + """Whether to strip Set-Cookie headers from the origin response before caching.""" + class SetCacheSettingsRuleExposedCredentialCheck(TypedDict, total=False): """Configuration for exposed credential checking.""" @@ -2947,6 +3570,205 @@ class SetCacheSettingsRuleRatelimit(TypedDict, total=False): """ +class SetCacheTagsRule(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["set_cache_tags"] + """The action to perform when the rule matches.""" + + action_parameters: SetCacheTagsRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: SetCacheTagsRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: SetCacheTagsRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: SetCacheTagsRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class SetCacheTagsRuleActionParametersAddCacheTagsValues(TypedDict, total=False): + """Add cache tags using a list of values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + values: Required[SequenceNotStr[str]] + """A list of cache tag values.""" + + +class SetCacheTagsRuleActionParametersAddCacheTagsExpression(TypedDict, total=False): + """Add cache tags using an expression.""" + + expression: Required[str] + """An expression that evaluates to an array of cache tag values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + +class SetCacheTagsRuleActionParametersRemoveCacheTagsValues(TypedDict, total=False): + """Remove cache tags using a list of values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + values: Required[SequenceNotStr[str]] + """A list of cache tag values.""" + + +class SetCacheTagsRuleActionParametersRemoveCacheTagsExpression(TypedDict, total=False): + """Remove cache tags using an expression.""" + + expression: Required[str] + """An expression that evaluates to an array of cache tag values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + +class SetCacheTagsRuleActionParametersSetCacheTagsValues(TypedDict, total=False): + """Set cache tags using a list of values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + values: Required[SequenceNotStr[str]] + """A list of cache tag values.""" + + +class SetCacheTagsRuleActionParametersSetCacheTagsExpression(TypedDict, total=False): + """Set cache tags using an expression.""" + + expression: Required[str] + """An expression that evaluates to an array of cache tag values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + +SetCacheTagsRuleActionParameters: TypeAlias = Union[ + SetCacheTagsRuleActionParametersAddCacheTagsValues, + SetCacheTagsRuleActionParametersAddCacheTagsExpression, + SetCacheTagsRuleActionParametersRemoveCacheTagsValues, + SetCacheTagsRuleActionParametersRemoveCacheTagsExpression, + SetCacheTagsRuleActionParametersSetCacheTagsValues, + SetCacheTagsRuleActionParametersSetCacheTagsExpression, +] + + +class SetCacheTagsRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class SetCacheTagsRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class SetCacheTagsRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class SetCacheTagsRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +SetCacheTagsRulePosition: TypeAlias = Union[ + SetCacheTagsRulePositionBeforePosition, SetCacheTagsRulePositionAfterPosition, SetCacheTagsRulePositionIndexPosition +] + + +class SetCacheTagsRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + class SetConfigurationRule(TypedDict, total=False): account_id: str """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" @@ -3340,7 +4162,9 @@ class SkipRuleRatelimit(TypedDict, total=False): RouteRule, ScoreRule, ServeErrorRule, + SetCacheControlRule, SetCacheSettingsRule, + SetCacheTagsRule, SetConfigurationRule, SkipRule, ] diff --git a/src/cloudflare/types/rulesets/rule_create_response.py b/src/cloudflare/types/rulesets/rule_create_response.py index 0490e4d9ed9..46f7ecd38f8 100644 --- a/src/cloudflare/types/rulesets/rule_create_response.py +++ b/src/cloudflare/types/rulesets/rule_create_response.py @@ -4,6 +4,8 @@ from datetime import datetime from typing_extensions import Literal, Annotated, TypeAlias +from pydantic import Field as FieldInfo + from .kind import Kind from .phase import Phase from .logging import Logging @@ -35,6 +37,59 @@ "RuleRulesetsJSChallengeRule", "RuleRulesetsJSChallengeRuleExposedCredentialCheck", "RuleRulesetsJSChallengeRuleRatelimit", + "RuleRulesetsSetCacheControlRule", + "RuleRulesetsSetCacheControlRuleActionParameters", + "RuleRulesetsSetCacheControlRuleActionParametersImmutable", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAge", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCache", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStore", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransform", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivate", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublic", + "RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxage", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfError", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleExposedCredentialCheck", + "RuleRulesetsSetCacheControlRuleRatelimit", + "RuleRulesetsSetCacheTagsRule", + "RuleRulesetsSetCacheTagsRuleActionParameters", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleExposedCredentialCheck", + "RuleRulesetsSetCacheTagsRuleRatelimit", ] @@ -232,6 +287,711 @@ class RuleRulesetsJSChallengeRule(BaseModel): """The reference of the rule (the rule's ID by default).""" +class RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersImmutable: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMaxAge: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective(BaseModel): + """Set the directive with optional qualifiers.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: Optional[List[str]] = None + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoCache: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoStore: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoTransform: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective(BaseModel): + """Set the directive with optional qualifiers.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: Optional[List[str]] = None + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPrivate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPublic: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersSMaxage: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleIfError: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParameters(BaseModel): + """The parameters configuring the rule's action.""" + + immutable: Optional[RuleRulesetsSetCacheControlRuleActionParametersImmutable] = None + """A cache-control directive configuration.""" + + max_age: Optional[RuleRulesetsSetCacheControlRuleActionParametersMaxAge] = FieldInfo(alias="max-age", default=None) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + must_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate] = FieldInfo( + alias="must-revalidate", default=None + ) + """A cache-control directive configuration.""" + + must_understand: Optional[RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand] = FieldInfo( + alias="must-understand", default=None + ) + """A cache-control directive configuration.""" + + no_cache: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoCache] = FieldInfo( + alias="no-cache", default=None + ) + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + no_store: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoStore] = FieldInfo( + alias="no-store", default=None + ) + """A cache-control directive configuration.""" + + no_transform: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoTransform] = FieldInfo( + alias="no-transform", default=None + ) + """A cache-control directive configuration.""" + + private: Optional[RuleRulesetsSetCacheControlRuleActionParametersPrivate] = None + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + proxy_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate] = FieldInfo( + alias="proxy-revalidate", default=None + ) + """A cache-control directive configuration.""" + + public: Optional[RuleRulesetsSetCacheControlRuleActionParametersPublic] = None + """A cache-control directive configuration.""" + + s_maxage: Optional[RuleRulesetsSetCacheControlRuleActionParametersSMaxage] = FieldInfo( + alias="s-maxage", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_if_error: Optional[RuleRulesetsSetCacheControlRuleActionParametersStaleIfError] = FieldInfo( + alias="stale-if-error", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_while_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate] = FieldInfo( + alias="stale-while-revalidate", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + +class RuleRulesetsSetCacheControlRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheControlRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheControlRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["set_cache_control"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheControlRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsSetCacheControlRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsSetCacheControlRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues(BaseModel): + """Add cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression(BaseModel): + """Add cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues(BaseModel): + """Remove cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression(BaseModel): + """Remove cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues(BaseModel): + """Set cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression(BaseModel): + """Set cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +RuleRulesetsSetCacheTagsRuleActionParameters: TypeAlias = Union[ + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression, +] + + +class RuleRulesetsSetCacheTagsRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheTagsRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheTagsRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["set_cache_tags"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheTagsRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsSetCacheTagsRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsSetCacheTagsRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + Rule: TypeAlias = Annotated[ Union[ BlockRule, @@ -249,7 +1009,9 @@ class RuleRulesetsJSChallengeRule(BaseModel): RouteRule, ScoreRule, ServeErrorRule, + RuleRulesetsSetCacheControlRule, SetCacheSettingsRule, + RuleRulesetsSetCacheTagsRule, SetConfigRule, SkipRule, ], diff --git a/src/cloudflare/types/rulesets/rule_delete_response.py b/src/cloudflare/types/rulesets/rule_delete_response.py index a4524c6c260..0477fa7dd06 100644 --- a/src/cloudflare/types/rulesets/rule_delete_response.py +++ b/src/cloudflare/types/rulesets/rule_delete_response.py @@ -4,6 +4,8 @@ from datetime import datetime from typing_extensions import Literal, Annotated, TypeAlias +from pydantic import Field as FieldInfo + from .kind import Kind from .phase import Phase from .logging import Logging @@ -35,6 +37,59 @@ "RuleRulesetsJSChallengeRule", "RuleRulesetsJSChallengeRuleExposedCredentialCheck", "RuleRulesetsJSChallengeRuleRatelimit", + "RuleRulesetsSetCacheControlRule", + "RuleRulesetsSetCacheControlRuleActionParameters", + "RuleRulesetsSetCacheControlRuleActionParametersImmutable", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAge", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCache", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStore", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransform", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivate", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublic", + "RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxage", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfError", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleExposedCredentialCheck", + "RuleRulesetsSetCacheControlRuleRatelimit", + "RuleRulesetsSetCacheTagsRule", + "RuleRulesetsSetCacheTagsRuleActionParameters", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleExposedCredentialCheck", + "RuleRulesetsSetCacheTagsRuleRatelimit", ] @@ -232,6 +287,711 @@ class RuleRulesetsJSChallengeRule(BaseModel): """The reference of the rule (the rule's ID by default).""" +class RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersImmutable: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMaxAge: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective(BaseModel): + """Set the directive with optional qualifiers.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: Optional[List[str]] = None + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoCache: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoStore: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoTransform: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective(BaseModel): + """Set the directive with optional qualifiers.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: Optional[List[str]] = None + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPrivate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPublic: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersSMaxage: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleIfError: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParameters(BaseModel): + """The parameters configuring the rule's action.""" + + immutable: Optional[RuleRulesetsSetCacheControlRuleActionParametersImmutable] = None + """A cache-control directive configuration.""" + + max_age: Optional[RuleRulesetsSetCacheControlRuleActionParametersMaxAge] = FieldInfo(alias="max-age", default=None) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + must_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate] = FieldInfo( + alias="must-revalidate", default=None + ) + """A cache-control directive configuration.""" + + must_understand: Optional[RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand] = FieldInfo( + alias="must-understand", default=None + ) + """A cache-control directive configuration.""" + + no_cache: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoCache] = FieldInfo( + alias="no-cache", default=None + ) + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + no_store: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoStore] = FieldInfo( + alias="no-store", default=None + ) + """A cache-control directive configuration.""" + + no_transform: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoTransform] = FieldInfo( + alias="no-transform", default=None + ) + """A cache-control directive configuration.""" + + private: Optional[RuleRulesetsSetCacheControlRuleActionParametersPrivate] = None + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + proxy_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate] = FieldInfo( + alias="proxy-revalidate", default=None + ) + """A cache-control directive configuration.""" + + public: Optional[RuleRulesetsSetCacheControlRuleActionParametersPublic] = None + """A cache-control directive configuration.""" + + s_maxage: Optional[RuleRulesetsSetCacheControlRuleActionParametersSMaxage] = FieldInfo( + alias="s-maxage", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_if_error: Optional[RuleRulesetsSetCacheControlRuleActionParametersStaleIfError] = FieldInfo( + alias="stale-if-error", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_while_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate] = FieldInfo( + alias="stale-while-revalidate", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + +class RuleRulesetsSetCacheControlRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheControlRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheControlRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["set_cache_control"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheControlRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsSetCacheControlRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsSetCacheControlRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues(BaseModel): + """Add cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression(BaseModel): + """Add cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues(BaseModel): + """Remove cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression(BaseModel): + """Remove cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues(BaseModel): + """Set cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression(BaseModel): + """Set cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +RuleRulesetsSetCacheTagsRuleActionParameters: TypeAlias = Union[ + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression, +] + + +class RuleRulesetsSetCacheTagsRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheTagsRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheTagsRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["set_cache_tags"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheTagsRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsSetCacheTagsRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsSetCacheTagsRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + Rule: TypeAlias = Annotated[ Union[ BlockRule, @@ -249,7 +1009,9 @@ class RuleRulesetsJSChallengeRule(BaseModel): RouteRule, ScoreRule, ServeErrorRule, + RuleRulesetsSetCacheControlRule, SetCacheSettingsRule, + RuleRulesetsSetCacheTagsRule, SetConfigRule, SkipRule, ], diff --git a/src/cloudflare/types/rulesets/rule_edit_params.py b/src/cloudflare/types/rulesets/rule_edit_params.py index c3c46474390..bb83fb8de24 100644 --- a/src/cloudflare/types/rulesets/rule_edit_params.py +++ b/src/cloudflare/types/rulesets/rule_edit_params.py @@ -3,10 +3,11 @@ from __future__ import annotations from typing import Dict, List, Union, Iterable -from typing_extensions import Literal, Required, TypeAlias, TypedDict +from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict from .phase import Phase from ..._types import SequenceNotStr +from ..._utils import PropertyInfo from .logging_param import LoggingParam __all__ = [ @@ -154,6 +155,53 @@ "ServeErrorRulePositionAfterPosition", "ServeErrorRulePositionIndexPosition", "ServeErrorRuleRatelimit", + "SetCacheControlRule", + "SetCacheControlRuleActionParameters", + "SetCacheControlRuleActionParametersImmutable", + "SetCacheControlRuleActionParametersImmutableSetDirective", + "SetCacheControlRuleActionParametersImmutableRemoveDirective", + "SetCacheControlRuleActionParametersMaxAge", + "SetCacheControlRuleActionParametersMaxAgeSetDirective", + "SetCacheControlRuleActionParametersMaxAgeRemoveDirective", + "SetCacheControlRuleActionParametersMustRevalidate", + "SetCacheControlRuleActionParametersMustRevalidateSetDirective", + "SetCacheControlRuleActionParametersMustRevalidateRemoveDirective", + "SetCacheControlRuleActionParametersMustUnderstand", + "SetCacheControlRuleActionParametersMustUnderstandSetDirective", + "SetCacheControlRuleActionParametersMustUnderstandRemoveDirective", + "SetCacheControlRuleActionParametersNoCache", + "SetCacheControlRuleActionParametersNoCacheSetDirective", + "SetCacheControlRuleActionParametersNoCacheRemoveDirective", + "SetCacheControlRuleActionParametersNoStore", + "SetCacheControlRuleActionParametersNoStoreSetDirective", + "SetCacheControlRuleActionParametersNoStoreRemoveDirective", + "SetCacheControlRuleActionParametersNoTransform", + "SetCacheControlRuleActionParametersNoTransformSetDirective", + "SetCacheControlRuleActionParametersNoTransformRemoveDirective", + "SetCacheControlRuleActionParametersPrivate", + "SetCacheControlRuleActionParametersPrivateSetDirective", + "SetCacheControlRuleActionParametersPrivateRemoveDirective", + "SetCacheControlRuleActionParametersProxyRevalidate", + "SetCacheControlRuleActionParametersProxyRevalidateSetDirective", + "SetCacheControlRuleActionParametersProxyRevalidateRemoveDirective", + "SetCacheControlRuleActionParametersPublic", + "SetCacheControlRuleActionParametersPublicSetDirective", + "SetCacheControlRuleActionParametersPublicRemoveDirective", + "SetCacheControlRuleActionParametersSMaxage", + "SetCacheControlRuleActionParametersSMaxageSetDirective", + "SetCacheControlRuleActionParametersSMaxageRemoveDirective", + "SetCacheControlRuleActionParametersStaleIfError", + "SetCacheControlRuleActionParametersStaleIfErrorSetDirective", + "SetCacheControlRuleActionParametersStaleIfErrorRemoveDirective", + "SetCacheControlRuleActionParametersStaleWhileRevalidate", + "SetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective", + "SetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective", + "SetCacheControlRuleExposedCredentialCheck", + "SetCacheControlRulePosition", + "SetCacheControlRulePositionBeforePosition", + "SetCacheControlRulePositionAfterPosition", + "SetCacheControlRulePositionIndexPosition", + "SetCacheControlRuleRatelimit", "SetCacheSettingsRule", "SetCacheSettingsRuleActionParameters", "SetCacheSettingsRuleActionParametersBrowserTTL", @@ -177,6 +225,20 @@ "SetCacheSettingsRulePositionAfterPosition", "SetCacheSettingsRulePositionIndexPosition", "SetCacheSettingsRuleRatelimit", + "SetCacheTagsRule", + "SetCacheTagsRuleActionParameters", + "SetCacheTagsRuleActionParametersAddCacheTagsValues", + "SetCacheTagsRuleActionParametersAddCacheTagsExpression", + "SetCacheTagsRuleActionParametersRemoveCacheTagsValues", + "SetCacheTagsRuleActionParametersRemoveCacheTagsExpression", + "SetCacheTagsRuleActionParametersSetCacheTagsValues", + "SetCacheTagsRuleActionParametersSetCacheTagsExpression", + "SetCacheTagsRuleExposedCredentialCheck", + "SetCacheTagsRulePosition", + "SetCacheTagsRulePositionBeforePosition", + "SetCacheTagsRulePositionAfterPosition", + "SetCacheTagsRulePositionIndexPosition", + "SetCacheTagsRuleRatelimit", "SetConfigurationRule", "SetConfigurationRuleActionParameters", "SetConfigurationRuleActionParametersAutominify", @@ -2586,6 +2648,561 @@ class ServeErrorRuleRatelimit(TypedDict, total=False): """ +class SetCacheControlRule(TypedDict, total=False): + ruleset_id: Required[str] + """The unique ID of the ruleset.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["set_cache_control"] + """The action to perform when the rule matches.""" + + action_parameters: SetCacheControlRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: SetCacheControlRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: SetCacheControlRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: SetCacheControlRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class SetCacheControlRuleActionParametersImmutableSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersImmutableRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersImmutable: TypeAlias = Union[ + SetCacheControlRuleActionParametersImmutableSetDirective, + SetCacheControlRuleActionParametersImmutableRemoveDirective, +] + + +class SetCacheControlRuleActionParametersMaxAgeSetDirective(TypedDict, total=False): + """Set the directive with a duration value in seconds.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + value: Required[int] + """The duration value in seconds for the directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersMaxAgeRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersMaxAge: TypeAlias = Union[ + SetCacheControlRuleActionParametersMaxAgeSetDirective, SetCacheControlRuleActionParametersMaxAgeRemoveDirective +] + + +class SetCacheControlRuleActionParametersMustRevalidateSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersMustRevalidateRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersMustRevalidate: TypeAlias = Union[ + SetCacheControlRuleActionParametersMustRevalidateSetDirective, + SetCacheControlRuleActionParametersMustRevalidateRemoveDirective, +] + + +class SetCacheControlRuleActionParametersMustUnderstandSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersMustUnderstandRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersMustUnderstand: TypeAlias = Union[ + SetCacheControlRuleActionParametersMustUnderstandSetDirective, + SetCacheControlRuleActionParametersMustUnderstandRemoveDirective, +] + + +class SetCacheControlRuleActionParametersNoCacheSetDirective(TypedDict, total=False): + """Set the directive with optional qualifiers.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: SequenceNotStr[str] + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class SetCacheControlRuleActionParametersNoCacheRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersNoCache: TypeAlias = Union[ + SetCacheControlRuleActionParametersNoCacheSetDirective, SetCacheControlRuleActionParametersNoCacheRemoveDirective +] + + +class SetCacheControlRuleActionParametersNoStoreSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersNoStoreRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersNoStore: TypeAlias = Union[ + SetCacheControlRuleActionParametersNoStoreSetDirective, SetCacheControlRuleActionParametersNoStoreRemoveDirective +] + + +class SetCacheControlRuleActionParametersNoTransformSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersNoTransformRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersNoTransform: TypeAlias = Union[ + SetCacheControlRuleActionParametersNoTransformSetDirective, + SetCacheControlRuleActionParametersNoTransformRemoveDirective, +] + + +class SetCacheControlRuleActionParametersPrivateSetDirective(TypedDict, total=False): + """Set the directive with optional qualifiers.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: SequenceNotStr[str] + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class SetCacheControlRuleActionParametersPrivateRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersPrivate: TypeAlias = Union[ + SetCacheControlRuleActionParametersPrivateSetDirective, SetCacheControlRuleActionParametersPrivateRemoveDirective +] + + +class SetCacheControlRuleActionParametersProxyRevalidateSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersProxyRevalidateRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersProxyRevalidate: TypeAlias = Union[ + SetCacheControlRuleActionParametersProxyRevalidateSetDirective, + SetCacheControlRuleActionParametersProxyRevalidateRemoveDirective, +] + + +class SetCacheControlRuleActionParametersPublicSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersPublicRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersPublic: TypeAlias = Union[ + SetCacheControlRuleActionParametersPublicSetDirective, SetCacheControlRuleActionParametersPublicRemoveDirective +] + + +class SetCacheControlRuleActionParametersSMaxageSetDirective(TypedDict, total=False): + """Set the directive with a duration value in seconds.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + value: Required[int] + """The duration value in seconds for the directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersSMaxageRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersSMaxage: TypeAlias = Union[ + SetCacheControlRuleActionParametersSMaxageSetDirective, SetCacheControlRuleActionParametersSMaxageRemoveDirective +] + + +class SetCacheControlRuleActionParametersStaleIfErrorSetDirective(TypedDict, total=False): + """Set the directive with a duration value in seconds.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + value: Required[int] + """The duration value in seconds for the directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersStaleIfErrorRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersStaleIfError: TypeAlias = Union[ + SetCacheControlRuleActionParametersStaleIfErrorSetDirective, + SetCacheControlRuleActionParametersStaleIfErrorRemoveDirective, +] + + +class SetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective(TypedDict, total=False): + """Set the directive with a duration value in seconds.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + value: Required[int] + """The duration value in seconds for the directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class SetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +SetCacheControlRuleActionParametersStaleWhileRevalidate: TypeAlias = Union[ + SetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective, + SetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective, +] + + +class SetCacheControlRuleActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + immutable: SetCacheControlRuleActionParametersImmutable + """A cache-control directive configuration.""" + + max_age: Annotated[SetCacheControlRuleActionParametersMaxAge, PropertyInfo(alias="max-age")] + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + must_revalidate: Annotated[SetCacheControlRuleActionParametersMustRevalidate, PropertyInfo(alias="must-revalidate")] + """A cache-control directive configuration.""" + + must_understand: Annotated[SetCacheControlRuleActionParametersMustUnderstand, PropertyInfo(alias="must-understand")] + """A cache-control directive configuration.""" + + no_cache: Annotated[SetCacheControlRuleActionParametersNoCache, PropertyInfo(alias="no-cache")] + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + no_store: Annotated[SetCacheControlRuleActionParametersNoStore, PropertyInfo(alias="no-store")] + """A cache-control directive configuration.""" + + no_transform: Annotated[SetCacheControlRuleActionParametersNoTransform, PropertyInfo(alias="no-transform")] + """A cache-control directive configuration.""" + + private: SetCacheControlRuleActionParametersPrivate + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + proxy_revalidate: Annotated[ + SetCacheControlRuleActionParametersProxyRevalidate, PropertyInfo(alias="proxy-revalidate") + ] + """A cache-control directive configuration.""" + + public: SetCacheControlRuleActionParametersPublic + """A cache-control directive configuration.""" + + s_maxage: Annotated[SetCacheControlRuleActionParametersSMaxage, PropertyInfo(alias="s-maxage")] + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_if_error: Annotated[SetCacheControlRuleActionParametersStaleIfError, PropertyInfo(alias="stale-if-error")] + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_while_revalidate: Annotated[ + SetCacheControlRuleActionParametersStaleWhileRevalidate, PropertyInfo(alias="stale-while-revalidate") + ] + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + +class SetCacheControlRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class SetCacheControlRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class SetCacheControlRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class SetCacheControlRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +SetCacheControlRulePosition: TypeAlias = Union[ + SetCacheControlRulePositionBeforePosition, + SetCacheControlRulePositionAfterPosition, + SetCacheControlRulePositionIndexPosition, +] + + +class SetCacheControlRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + class SetCacheSettingsRule(TypedDict, total=False): ruleset_id: Required[str] """The unique ID of the ruleset.""" @@ -2904,6 +3521,15 @@ class SetCacheSettingsRuleActionParameters(TypedDict, total=False): serve_stale: SetCacheSettingsRuleActionParametersServeStale """When to serve stale content from cache.""" + strip_etags: bool + """Whether to strip ETag headers from the origin response before caching.""" + + strip_last_modified: bool + """Whether to strip Last-Modified headers from the origin response before caching.""" + + strip_set_cookie: bool + """Whether to strip Set-Cookie headers from the origin response before caching.""" + class SetCacheSettingsRuleExposedCredentialCheck(TypedDict, total=False): """Configuration for exposed credential checking.""" @@ -2995,6 +3621,208 @@ class SetCacheSettingsRuleRatelimit(TypedDict, total=False): """ +class SetCacheTagsRule(TypedDict, total=False): + ruleset_id: Required[str] + """The unique ID of the ruleset.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["set_cache_tags"] + """The action to perform when the rule matches.""" + + action_parameters: SetCacheTagsRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: SetCacheTagsRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + position: SetCacheTagsRulePosition + """An object configuring where the rule will be placed.""" + + ratelimit: SetCacheTagsRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class SetCacheTagsRuleActionParametersAddCacheTagsValues(TypedDict, total=False): + """Add cache tags using a list of values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + values: Required[SequenceNotStr[str]] + """A list of cache tag values.""" + + +class SetCacheTagsRuleActionParametersAddCacheTagsExpression(TypedDict, total=False): + """Add cache tags using an expression.""" + + expression: Required[str] + """An expression that evaluates to an array of cache tag values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + +class SetCacheTagsRuleActionParametersRemoveCacheTagsValues(TypedDict, total=False): + """Remove cache tags using a list of values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + values: Required[SequenceNotStr[str]] + """A list of cache tag values.""" + + +class SetCacheTagsRuleActionParametersRemoveCacheTagsExpression(TypedDict, total=False): + """Remove cache tags using an expression.""" + + expression: Required[str] + """An expression that evaluates to an array of cache tag values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + +class SetCacheTagsRuleActionParametersSetCacheTagsValues(TypedDict, total=False): + """Set cache tags using a list of values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + values: Required[SequenceNotStr[str]] + """A list of cache tag values.""" + + +class SetCacheTagsRuleActionParametersSetCacheTagsExpression(TypedDict, total=False): + """Set cache tags using an expression.""" + + expression: Required[str] + """An expression that evaluates to an array of cache tag values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + +SetCacheTagsRuleActionParameters: TypeAlias = Union[ + SetCacheTagsRuleActionParametersAddCacheTagsValues, + SetCacheTagsRuleActionParametersAddCacheTagsExpression, + SetCacheTagsRuleActionParametersRemoveCacheTagsValues, + SetCacheTagsRuleActionParametersRemoveCacheTagsExpression, + SetCacheTagsRuleActionParametersSetCacheTagsValues, + SetCacheTagsRuleActionParametersSetCacheTagsExpression, +] + + +class SetCacheTagsRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class SetCacheTagsRulePositionBeforePosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + before: str + """The ID of another rule to place the rule before. + + An empty value causes the rule to be placed at the top. + """ + + +class SetCacheTagsRulePositionAfterPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + after: str + """The ID of another rule to place the rule after. + + An empty value causes the rule to be placed at the bottom. + """ + + +class SetCacheTagsRulePositionIndexPosition(TypedDict, total=False): + """An object configuring where the rule will be placed.""" + + index: int + """An index at which to place the rule, where index 1 is the first rule.""" + + +SetCacheTagsRulePosition: TypeAlias = Union[ + SetCacheTagsRulePositionBeforePosition, SetCacheTagsRulePositionAfterPosition, SetCacheTagsRulePositionIndexPosition +] + + +class SetCacheTagsRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + class SetConfigurationRule(TypedDict, total=False): ruleset_id: Required[str] """The unique ID of the ruleset.""" @@ -3394,7 +4222,9 @@ class SkipRuleRatelimit(TypedDict, total=False): RouteRule, ScoreRule, ServeErrorRule, + SetCacheControlRule, SetCacheSettingsRule, + SetCacheTagsRule, SetConfigurationRule, SkipRule, ] diff --git a/src/cloudflare/types/rulesets/rule_edit_response.py b/src/cloudflare/types/rulesets/rule_edit_response.py index 7de4cd9523e..73f8f8cc4aa 100644 --- a/src/cloudflare/types/rulesets/rule_edit_response.py +++ b/src/cloudflare/types/rulesets/rule_edit_response.py @@ -4,6 +4,8 @@ from datetime import datetime from typing_extensions import Literal, Annotated, TypeAlias +from pydantic import Field as FieldInfo + from .kind import Kind from .phase import Phase from .logging import Logging @@ -35,6 +37,59 @@ "RuleRulesetsJSChallengeRule", "RuleRulesetsJSChallengeRuleExposedCredentialCheck", "RuleRulesetsJSChallengeRuleRatelimit", + "RuleRulesetsSetCacheControlRule", + "RuleRulesetsSetCacheControlRuleActionParameters", + "RuleRulesetsSetCacheControlRuleActionParametersImmutable", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAge", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCache", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStore", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransform", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivate", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublic", + "RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxage", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfError", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleExposedCredentialCheck", + "RuleRulesetsSetCacheControlRuleRatelimit", + "RuleRulesetsSetCacheTagsRule", + "RuleRulesetsSetCacheTagsRuleActionParameters", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleExposedCredentialCheck", + "RuleRulesetsSetCacheTagsRuleRatelimit", ] @@ -232,6 +287,711 @@ class RuleRulesetsJSChallengeRule(BaseModel): """The reference of the rule (the rule's ID by default).""" +class RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersImmutable: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMaxAge: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective(BaseModel): + """Set the directive with optional qualifiers.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: Optional[List[str]] = None + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoCache: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoStore: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoTransform: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective(BaseModel): + """Set the directive with optional qualifiers.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: Optional[List[str]] = None + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPrivate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPublic: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersSMaxage: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleIfError: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParameters(BaseModel): + """The parameters configuring the rule's action.""" + + immutable: Optional[RuleRulesetsSetCacheControlRuleActionParametersImmutable] = None + """A cache-control directive configuration.""" + + max_age: Optional[RuleRulesetsSetCacheControlRuleActionParametersMaxAge] = FieldInfo(alias="max-age", default=None) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + must_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate] = FieldInfo( + alias="must-revalidate", default=None + ) + """A cache-control directive configuration.""" + + must_understand: Optional[RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand] = FieldInfo( + alias="must-understand", default=None + ) + """A cache-control directive configuration.""" + + no_cache: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoCache] = FieldInfo( + alias="no-cache", default=None + ) + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + no_store: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoStore] = FieldInfo( + alias="no-store", default=None + ) + """A cache-control directive configuration.""" + + no_transform: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoTransform] = FieldInfo( + alias="no-transform", default=None + ) + """A cache-control directive configuration.""" + + private: Optional[RuleRulesetsSetCacheControlRuleActionParametersPrivate] = None + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + proxy_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate] = FieldInfo( + alias="proxy-revalidate", default=None + ) + """A cache-control directive configuration.""" + + public: Optional[RuleRulesetsSetCacheControlRuleActionParametersPublic] = None + """A cache-control directive configuration.""" + + s_maxage: Optional[RuleRulesetsSetCacheControlRuleActionParametersSMaxage] = FieldInfo( + alias="s-maxage", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_if_error: Optional[RuleRulesetsSetCacheControlRuleActionParametersStaleIfError] = FieldInfo( + alias="stale-if-error", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_while_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate] = FieldInfo( + alias="stale-while-revalidate", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + +class RuleRulesetsSetCacheControlRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheControlRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheControlRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["set_cache_control"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheControlRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsSetCacheControlRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsSetCacheControlRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues(BaseModel): + """Add cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression(BaseModel): + """Add cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues(BaseModel): + """Remove cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression(BaseModel): + """Remove cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues(BaseModel): + """Set cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression(BaseModel): + """Set cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +RuleRulesetsSetCacheTagsRuleActionParameters: TypeAlias = Union[ + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression, +] + + +class RuleRulesetsSetCacheTagsRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheTagsRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheTagsRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["set_cache_tags"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheTagsRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsSetCacheTagsRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsSetCacheTagsRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + Rule: TypeAlias = Annotated[ Union[ BlockRule, @@ -249,7 +1009,9 @@ class RuleRulesetsJSChallengeRule(BaseModel): RouteRule, ScoreRule, ServeErrorRule, + RuleRulesetsSetCacheControlRule, SetCacheSettingsRule, + RuleRulesetsSetCacheTagsRule, SetConfigRule, SkipRule, ], diff --git a/src/cloudflare/types/rulesets/ruleset_create_params.py b/src/cloudflare/types/rulesets/ruleset_create_params.py index d70cfb8f604..e1130c331fa 100644 --- a/src/cloudflare/types/rulesets/ruleset_create_params.py +++ b/src/cloudflare/types/rulesets/ruleset_create_params.py @@ -3,11 +3,12 @@ from __future__ import annotations from typing import Union, Iterable -from typing_extensions import Literal, Required, TypeAlias, TypedDict +from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict from .kind import Kind from .phase import Phase from ..._types import SequenceNotStr +from ..._utils import PropertyInfo from .logging_param import LoggingParam from .log_rule_param import LogRuleParam from .skip_rule_param import SkipRuleParam @@ -35,6 +36,59 @@ "RuleRulesetsJSChallengeRule", "RuleRulesetsJSChallengeRuleExposedCredentialCheck", "RuleRulesetsJSChallengeRuleRatelimit", + "RuleRulesetsSetCacheControlRule", + "RuleRulesetsSetCacheControlRuleActionParameters", + "RuleRulesetsSetCacheControlRuleActionParametersImmutable", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAge", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCache", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStore", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransform", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivate", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublic", + "RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxage", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfError", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleExposedCredentialCheck", + "RuleRulesetsSetCacheControlRuleRatelimit", + "RuleRulesetsSetCacheTagsRule", + "RuleRulesetsSetCacheTagsRuleActionParameters", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleExposedCredentialCheck", + "RuleRulesetsSetCacheTagsRuleRatelimit", ] @@ -237,6 +291,688 @@ class RuleRulesetsJSChallengeRule(TypedDict, total=False): """The reference of the rule (the rule's ID by default).""" +class RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersImmutable: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective(TypedDict, total=False): + """Set the directive with a duration value in seconds.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + value: Required[int] + """The duration value in seconds for the directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMaxAge: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective(TypedDict, total=False): + """Set the directive with optional qualifiers.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: SequenceNotStr[str] + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoCache: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoStore: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoTransform: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective(TypedDict, total=False): + """Set the directive with optional qualifiers.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: SequenceNotStr[str] + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPrivate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPublic: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective(TypedDict, total=False): + """Set the directive with a duration value in seconds.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + value: Required[int] + """The duration value in seconds for the directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersSMaxage: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective(TypedDict, total=False): + """Set the directive with a duration value in seconds.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + value: Required[int] + """The duration value in seconds for the directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleIfError: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective(TypedDict, total=False): + """Set the directive with a duration value in seconds.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + value: Required[int] + """The duration value in seconds for the directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + immutable: RuleRulesetsSetCacheControlRuleActionParametersImmutable + """A cache-control directive configuration.""" + + max_age: Annotated[RuleRulesetsSetCacheControlRuleActionParametersMaxAge, PropertyInfo(alias="max-age")] + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + must_revalidate: Annotated[ + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate, PropertyInfo(alias="must-revalidate") + ] + """A cache-control directive configuration.""" + + must_understand: Annotated[ + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand, PropertyInfo(alias="must-understand") + ] + """A cache-control directive configuration.""" + + no_cache: Annotated[RuleRulesetsSetCacheControlRuleActionParametersNoCache, PropertyInfo(alias="no-cache")] + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + no_store: Annotated[RuleRulesetsSetCacheControlRuleActionParametersNoStore, PropertyInfo(alias="no-store")] + """A cache-control directive configuration.""" + + no_transform: Annotated[ + RuleRulesetsSetCacheControlRuleActionParametersNoTransform, PropertyInfo(alias="no-transform") + ] + """A cache-control directive configuration.""" + + private: RuleRulesetsSetCacheControlRuleActionParametersPrivate + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + proxy_revalidate: Annotated[ + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate, PropertyInfo(alias="proxy-revalidate") + ] + """A cache-control directive configuration.""" + + public: RuleRulesetsSetCacheControlRuleActionParametersPublic + """A cache-control directive configuration.""" + + s_maxage: Annotated[RuleRulesetsSetCacheControlRuleActionParametersSMaxage, PropertyInfo(alias="s-maxage")] + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_if_error: Annotated[ + RuleRulesetsSetCacheControlRuleActionParametersStaleIfError, PropertyInfo(alias="stale-if-error") + ] + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_while_revalidate: Annotated[ + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate, + PropertyInfo(alias="stale-while-revalidate"), + ] + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + +class RuleRulesetsSetCacheControlRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheControlRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheControlRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["set_cache_control"] + """The action to perform when the rule matches.""" + + action_parameters: RuleRulesetsSetCacheControlRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: RuleRulesetsSetCacheControlRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ratelimit: RuleRulesetsSetCacheControlRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues(TypedDict, total=False): + """Add cache tags using a list of values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + values: Required[SequenceNotStr[str]] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression(TypedDict, total=False): + """Add cache tags using an expression.""" + + expression: Required[str] + """An expression that evaluates to an array of cache tag values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues(TypedDict, total=False): + """Remove cache tags using a list of values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + values: Required[SequenceNotStr[str]] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression(TypedDict, total=False): + """Remove cache tags using an expression.""" + + expression: Required[str] + """An expression that evaluates to an array of cache tag values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues(TypedDict, total=False): + """Set cache tags using a list of values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + values: Required[SequenceNotStr[str]] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression(TypedDict, total=False): + """Set cache tags using an expression.""" + + expression: Required[str] + """An expression that evaluates to an array of cache tag values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + +RuleRulesetsSetCacheTagsRuleActionParameters: TypeAlias = Union[ + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression, +] + + +class RuleRulesetsSetCacheTagsRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheTagsRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheTagsRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["set_cache_tags"] + """The action to perform when the rule matches.""" + + action_parameters: RuleRulesetsSetCacheTagsRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: RuleRulesetsSetCacheTagsRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ratelimit: RuleRulesetsSetCacheTagsRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + Rule: TypeAlias = Union[ BlockRuleParam, RuleRulesetsChallengeRule, @@ -253,7 +989,9 @@ class RuleRulesetsJSChallengeRule(TypedDict, total=False): RouteRuleParam, ScoreRuleParam, ServeErrorRuleParam, + RuleRulesetsSetCacheControlRule, SetCacheSettingsRuleParam, + RuleRulesetsSetCacheTagsRule, SetConfigRuleParam, SkipRuleParam, ] diff --git a/src/cloudflare/types/rulesets/ruleset_create_response.py b/src/cloudflare/types/rulesets/ruleset_create_response.py index 4b157ce0840..996e8edac9d 100644 --- a/src/cloudflare/types/rulesets/ruleset_create_response.py +++ b/src/cloudflare/types/rulesets/ruleset_create_response.py @@ -4,6 +4,8 @@ from datetime import datetime from typing_extensions import Literal, Annotated, TypeAlias +from pydantic import Field as FieldInfo + from .kind import Kind from .phase import Phase from .logging import Logging @@ -35,6 +37,59 @@ "RuleRulesetsJSChallengeRule", "RuleRulesetsJSChallengeRuleExposedCredentialCheck", "RuleRulesetsJSChallengeRuleRatelimit", + "RuleRulesetsSetCacheControlRule", + "RuleRulesetsSetCacheControlRuleActionParameters", + "RuleRulesetsSetCacheControlRuleActionParametersImmutable", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAge", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCache", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStore", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransform", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivate", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublic", + "RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxage", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfError", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleExposedCredentialCheck", + "RuleRulesetsSetCacheControlRuleRatelimit", + "RuleRulesetsSetCacheTagsRule", + "RuleRulesetsSetCacheTagsRuleActionParameters", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleExposedCredentialCheck", + "RuleRulesetsSetCacheTagsRuleRatelimit", ] @@ -232,6 +287,711 @@ class RuleRulesetsJSChallengeRule(BaseModel): """The reference of the rule (the rule's ID by default).""" +class RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersImmutable: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMaxAge: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective(BaseModel): + """Set the directive with optional qualifiers.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: Optional[List[str]] = None + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoCache: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoStore: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoTransform: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective(BaseModel): + """Set the directive with optional qualifiers.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: Optional[List[str]] = None + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPrivate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPublic: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersSMaxage: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleIfError: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParameters(BaseModel): + """The parameters configuring the rule's action.""" + + immutable: Optional[RuleRulesetsSetCacheControlRuleActionParametersImmutable] = None + """A cache-control directive configuration.""" + + max_age: Optional[RuleRulesetsSetCacheControlRuleActionParametersMaxAge] = FieldInfo(alias="max-age", default=None) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + must_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate] = FieldInfo( + alias="must-revalidate", default=None + ) + """A cache-control directive configuration.""" + + must_understand: Optional[RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand] = FieldInfo( + alias="must-understand", default=None + ) + """A cache-control directive configuration.""" + + no_cache: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoCache] = FieldInfo( + alias="no-cache", default=None + ) + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + no_store: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoStore] = FieldInfo( + alias="no-store", default=None + ) + """A cache-control directive configuration.""" + + no_transform: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoTransform] = FieldInfo( + alias="no-transform", default=None + ) + """A cache-control directive configuration.""" + + private: Optional[RuleRulesetsSetCacheControlRuleActionParametersPrivate] = None + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + proxy_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate] = FieldInfo( + alias="proxy-revalidate", default=None + ) + """A cache-control directive configuration.""" + + public: Optional[RuleRulesetsSetCacheControlRuleActionParametersPublic] = None + """A cache-control directive configuration.""" + + s_maxage: Optional[RuleRulesetsSetCacheControlRuleActionParametersSMaxage] = FieldInfo( + alias="s-maxage", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_if_error: Optional[RuleRulesetsSetCacheControlRuleActionParametersStaleIfError] = FieldInfo( + alias="stale-if-error", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_while_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate] = FieldInfo( + alias="stale-while-revalidate", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + +class RuleRulesetsSetCacheControlRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheControlRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheControlRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["set_cache_control"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheControlRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsSetCacheControlRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsSetCacheControlRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues(BaseModel): + """Add cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression(BaseModel): + """Add cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues(BaseModel): + """Remove cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression(BaseModel): + """Remove cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues(BaseModel): + """Set cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression(BaseModel): + """Set cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +RuleRulesetsSetCacheTagsRuleActionParameters: TypeAlias = Union[ + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression, +] + + +class RuleRulesetsSetCacheTagsRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheTagsRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheTagsRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["set_cache_tags"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheTagsRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsSetCacheTagsRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsSetCacheTagsRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + Rule: TypeAlias = Annotated[ Union[ BlockRule, @@ -249,7 +1009,9 @@ class RuleRulesetsJSChallengeRule(BaseModel): RouteRule, ScoreRule, ServeErrorRule, + RuleRulesetsSetCacheControlRule, SetCacheSettingsRule, + RuleRulesetsSetCacheTagsRule, SetConfigRule, SkipRule, ], diff --git a/src/cloudflare/types/rulesets/ruleset_get_response.py b/src/cloudflare/types/rulesets/ruleset_get_response.py index fda4e4bf141..642243625e4 100644 --- a/src/cloudflare/types/rulesets/ruleset_get_response.py +++ b/src/cloudflare/types/rulesets/ruleset_get_response.py @@ -4,6 +4,8 @@ from datetime import datetime from typing_extensions import Literal, Annotated, TypeAlias +from pydantic import Field as FieldInfo + from .kind import Kind from .phase import Phase from .logging import Logging @@ -35,6 +37,59 @@ "RuleRulesetsJSChallengeRule", "RuleRulesetsJSChallengeRuleExposedCredentialCheck", "RuleRulesetsJSChallengeRuleRatelimit", + "RuleRulesetsSetCacheControlRule", + "RuleRulesetsSetCacheControlRuleActionParameters", + "RuleRulesetsSetCacheControlRuleActionParametersImmutable", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAge", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCache", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStore", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransform", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivate", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublic", + "RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxage", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfError", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleExposedCredentialCheck", + "RuleRulesetsSetCacheControlRuleRatelimit", + "RuleRulesetsSetCacheTagsRule", + "RuleRulesetsSetCacheTagsRuleActionParameters", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleExposedCredentialCheck", + "RuleRulesetsSetCacheTagsRuleRatelimit", ] @@ -232,6 +287,711 @@ class RuleRulesetsJSChallengeRule(BaseModel): """The reference of the rule (the rule's ID by default).""" +class RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersImmutable: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMaxAge: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective(BaseModel): + """Set the directive with optional qualifiers.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: Optional[List[str]] = None + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoCache: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoStore: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoTransform: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective(BaseModel): + """Set the directive with optional qualifiers.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: Optional[List[str]] = None + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPrivate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPublic: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersSMaxage: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleIfError: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParameters(BaseModel): + """The parameters configuring the rule's action.""" + + immutable: Optional[RuleRulesetsSetCacheControlRuleActionParametersImmutable] = None + """A cache-control directive configuration.""" + + max_age: Optional[RuleRulesetsSetCacheControlRuleActionParametersMaxAge] = FieldInfo(alias="max-age", default=None) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + must_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate] = FieldInfo( + alias="must-revalidate", default=None + ) + """A cache-control directive configuration.""" + + must_understand: Optional[RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand] = FieldInfo( + alias="must-understand", default=None + ) + """A cache-control directive configuration.""" + + no_cache: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoCache] = FieldInfo( + alias="no-cache", default=None + ) + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + no_store: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoStore] = FieldInfo( + alias="no-store", default=None + ) + """A cache-control directive configuration.""" + + no_transform: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoTransform] = FieldInfo( + alias="no-transform", default=None + ) + """A cache-control directive configuration.""" + + private: Optional[RuleRulesetsSetCacheControlRuleActionParametersPrivate] = None + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + proxy_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate] = FieldInfo( + alias="proxy-revalidate", default=None + ) + """A cache-control directive configuration.""" + + public: Optional[RuleRulesetsSetCacheControlRuleActionParametersPublic] = None + """A cache-control directive configuration.""" + + s_maxage: Optional[RuleRulesetsSetCacheControlRuleActionParametersSMaxage] = FieldInfo( + alias="s-maxage", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_if_error: Optional[RuleRulesetsSetCacheControlRuleActionParametersStaleIfError] = FieldInfo( + alias="stale-if-error", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_while_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate] = FieldInfo( + alias="stale-while-revalidate", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + +class RuleRulesetsSetCacheControlRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheControlRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheControlRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["set_cache_control"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheControlRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsSetCacheControlRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsSetCacheControlRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues(BaseModel): + """Add cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression(BaseModel): + """Add cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues(BaseModel): + """Remove cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression(BaseModel): + """Remove cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues(BaseModel): + """Set cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression(BaseModel): + """Set cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +RuleRulesetsSetCacheTagsRuleActionParameters: TypeAlias = Union[ + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression, +] + + +class RuleRulesetsSetCacheTagsRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheTagsRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheTagsRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["set_cache_tags"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheTagsRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsSetCacheTagsRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsSetCacheTagsRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + Rule: TypeAlias = Annotated[ Union[ BlockRule, @@ -249,7 +1009,9 @@ class RuleRulesetsJSChallengeRule(BaseModel): RouteRule, ScoreRule, ServeErrorRule, + RuleRulesetsSetCacheControlRule, SetCacheSettingsRule, + RuleRulesetsSetCacheTagsRule, SetConfigRule, SkipRule, ], diff --git a/src/cloudflare/types/rulesets/ruleset_update_params.py b/src/cloudflare/types/rulesets/ruleset_update_params.py index 38af103d218..75ac54d4e87 100644 --- a/src/cloudflare/types/rulesets/ruleset_update_params.py +++ b/src/cloudflare/types/rulesets/ruleset_update_params.py @@ -3,11 +3,12 @@ from __future__ import annotations from typing import Union, Iterable -from typing_extensions import Literal, Required, TypeAlias, TypedDict +from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict from .kind import Kind from .phase import Phase from ..._types import SequenceNotStr +from ..._utils import PropertyInfo from .logging_param import LoggingParam from .log_rule_param import LogRuleParam from .skip_rule_param import SkipRuleParam @@ -35,6 +36,59 @@ "RuleRulesetsJSChallengeRule", "RuleRulesetsJSChallengeRuleExposedCredentialCheck", "RuleRulesetsJSChallengeRuleRatelimit", + "RuleRulesetsSetCacheControlRule", + "RuleRulesetsSetCacheControlRuleActionParameters", + "RuleRulesetsSetCacheControlRuleActionParametersImmutable", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAge", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCache", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStore", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransform", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivate", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublic", + "RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxage", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfError", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleExposedCredentialCheck", + "RuleRulesetsSetCacheControlRuleRatelimit", + "RuleRulesetsSetCacheTagsRule", + "RuleRulesetsSetCacheTagsRuleActionParameters", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleExposedCredentialCheck", + "RuleRulesetsSetCacheTagsRuleRatelimit", ] @@ -237,6 +291,688 @@ class RuleRulesetsJSChallengeRule(TypedDict, total=False): """The reference of the rule (the rule's ID by default).""" +class RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersImmutable: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective(TypedDict, total=False): + """Set the directive with a duration value in seconds.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + value: Required[int] + """The duration value in seconds for the directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMaxAge: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective(TypedDict, total=False): + """Set the directive with optional qualifiers.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: SequenceNotStr[str] + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoCache: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoStore: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoTransform: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective(TypedDict, total=False): + """Set the directive with optional qualifiers.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: SequenceNotStr[str] + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPrivate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective(TypedDict, total=False): + """Set the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPublic: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective(TypedDict, total=False): + """Set the directive with a duration value in seconds.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + value: Required[int] + """The duration value in seconds for the directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersSMaxage: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective(TypedDict, total=False): + """Set the directive with a duration value in seconds.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + value: Required[int] + """The duration value in seconds for the directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleIfError: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective(TypedDict, total=False): + """Set the directive with a duration value in seconds.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + value: Required[int] + """The duration value in seconds for the directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective(TypedDict, total=False): + """Remove the directive.""" + + operation: Required[Literal["set", "remove"]] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: bool + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParameters(TypedDict, total=False): + """The parameters configuring the rule's action.""" + + immutable: RuleRulesetsSetCacheControlRuleActionParametersImmutable + """A cache-control directive configuration.""" + + max_age: Annotated[RuleRulesetsSetCacheControlRuleActionParametersMaxAge, PropertyInfo(alias="max-age")] + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + must_revalidate: Annotated[ + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate, PropertyInfo(alias="must-revalidate") + ] + """A cache-control directive configuration.""" + + must_understand: Annotated[ + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand, PropertyInfo(alias="must-understand") + ] + """A cache-control directive configuration.""" + + no_cache: Annotated[RuleRulesetsSetCacheControlRuleActionParametersNoCache, PropertyInfo(alias="no-cache")] + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + no_store: Annotated[RuleRulesetsSetCacheControlRuleActionParametersNoStore, PropertyInfo(alias="no-store")] + """A cache-control directive configuration.""" + + no_transform: Annotated[ + RuleRulesetsSetCacheControlRuleActionParametersNoTransform, PropertyInfo(alias="no-transform") + ] + """A cache-control directive configuration.""" + + private: RuleRulesetsSetCacheControlRuleActionParametersPrivate + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + proxy_revalidate: Annotated[ + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate, PropertyInfo(alias="proxy-revalidate") + ] + """A cache-control directive configuration.""" + + public: RuleRulesetsSetCacheControlRuleActionParametersPublic + """A cache-control directive configuration.""" + + s_maxage: Annotated[RuleRulesetsSetCacheControlRuleActionParametersSMaxage, PropertyInfo(alias="s-maxage")] + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_if_error: Annotated[ + RuleRulesetsSetCacheControlRuleActionParametersStaleIfError, PropertyInfo(alias="stale-if-error") + ] + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_while_revalidate: Annotated[ + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate, + PropertyInfo(alias="stale-while-revalidate"), + ] + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + +class RuleRulesetsSetCacheControlRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheControlRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheControlRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["set_cache_control"] + """The action to perform when the rule matches.""" + + action_parameters: RuleRulesetsSetCacheControlRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: RuleRulesetsSetCacheControlRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ratelimit: RuleRulesetsSetCacheControlRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues(TypedDict, total=False): + """Add cache tags using a list of values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + values: Required[SequenceNotStr[str]] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression(TypedDict, total=False): + """Add cache tags using an expression.""" + + expression: Required[str] + """An expression that evaluates to an array of cache tag values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues(TypedDict, total=False): + """Remove cache tags using a list of values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + values: Required[SequenceNotStr[str]] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression(TypedDict, total=False): + """Remove cache tags using an expression.""" + + expression: Required[str] + """An expression that evaluates to an array of cache tag values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues(TypedDict, total=False): + """Set cache tags using a list of values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + values: Required[SequenceNotStr[str]] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression(TypedDict, total=False): + """Set cache tags using an expression.""" + + expression: Required[str] + """An expression that evaluates to an array of cache tag values.""" + + operation: Required[Literal["add", "remove", "set"]] + """The operation to perform on the cache tags.""" + + +RuleRulesetsSetCacheTagsRuleActionParameters: TypeAlias = Union[ + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression, +] + + +class RuleRulesetsSetCacheTagsRuleExposedCredentialCheck(TypedDict, total=False): + """Configuration for exposed credential checking.""" + + password_expression: Required[str] + """An expression that selects the password used in the credentials check.""" + + username_expression: Required[str] + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheTagsRuleRatelimit(TypedDict, total=False): + """An object configuring the rule's rate limit behavior.""" + + characteristics: Required[SequenceNotStr[str]] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: Required[int] + """Period in seconds over which the counter is being incremented.""" + + counting_expression: str + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: int + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: int + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: bool + """Whether counting is only performed when an origin is reached.""" + + score_per_period: int + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: str + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheTagsRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["set_cache_tags"] + """The action to perform when the rule matches.""" + + action_parameters: RuleRulesetsSetCacheTagsRuleActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + exposed_credential_check: RuleRulesetsSetCacheTagsRuleExposedCredentialCheck + """Configuration for exposed credential checking.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ratelimit: RuleRulesetsSetCacheTagsRuleRatelimit + """An object configuring the rule's rate limit behavior.""" + + ref: str + """The reference of the rule (the rule's ID by default).""" + + Rule: TypeAlias = Union[ BlockRuleParam, RuleRulesetsChallengeRule, @@ -253,7 +989,9 @@ class RuleRulesetsJSChallengeRule(TypedDict, total=False): RouteRuleParam, ScoreRuleParam, ServeErrorRuleParam, + RuleRulesetsSetCacheControlRule, SetCacheSettingsRuleParam, + RuleRulesetsSetCacheTagsRule, SetConfigRuleParam, SkipRuleParam, ] diff --git a/src/cloudflare/types/rulesets/ruleset_update_response.py b/src/cloudflare/types/rulesets/ruleset_update_response.py index 19a203aa4de..a323e0af695 100644 --- a/src/cloudflare/types/rulesets/ruleset_update_response.py +++ b/src/cloudflare/types/rulesets/ruleset_update_response.py @@ -4,6 +4,8 @@ from datetime import datetime from typing_extensions import Literal, Annotated, TypeAlias +from pydantic import Field as FieldInfo + from .kind import Kind from .phase import Phase from .logging import Logging @@ -35,6 +37,59 @@ "RuleRulesetsJSChallengeRule", "RuleRulesetsJSChallengeRuleExposedCredentialCheck", "RuleRulesetsJSChallengeRuleRatelimit", + "RuleRulesetsSetCacheControlRule", + "RuleRulesetsSetCacheControlRuleActionParameters", + "RuleRulesetsSetCacheControlRuleActionParametersImmutable", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAge", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCache", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStore", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransform", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivate", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublic", + "RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxage", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfError", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleExposedCredentialCheck", + "RuleRulesetsSetCacheControlRuleRatelimit", + "RuleRulesetsSetCacheTagsRule", + "RuleRulesetsSetCacheTagsRuleActionParameters", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleExposedCredentialCheck", + "RuleRulesetsSetCacheTagsRuleRatelimit", ] @@ -232,6 +287,711 @@ class RuleRulesetsJSChallengeRule(BaseModel): """The reference of the rule (the rule's ID by default).""" +class RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersImmutable: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMaxAge: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective(BaseModel): + """Set the directive with optional qualifiers.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: Optional[List[str]] = None + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoCache: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoStore: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoTransform: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective(BaseModel): + """Set the directive with optional qualifiers.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: Optional[List[str]] = None + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPrivate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPublic: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersSMaxage: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleIfError: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParameters(BaseModel): + """The parameters configuring the rule's action.""" + + immutable: Optional[RuleRulesetsSetCacheControlRuleActionParametersImmutable] = None + """A cache-control directive configuration.""" + + max_age: Optional[RuleRulesetsSetCacheControlRuleActionParametersMaxAge] = FieldInfo(alias="max-age", default=None) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + must_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate] = FieldInfo( + alias="must-revalidate", default=None + ) + """A cache-control directive configuration.""" + + must_understand: Optional[RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand] = FieldInfo( + alias="must-understand", default=None + ) + """A cache-control directive configuration.""" + + no_cache: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoCache] = FieldInfo( + alias="no-cache", default=None + ) + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + no_store: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoStore] = FieldInfo( + alias="no-store", default=None + ) + """A cache-control directive configuration.""" + + no_transform: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoTransform] = FieldInfo( + alias="no-transform", default=None + ) + """A cache-control directive configuration.""" + + private: Optional[RuleRulesetsSetCacheControlRuleActionParametersPrivate] = None + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + proxy_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate] = FieldInfo( + alias="proxy-revalidate", default=None + ) + """A cache-control directive configuration.""" + + public: Optional[RuleRulesetsSetCacheControlRuleActionParametersPublic] = None + """A cache-control directive configuration.""" + + s_maxage: Optional[RuleRulesetsSetCacheControlRuleActionParametersSMaxage] = FieldInfo( + alias="s-maxage", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_if_error: Optional[RuleRulesetsSetCacheControlRuleActionParametersStaleIfError] = FieldInfo( + alias="stale-if-error", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_while_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate] = FieldInfo( + alias="stale-while-revalidate", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + +class RuleRulesetsSetCacheControlRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheControlRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheControlRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["set_cache_control"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheControlRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsSetCacheControlRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsSetCacheControlRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues(BaseModel): + """Add cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression(BaseModel): + """Add cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues(BaseModel): + """Remove cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression(BaseModel): + """Remove cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues(BaseModel): + """Set cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression(BaseModel): + """Set cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +RuleRulesetsSetCacheTagsRuleActionParameters: TypeAlias = Union[ + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression, +] + + +class RuleRulesetsSetCacheTagsRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheTagsRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheTagsRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["set_cache_tags"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheTagsRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsSetCacheTagsRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsSetCacheTagsRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + Rule: TypeAlias = Annotated[ Union[ BlockRule, @@ -249,7 +1009,9 @@ class RuleRulesetsJSChallengeRule(BaseModel): RouteRule, ScoreRule, ServeErrorRule, + RuleRulesetsSetCacheControlRule, SetCacheSettingsRule, + RuleRulesetsSetCacheTagsRule, SetConfigRule, SkipRule, ], diff --git a/src/cloudflare/types/rulesets/set_cache_settings_rule.py b/src/cloudflare/types/rulesets/set_cache_settings_rule.py index afbc0d4af20..6d90bf7d997 100644 --- a/src/cloudflare/types/rulesets/set_cache_settings_rule.py +++ b/src/cloudflare/types/rulesets/set_cache_settings_rule.py @@ -298,6 +298,15 @@ class ActionParameters(BaseModel): serve_stale: Optional[ActionParametersServeStale] = None """When to serve stale content from cache.""" + strip_etags: Optional[bool] = None + """Whether to strip ETag headers from the origin response before caching.""" + + strip_last_modified: Optional[bool] = None + """Whether to strip Last-Modified headers from the origin response before caching.""" + + strip_set_cookie: Optional[bool] = None + """Whether to strip Set-Cookie headers from the origin response before caching.""" + class ExposedCredentialCheck(BaseModel): """Configuration for exposed credential checking.""" diff --git a/src/cloudflare/types/rulesets/set_cache_settings_rule_param.py b/src/cloudflare/types/rulesets/set_cache_settings_rule_param.py index 302bf4ff9f9..9fd1071a07d 100644 --- a/src/cloudflare/types/rulesets/set_cache_settings_rule_param.py +++ b/src/cloudflare/types/rulesets/set_cache_settings_rule_param.py @@ -305,6 +305,15 @@ class ActionParameters(TypedDict, total=False): serve_stale: ActionParametersServeStale """When to serve stale content from cache.""" + strip_etags: bool + """Whether to strip ETag headers from the origin response before caching.""" + + strip_last_modified: bool + """Whether to strip Last-Modified headers from the origin response before caching.""" + + strip_set_cookie: bool + """Whether to strip Set-Cookie headers from the origin response before caching.""" + class ExposedCredentialCheck(TypedDict, total=False): """Configuration for exposed credential checking.""" diff --git a/src/cloudflare/types/rulesets/version_get_response.py b/src/cloudflare/types/rulesets/version_get_response.py index 6e0536e009c..ffa5b313a0b 100644 --- a/src/cloudflare/types/rulesets/version_get_response.py +++ b/src/cloudflare/types/rulesets/version_get_response.py @@ -4,6 +4,8 @@ from datetime import datetime from typing_extensions import Literal, Annotated, TypeAlias +from pydantic import Field as FieldInfo + from .kind import Kind from .phase import Phase from .logging import Logging @@ -35,6 +37,59 @@ "RuleRulesetsJSChallengeRule", "RuleRulesetsJSChallengeRuleExposedCredentialCheck", "RuleRulesetsJSChallengeRuleRatelimit", + "RuleRulesetsSetCacheControlRule", + "RuleRulesetsSetCacheControlRuleActionParameters", + "RuleRulesetsSetCacheControlRuleActionParametersImmutable", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAge", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCache", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStore", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransform", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivate", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublic", + "RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxage", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfError", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective", + "RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective", + "RuleRulesetsSetCacheControlRuleExposedCredentialCheck", + "RuleRulesetsSetCacheControlRuleRatelimit", + "RuleRulesetsSetCacheTagsRule", + "RuleRulesetsSetCacheTagsRuleActionParameters", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues", + "RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression", + "RuleRulesetsSetCacheTagsRuleExposedCredentialCheck", + "RuleRulesetsSetCacheTagsRuleRatelimit", ] @@ -232,6 +287,711 @@ class RuleRulesetsJSChallengeRule(BaseModel): """The reference of the rule (the rule's ID by default).""" +class RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersImmutable: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersImmutableSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersImmutableRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMaxAge: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMaxAgeRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersMustUnderstandRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective(BaseModel): + """Set the directive with optional qualifiers.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: Optional[List[str]] = None + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoCache: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoCacheSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoCacheRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoStore: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoStoreSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoStoreRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersNoTransform: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersNoTransformSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersNoTransformRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective(BaseModel): + """Set the directive with optional qualifiers.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + qualifiers: Optional[List[str]] = None + """ + Optional list of header names to qualify the directive (e.g., for "private" or + "no-cache" directives). + """ + + +class RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPrivate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPrivateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPrivateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective(BaseModel): + """Set the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersPublic: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersPublicSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersPublicRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersSMaxage: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersSMaxageSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersSMaxageRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleIfError: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleIfErrorRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective(BaseModel): + """Set the directive with a duration value in seconds.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + value: int + """The duration value in seconds for the directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +class RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective(BaseModel): + """Remove the directive.""" + + operation: Literal["set", "remove"] + """The operation to perform on the cache-control directive.""" + + cloudflare_only: Optional[bool] = None + """Whether the directive should only be applied to the Cloudflare CDN cache.""" + + +RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate: TypeAlias = Union[ + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateSetDirective, + RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidateRemoveDirective, +] + + +class RuleRulesetsSetCacheControlRuleActionParameters(BaseModel): + """The parameters configuring the rule's action.""" + + immutable: Optional[RuleRulesetsSetCacheControlRuleActionParametersImmutable] = None + """A cache-control directive configuration.""" + + max_age: Optional[RuleRulesetsSetCacheControlRuleActionParametersMaxAge] = FieldInfo(alias="max-age", default=None) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + must_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersMustRevalidate] = FieldInfo( + alias="must-revalidate", default=None + ) + """A cache-control directive configuration.""" + + must_understand: Optional[RuleRulesetsSetCacheControlRuleActionParametersMustUnderstand] = FieldInfo( + alias="must-understand", default=None + ) + """A cache-control directive configuration.""" + + no_cache: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoCache] = FieldInfo( + alias="no-cache", default=None + ) + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + no_store: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoStore] = FieldInfo( + alias="no-store", default=None + ) + """A cache-control directive configuration.""" + + no_transform: Optional[RuleRulesetsSetCacheControlRuleActionParametersNoTransform] = FieldInfo( + alias="no-transform", default=None + ) + """A cache-control directive configuration.""" + + private: Optional[RuleRulesetsSetCacheControlRuleActionParametersPrivate] = None + """ + A cache-control directive configuration that accepts optional qualifiers (header + names). + """ + + proxy_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersProxyRevalidate] = FieldInfo( + alias="proxy-revalidate", default=None + ) + """A cache-control directive configuration.""" + + public: Optional[RuleRulesetsSetCacheControlRuleActionParametersPublic] = None + """A cache-control directive configuration.""" + + s_maxage: Optional[RuleRulesetsSetCacheControlRuleActionParametersSMaxage] = FieldInfo( + alias="s-maxage", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_if_error: Optional[RuleRulesetsSetCacheControlRuleActionParametersStaleIfError] = FieldInfo( + alias="stale-if-error", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + stale_while_revalidate: Optional[RuleRulesetsSetCacheControlRuleActionParametersStaleWhileRevalidate] = FieldInfo( + alias="stale-while-revalidate", default=None + ) + """ + A cache-control directive configuration that accepts a duration value in + seconds. + """ + + +class RuleRulesetsSetCacheControlRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheControlRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheControlRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["set_cache_control"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheControlRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsSetCacheControlRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsSetCacheControlRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues(BaseModel): + """Add cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression(BaseModel): + """Add cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues(BaseModel): + """Remove cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression(BaseModel): + """Remove cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues(BaseModel): + """Set cache tags using a list of values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + values: List[str] + """A list of cache tag values.""" + + +class RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression(BaseModel): + """Set cache tags using an expression.""" + + expression: str + """An expression that evaluates to an array of cache tag values.""" + + operation: Literal["add", "remove", "set"] + """The operation to perform on the cache tags.""" + + +RuleRulesetsSetCacheTagsRuleActionParameters: TypeAlias = Union[ + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersAddCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersRemoveCacheTagsExpression, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsValues, + RuleRulesetsSetCacheTagsRuleActionParametersSetCacheTagsExpression, +] + + +class RuleRulesetsSetCacheTagsRuleExposedCredentialCheck(BaseModel): + """Configuration for exposed credential checking.""" + + password_expression: str + """An expression that selects the password used in the credentials check.""" + + username_expression: str + """An expression that selects the user ID used in the credentials check.""" + + +class RuleRulesetsSetCacheTagsRuleRatelimit(BaseModel): + """An object configuring the rule's rate limit behavior.""" + + characteristics: List[str] + """ + Characteristics of the request on which the rate limit counter will be + incremented. + """ + + period: int + """Period in seconds over which the counter is being incremented.""" + + counting_expression: Optional[str] = None + """An expression that defines when the rate limit counter should be incremented. + + It defaults to the same as the rule's expression. + """ + + mitigation_timeout: Optional[int] = None + """ + Period of time in seconds after which the action will be disabled following its + first execution. + """ + + requests_per_period: Optional[int] = None + """ + The threshold of requests per period after which the action will be executed for + the first time. + """ + + requests_to_origin: Optional[bool] = None + """Whether counting is only performed when an origin is reached.""" + + score_per_period: Optional[int] = None + """ + The score threshold per period for which the action will be executed the first + time. + """ + + score_response_header_name: Optional[str] = None + """ + A response header name provided by the origin, which contains the score to + increment rate limit counter with. + """ + + +class RuleRulesetsSetCacheTagsRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["set_cache_tags"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheTagsRuleActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + exposed_credential_check: Optional[RuleRulesetsSetCacheTagsRuleExposedCredentialCheck] = None + """Configuration for exposed credential checking.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[Logging] = None + """An object configuring the rule's logging behavior.""" + + ratelimit: Optional[RuleRulesetsSetCacheTagsRuleRatelimit] = None + """An object configuring the rule's rate limit behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule's ID by default).""" + + Rule: TypeAlias = Annotated[ Union[ BlockRule, @@ -249,7 +1009,9 @@ class RuleRulesetsJSChallengeRule(BaseModel): RouteRule, ScoreRule, ServeErrorRule, + RuleRulesetsSetCacheControlRule, SetCacheSettingsRule, + RuleRulesetsSetCacheTagsRule, SetConfigRule, SkipRule, ], diff --git a/src/cloudflare/types/security_txt/security_txt_get_response.py b/src/cloudflare/types/security_txt/security_txt_get_response.py index 21e896fb24a..9a2263d1101 100644 --- a/src/cloudflare/types/security_txt/security_txt_get_response.py +++ b/src/cloudflare/types/security_txt/security_txt_get_response.py @@ -3,8 +3,6 @@ from typing import List, Optional from datetime import datetime -from pydantic import Field as FieldInfo - from ..._models import BaseModel __all__ = ["SecurityTXTGetResponse"] @@ -27,4 +25,4 @@ class SecurityTXTGetResponse(BaseModel): policy: Optional[List[str]] = None - preferred_languages: Optional[str] = FieldInfo(alias="preferredLanguages", default=None) + preferred_languages: Optional[str] = None diff --git a/src/cloudflare/types/security_txt/security_txt_update_params.py b/src/cloudflare/types/security_txt/security_txt_update_params.py index cfd96dc16ac..ccd935f7bed 100644 --- a/src/cloudflare/types/security_txt/security_txt_update_params.py +++ b/src/cloudflare/types/security_txt/security_txt_update_params.py @@ -32,4 +32,4 @@ class SecurityTXTUpdateParams(TypedDict, total=False): policy: SequenceNotStr[str] - preferred_languages: Annotated[str, PropertyInfo(alias="preferredLanguages")] + preferred_languages: str diff --git a/src/cloudflare/types/speed/schedule_create_params.py b/src/cloudflare/types/speed/schedule_create_params.py index e776e4255d6..c36a7880435 100644 --- a/src/cloudflare/types/speed/schedule_create_params.py +++ b/src/cloudflare/types/speed/schedule_create_params.py @@ -11,6 +11,12 @@ class ScheduleCreateParams(TypedDict, total=False): zone_id: Required[str] """Identifier.""" + frequency: Literal["DAILY", "WEEKLY"] + """The frequency of the scheduled test. + + Defaults to WEEKLY for free plans, DAILY for paid plans. + """ + region: Literal[ "asia-east1", "asia-northeast1", diff --git a/src/cloudflare/types/token_validation/configuration_edit_response.py b/src/cloudflare/types/token_validation/configuration_edit_response.py index 662c55edd12..22545c20e04 100644 --- a/src/cloudflare/types/token_validation/configuration_edit_response.py +++ b/src/cloudflare/types/token_validation/configuration_edit_response.py @@ -8,6 +8,9 @@ class ConfigurationEditResponse(BaseModel): + id: Optional[str] = None + """UUID.""" + description: Optional[str] = None title: Optional[str] = None diff --git a/src/cloudflare/types/workers/beta/workers/version.py b/src/cloudflare/types/workers/beta/workers/version.py index 26a16505ff2..640ea8501c8 100644 --- a/src/cloudflare/types/workers/beta/workers/version.py +++ b/src/cloudflare/types/workers/beta/workers/version.py @@ -704,6 +704,13 @@ class Version(BaseModel): number: int """The integer version number, starting from one.""" + urls: List[str] + """All routable URLs that always point to this version. + + Does not include alias URLs, since aliases can be updated to point to a + different version. + """ + annotations: Optional[Annotations] = None """Metadata about the version.""" diff --git a/src/cloudflare/types/workflows/__init__.py b/src/cloudflare/types/workflows/__init__.py index 7ddd6aefea8..385d8fff853 100644 --- a/src/cloudflare/types/workflows/__init__.py +++ b/src/cloudflare/types/workflows/__init__.py @@ -2,6 +2,7 @@ from __future__ import annotations +from .instance_get_params import InstanceGetParams as InstanceGetParams from .version_list_params import VersionListParams as VersionListParams from .instance_bulk_params import InstanceBulkParams as InstanceBulkParams from .instance_list_params import InstanceListParams as InstanceListParams diff --git a/src/cloudflare/types/workflows/instance_get_params.py b/src/cloudflare/types/workflows/instance_get_params.py new file mode 100644 index 00000000000..eb22c5965ce --- /dev/null +++ b/src/cloudflare/types/workflows/instance_get_params.py @@ -0,0 +1,19 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["InstanceGetParams"] + + +class InstanceGetParams(TypedDict, total=False): + account_id: Required[str] + + workflow_name: Required[str] + + order: Literal["asc", "desc"] + """Step ordering: "asc" (default, oldest first) or "desc" (newest first).""" + + simple: Literal["true", "false"] + """When true, omits step details and returns only metadata with step_count.""" diff --git a/src/cloudflare/types/workflows/instance_get_response.py b/src/cloudflare/types/workflows/instance_get_response.py index e75ee1e2c6f..f25bfa25ead 100644 --- a/src/cloudflare/types/workflows/instance_get_response.py +++ b/src/cloudflare/types/workflows/instance_get_response.py @@ -157,6 +157,8 @@ class InstanceGetResponse(BaseModel): status: Literal["queued", "running", "paused", "errored", "terminated", "complete", "waitingForPause", "waiting"] + step_count: int + steps: List[Step] success: Optional[bool] = None diff --git a/src/cloudflare/types/workflows/version_get_response.py b/src/cloudflare/types/workflows/version_get_response.py index 51c1879072f..efcc075ab45 100644 --- a/src/cloudflare/types/workflows/version_get_response.py +++ b/src/cloudflare/types/workflows/version_get_response.py @@ -1,10 +1,15 @@ # 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__ = ["VersionGetResponse"] +__all__ = ["VersionGetResponse", "Limits"] + + +class Limits(BaseModel): + steps: Optional[int] = None class VersionGetResponse(BaseModel): @@ -19,3 +24,5 @@ class VersionGetResponse(BaseModel): modified_on: datetime workflow_id: str + + limits: Optional[Limits] = None diff --git a/src/cloudflare/types/workflows/version_list_response.py b/src/cloudflare/types/workflows/version_list_response.py index 03a9a24feef..4125333a1b4 100644 --- a/src/cloudflare/types/workflows/version_list_response.py +++ b/src/cloudflare/types/workflows/version_list_response.py @@ -1,10 +1,15 @@ # 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__ = ["VersionListResponse"] +__all__ = ["VersionListResponse", "Limits"] + + +class Limits(BaseModel): + steps: Optional[int] = None class VersionListResponse(BaseModel): @@ -19,3 +24,5 @@ class VersionListResponse(BaseModel): modified_on: datetime workflow_id: str + + limits: Optional[Limits] = None diff --git a/src/cloudflare/types/workflows/workflow_update_params.py b/src/cloudflare/types/workflows/workflow_update_params.py index 3cc22a14961..2ff781a484d 100644 --- a/src/cloudflare/types/workflows/workflow_update_params.py +++ b/src/cloudflare/types/workflows/workflow_update_params.py @@ -4,7 +4,7 @@ from typing_extensions import Required, TypedDict -__all__ = ["WorkflowUpdateParams"] +__all__ = ["WorkflowUpdateParams", "Limits"] class WorkflowUpdateParams(TypedDict, total=False): @@ -13,3 +13,9 @@ class WorkflowUpdateParams(TypedDict, total=False): class_name: Required[str] script_name: Required[str] + + limits: Limits + + +class Limits(TypedDict, total=False): + steps: int diff --git a/src/cloudflare/types/zero_trust/dlp/payload_log_get_response.py b/src/cloudflare/types/zero_trust/dlp/payload_log_get_response.py index 14a5fe92d59..0ee9d9e6406 100644 --- a/src/cloudflare/types/zero_trust/dlp/payload_log_get_response.py +++ b/src/cloudflare/types/zero_trust/dlp/payload_log_get_response.py @@ -10,7 +10,9 @@ class PayloadLogGetResponse(BaseModel): - masking_level: Literal["full", "partial", "clear", "default"] + updated_at: datetime + + masking_level: Optional[Literal["full", "partial", "clear", "default"]] = None """Masking level for payload logs. - `full`: The entire payload is masked. @@ -19,8 +21,6 @@ class PayloadLogGetResponse(BaseModel): - `default`: DLP uses its default masking behavior. """ - updated_at: datetime - public_key: Optional[str] = None """Base64-encoded public key for encrypting payload logs. diff --git a/src/cloudflare/types/zero_trust/dlp/payload_log_update_response.py b/src/cloudflare/types/zero_trust/dlp/payload_log_update_response.py index 20e305721e7..d5cb5fea76e 100644 --- a/src/cloudflare/types/zero_trust/dlp/payload_log_update_response.py +++ b/src/cloudflare/types/zero_trust/dlp/payload_log_update_response.py @@ -10,7 +10,9 @@ class PayloadLogUpdateResponse(BaseModel): - masking_level: Literal["full", "partial", "clear", "default"] + updated_at: datetime + + masking_level: Optional[Literal["full", "partial", "clear", "default"]] = None """Masking level for payload logs. - `full`: The entire payload is masked. @@ -19,8 +21,6 @@ class PayloadLogUpdateResponse(BaseModel): - `default`: DLP uses its default masking behavior. """ - updated_at: datetime - public_key: Optional[str] = None """Base64-encoded public key for encrypting payload logs. diff --git a/src/cloudflare/types/zero_trust/dlp/profile.py b/src/cloudflare/types/zero_trust/dlp/profile.py index 3e204f1c0fa..e5904c1c648 100644 --- a/src/cloudflare/types/zero_trust/dlp/profile.py +++ b/src/cloudflare/types/zero_trust/dlp/profile.py @@ -364,11 +364,20 @@ class CustomProfile(BaseModel): keywords. """ + data_classes: Optional[List[str]] = None + """Data classes associated with this profile.""" + + data_tags: Optional[List[str]] = None + """Data tags associated with this profile.""" + description: Optional[str] = None """The description of the profile.""" entries: Optional[List[CustomProfileEntry]] = None + sensitivity_levels: Optional[List[List[str]]] = None + """Sensitivity levels associated with this profile as (group_id, level_id) tuples.""" + shared_entries: Optional[List[CustomProfileSharedEntry]] = None diff --git a/src/cloudflare/types/zero_trust/dlp/profiles/custom_create_params.py b/src/cloudflare/types/zero_trust/dlp/profiles/custom_create_params.py index fa44d5c365f..61b88ede52d 100644 --- a/src/cloudflare/types/zero_trust/dlp/profiles/custom_create_params.py +++ b/src/cloudflare/types/zero_trust/dlp/profiles/custom_create_params.py @@ -30,6 +30,12 @@ class CustomCreateParams(TypedDict, total=False): keywords. """ + data_classes: SequenceNotStr[str] + """Data class IDs to associate with the profile.""" + + data_tags: SequenceNotStr[str] + """Data tag IDs to associate with the profile.""" + description: Optional[str] """The description of the profile.""" @@ -37,6 +43,11 @@ class CustomCreateParams(TypedDict, total=False): ocr_enabled: bool + sensitivity_levels: Iterable[SequenceNotStr[str]] + """ + Sensitivity levels to associate with the profile as (group_id, level_id) tuples. + """ + shared_entries: Iterable[SharedEntry] """Entries from other profiles (e.g. diff --git a/src/cloudflare/types/zero_trust/dlp/profiles/custom_update_params.py b/src/cloudflare/types/zero_trust/dlp/profiles/custom_update_params.py index b6b46d1059d..928b959cf0a 100644 --- a/src/cloudflare/types/zero_trust/dlp/profiles/custom_update_params.py +++ b/src/cloudflare/types/zero_trust/dlp/profiles/custom_update_params.py @@ -5,6 +5,7 @@ from typing import Union, Iterable, Optional from typing_extensions import Required, TypeAlias, TypedDict +from ....._types import SequenceNotStr from .pattern_param import PatternParam from ..context_awareness_param import ContextAwarenessParam @@ -28,6 +29,18 @@ class CustomUpdateParams(TypedDict, total=False): keywords. """ + data_classes: Optional[SequenceNotStr[str]] + """Data class IDs to associate with the profile. + + If omitted, existing associations are unchanged. + """ + + data_tags: Optional[SequenceNotStr[str]] + """Data tag IDs to associate with the profile. + + If omitted, existing associations are unchanged. + """ + description: Optional[str] """The description of the profile.""" @@ -39,6 +52,12 @@ class CustomUpdateParams(TypedDict, total=False): ocr_enabled: bool + sensitivity_levels: Optional[Iterable[SequenceNotStr[str]]] + """Sensitivity levels to associate with the profile. + + If omitted, existing associations are unchanged. + """ + shared_entries: Iterable[SharedEntry] """Other entries, e.g. predefined or integration.""" diff --git a/src/cloudflare/types/zones/setting_edit_response.py b/src/cloudflare/types/zones/setting_edit_response.py index 9a65fcb24a0..9fd2e3ef777 100644 --- a/src/cloudflare/types/zones/setting_edit_response.py +++ b/src/cloudflare/types/zones/setting_edit_response.py @@ -58,6 +58,7 @@ "ZonesCacheRulesOriginMaxHTTPVersion", "ZonesSchemasPolish", "ZonesPrivacyPass", + "ZonesRedirectsForAITraining", "ZonesReplaceInsecureJS", "ZonesSchemasResponseBuffering", "ZonesSchemasRocketLoader", @@ -508,6 +509,28 @@ class ZonesPrivacyPass(BaseModel): """last time this setting was modified.""" +class ZonesRedirectsForAITraining(BaseModel): + """ + When enabled, Cloudflare will redirect verified AI training crawlers to canonical URLs + found in the HTML response, ensuring AI models train on authoritative content. + """ + + id: Literal["redirects_for_ai_training"] + """ID of the zone setting.""" + + value: Literal["off", "on"] + """Current value of the zone setting.""" + + editable: Optional[Literal[True, False]] = None + """ + Whether or not this setting can be modified for this zone (based on your + Cloudflare plan level). + """ + + modified_on: Optional[datetime] = None + """last time this setting was modified.""" + + class ZonesReplaceInsecureJS(BaseModel): """ Automatically replace insecure JavaScript libraries with safer and faster alternatives provided under cdnjs and powered by Cloudflare. Currently supports the following libraries: Polyfill under polyfill.io. @@ -827,6 +850,7 @@ class ZonesSchemasWAF(BaseModel): ZonesPrivacyPass, ProxyReadTimeout, PseudoIPV4, + ZonesRedirectsForAITraining, ZonesReplaceInsecureJS, ZonesSchemasResponseBuffering, ZonesSchemasRocketLoader, diff --git a/src/cloudflare/types/zones/setting_get_response.py b/src/cloudflare/types/zones/setting_get_response.py index 5976efc6f37..ac20c206eb1 100644 --- a/src/cloudflare/types/zones/setting_get_response.py +++ b/src/cloudflare/types/zones/setting_get_response.py @@ -58,6 +58,7 @@ "ZonesCacheRulesOriginMaxHTTPVersion", "ZonesSchemasPolish", "ZonesPrivacyPass", + "ZonesRedirectsForAITraining", "ZonesReplaceInsecureJS", "ZonesSchemasResponseBuffering", "ZonesSchemasRocketLoader", @@ -508,6 +509,28 @@ class ZonesPrivacyPass(BaseModel): """last time this setting was modified.""" +class ZonesRedirectsForAITraining(BaseModel): + """ + When enabled, Cloudflare will redirect verified AI training crawlers to canonical URLs + found in the HTML response, ensuring AI models train on authoritative content. + """ + + id: Literal["redirects_for_ai_training"] + """ID of the zone setting.""" + + value: Literal["off", "on"] + """Current value of the zone setting.""" + + editable: Optional[Literal[True, False]] = None + """ + Whether or not this setting can be modified for this zone (based on your + Cloudflare plan level). + """ + + modified_on: Optional[datetime] = None + """last time this setting was modified.""" + + class ZonesReplaceInsecureJS(BaseModel): """ Automatically replace insecure JavaScript libraries with safer and faster alternatives provided under cdnjs and powered by Cloudflare. Currently supports the following libraries: Polyfill under polyfill.io. @@ -827,6 +850,7 @@ class ZonesSchemasWAF(BaseModel): ZonesPrivacyPass, ProxyReadTimeout, PseudoIPV4, + ZonesRedirectsForAITraining, ZonesReplaceInsecureJS, ZonesSchemasResponseBuffering, ZonesSchemasRocketLoader, diff --git a/tests/api_resources/aisearch/instances/test_items.py b/tests/api_resources/aisearch/instances/test_items.py index 1d2e15d03b9..b95f7b5d460 100644 --- a/tests/api_resources/aisearch/instances/test_items.py +++ b/tests/api_resources/aisearch/instances/test_items.py @@ -10,7 +10,7 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray -from cloudflare.types.aisearch.instances import ItemGetResponse, ItemListResponse +from cloudflare.types.aisearch.instances import ItemListResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -78,66 +78,6 @@ def test_path_params_list(self, client: Cloudflare) -> None: account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", ) - @parametrize - def test_method_get(self, client: Cloudflare) -> None: - item = client.aisearch.instances.items.get( - item_id="item_id", - account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", - id="my-ai-search", - ) - assert_matches_type(ItemGetResponse, item, path=["response"]) - - @parametrize - def test_raw_response_get(self, client: Cloudflare) -> None: - response = client.aisearch.instances.items.with_raw_response.get( - item_id="item_id", - account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", - id="my-ai-search", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - item = response.parse() - assert_matches_type(ItemGetResponse, item, path=["response"]) - - @parametrize - def test_streaming_response_get(self, client: Cloudflare) -> None: - with client.aisearch.instances.items.with_streaming_response.get( - item_id="item_id", - account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", - id="my-ai-search", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - item = response.parse() - assert_matches_type(ItemGetResponse, item, 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.aisearch.instances.items.with_raw_response.get( - item_id="item_id", - account_id="", - id="my-ai-search", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - client.aisearch.instances.items.with_raw_response.get( - item_id="item_id", - account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", - id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `item_id` but received ''"): - client.aisearch.instances.items.with_raw_response.get( - item_id="", - account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", - id="my-ai-search", - ) - class TestAsyncItems: parametrize = pytest.mark.parametrize( @@ -203,63 +143,3 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: id="", account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", ) - - @parametrize - async def test_method_get(self, async_client: AsyncCloudflare) -> None: - item = await async_client.aisearch.instances.items.get( - item_id="item_id", - account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", - id="my-ai-search", - ) - assert_matches_type(ItemGetResponse, item, path=["response"]) - - @parametrize - async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: - response = await async_client.aisearch.instances.items.with_raw_response.get( - item_id="item_id", - account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", - id="my-ai-search", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - item = await response.parse() - assert_matches_type(ItemGetResponse, item, path=["response"]) - - @parametrize - async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: - async with async_client.aisearch.instances.items.with_streaming_response.get( - item_id="item_id", - account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", - id="my-ai-search", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - item = await response.parse() - assert_matches_type(ItemGetResponse, item, 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.aisearch.instances.items.with_raw_response.get( - item_id="item_id", - account_id="", - id="my-ai-search", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - await async_client.aisearch.instances.items.with_raw_response.get( - item_id="item_id", - account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", - id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `item_id` but received ''"): - await async_client.aisearch.instances.items.with_raw_response.get( - item_id="", - account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", - id="my-ai-search", - ) diff --git a/tests/api_resources/aisearch/instances/test_jobs.py b/tests/api_resources/aisearch/instances/test_jobs.py index 9fa2d6a28d4..d66674d7e80 100644 --- a/tests/api_resources/aisearch/instances/test_jobs.py +++ b/tests/api_resources/aisearch/instances/test_jobs.py @@ -31,6 +31,15 @@ def test_method_create(self, client: Cloudflare) -> None: ) assert_matches_type(JobCreateResponse, job, path=["response"]) + @parametrize + def test_method_create_with_all_params(self, client: Cloudflare) -> None: + job = client.aisearch.instances.jobs.create( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + description="description", + ) + assert_matches_type(JobCreateResponse, job, path=["response"]) + @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: response = client.aisearch.instances.jobs.with_raw_response.create( @@ -274,6 +283,15 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(JobCreateResponse, job, path=["response"]) + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: + job = await async_client.aisearch.instances.jobs.create( + id="my-ai-search", + account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + description="description", + ) + assert_matches_type(JobCreateResponse, job, path=["response"]) + @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: response = await async_client.aisearch.instances.jobs.with_raw_response.create( diff --git a/tests/api_resources/aisearch/test_instances.py b/tests/api_resources/aisearch/test_instances.py index e65fdf05082..ddfc0435184 100644 --- a/tests/api_resources/aisearch/test_instances.py +++ b/tests/api_resources/aisearch/test_instances.py @@ -32,8 +32,6 @@ def test_method_create(self, client: Cloudflare) -> None: instance = client.aisearch.instances.create( account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", id="my-ai-search", - source="source", - type="r2", ) assert_matches_type(InstanceCreateResponse, instance, path=["response"]) @@ -42,10 +40,10 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: instance = client.aisearch.instances.create( account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", id="my-ai-search", - source="source", - type="r2", ai_gateway_id="ai_gateway_id", aisearch_model="@cf/meta/llama-3.3-70b-instruct-fp8-fast", + cache=True, + cache_threshold="super_strict_match", chunk=True, chunk_overlap=0, chunk_size=64, @@ -80,10 +78,19 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: }, reranking=True, reranking_model="@cf/baai/bge-reranker-base", - retrieval_options={"keyword_match_mode": "exact_match"}, + retrieval_options={ + "boost_by": [ + { + "field": "timestamp", + "direction": "desc", + } + ], + "keyword_match_mode": "exact_match", + }, rewrite_model="@cf/meta/llama-3.3-70b-instruct-fp8-fast", rewrite_query=True, score_threshold=0, + source="source", source_params={ "exclude_items": ["/admin/**", "/private/**", "**\\temp\\**"], "include_items": ["/blog/**", "/docs/**/*.html", "**\\blog\\**.html"], @@ -91,6 +98,12 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: "r2_jurisdiction": "r2_jurisdiction", "web_crawler": { "parse_options": { + "content_selector": [ + { + "path": "**/blog/**", + "selector": "article .post-body", + } + ], "include_headers": {"foo": "string"}, "include_images": True, "specific_sitemaps": [ @@ -108,6 +121,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: }, }, token_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + type="r2", ) assert_matches_type(InstanceCreateResponse, instance, path=["response"]) @@ -116,8 +130,6 @@ def test_raw_response_create(self, client: Cloudflare) -> None: response = client.aisearch.instances.with_raw_response.create( account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", id="my-ai-search", - source="source", - type="r2", ) assert response.is_closed is True @@ -130,8 +142,6 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: with client.aisearch.instances.with_streaming_response.create( account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", id="my-ai-search", - source="source", - type="r2", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -147,8 +157,6 @@ def test_path_params_create(self, client: Cloudflare) -> None: client.aisearch.instances.with_raw_response.create( account_id="", id="my-ai-search", - source="source", - type="r2", ) @parametrize @@ -203,7 +211,15 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: }, reranking=True, reranking_model="@cf/baai/bge-reranker-base", - retrieval_options={"keyword_match_mode": "exact_match"}, + retrieval_options={ + "boost_by": [ + { + "field": "timestamp", + "direction": "desc", + } + ], + "keyword_match_mode": "exact_match", + }, rewrite_model="@cf/meta/llama-3.3-70b-instruct-fp8-fast", rewrite_query=True, score_threshold=0, @@ -214,6 +230,12 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: "r2_jurisdiction": "r2_jurisdiction", "web_crawler": { "parse_options": { + "content_selector": [ + { + "path": "**/blog/**", + "selector": "article .post-body", + } + ], "include_headers": {"foo": "string"}, "include_images": True, "specific_sitemaps": [ @@ -290,6 +312,8 @@ def test_method_list(self, client: Cloudflare) -> None: def test_method_list_with_all_params(self, client: Cloudflare) -> None: instance = client.aisearch.instances.list( account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + order_by="created_at", + order_by_direction="asc", page=1, per_page=1, search="search", @@ -412,6 +436,12 @@ def test_method_chat_completions_with_all_params(self, client: Cloudflare) -> No "model": "@cf/baai/bge-reranker-base", }, "retrieval": { + "boost_by": [ + { + "field": "timestamp", + "direction": "desc", + } + ], "context_expansion": 0, "filters": {"foo": "bar"}, "fusion_method": "max", @@ -576,6 +606,12 @@ def test_method_search_with_all_params(self, client: Cloudflare) -> None: "model": "@cf/baai/bge-reranker-base", }, "retrieval": { + "boost_by": [ + { + "field": "timestamp", + "direction": "desc", + } + ], "context_expansion": 0, "filters": {"foo": "bar"}, "fusion_method": "max", @@ -712,8 +748,6 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: instance = await async_client.aisearch.instances.create( account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", id="my-ai-search", - source="source", - type="r2", ) assert_matches_type(InstanceCreateResponse, instance, path=["response"]) @@ -722,10 +756,10 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare instance = await async_client.aisearch.instances.create( account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", id="my-ai-search", - source="source", - type="r2", ai_gateway_id="ai_gateway_id", aisearch_model="@cf/meta/llama-3.3-70b-instruct-fp8-fast", + cache=True, + cache_threshold="super_strict_match", chunk=True, chunk_overlap=0, chunk_size=64, @@ -760,10 +794,19 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare }, reranking=True, reranking_model="@cf/baai/bge-reranker-base", - retrieval_options={"keyword_match_mode": "exact_match"}, + retrieval_options={ + "boost_by": [ + { + "field": "timestamp", + "direction": "desc", + } + ], + "keyword_match_mode": "exact_match", + }, rewrite_model="@cf/meta/llama-3.3-70b-instruct-fp8-fast", rewrite_query=True, score_threshold=0, + source="source", source_params={ "exclude_items": ["/admin/**", "/private/**", "**\\temp\\**"], "include_items": ["/blog/**", "/docs/**/*.html", "**\\blog\\**.html"], @@ -771,6 +814,12 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare "r2_jurisdiction": "r2_jurisdiction", "web_crawler": { "parse_options": { + "content_selector": [ + { + "path": "**/blog/**", + "selector": "article .post-body", + } + ], "include_headers": {"foo": "string"}, "include_images": True, "specific_sitemaps": [ @@ -788,6 +837,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare }, }, token_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + type="r2", ) assert_matches_type(InstanceCreateResponse, instance, path=["response"]) @@ -796,8 +846,6 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: response = await async_client.aisearch.instances.with_raw_response.create( account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", id="my-ai-search", - source="source", - type="r2", ) assert response.is_closed is True @@ -810,8 +858,6 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> async with async_client.aisearch.instances.with_streaming_response.create( account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", id="my-ai-search", - source="source", - type="r2", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -827,8 +873,6 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: await async_client.aisearch.instances.with_raw_response.create( account_id="", id="my-ai-search", - source="source", - type="r2", ) @parametrize @@ -883,7 +927,15 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare }, reranking=True, reranking_model="@cf/baai/bge-reranker-base", - retrieval_options={"keyword_match_mode": "exact_match"}, + retrieval_options={ + "boost_by": [ + { + "field": "timestamp", + "direction": "desc", + } + ], + "keyword_match_mode": "exact_match", + }, rewrite_model="@cf/meta/llama-3.3-70b-instruct-fp8-fast", rewrite_query=True, score_threshold=0, @@ -894,6 +946,12 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare "r2_jurisdiction": "r2_jurisdiction", "web_crawler": { "parse_options": { + "content_selector": [ + { + "path": "**/blog/**", + "selector": "article .post-body", + } + ], "include_headers": {"foo": "string"}, "include_images": True, "specific_sitemaps": [ @@ -970,6 +1028,8 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None: async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: instance = await async_client.aisearch.instances.list( account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + order_by="created_at", + order_by_direction="asc", page=1, per_page=1, search="search", @@ -1092,6 +1152,12 @@ async def test_method_chat_completions_with_all_params(self, async_client: Async "model": "@cf/baai/bge-reranker-base", }, "retrieval": { + "boost_by": [ + { + "field": "timestamp", + "direction": "desc", + } + ], "context_expansion": 0, "filters": {"foo": "bar"}, "fusion_method": "max", @@ -1256,6 +1322,12 @@ async def test_method_search_with_all_params(self, async_client: AsyncCloudflare "model": "@cf/baai/bge-reranker-base", }, "retrieval": { + "boost_by": [ + { + "field": "timestamp", + "direction": "desc", + } + ], "context_expansion": 0, "filters": {"foo": "bar"}, "fusion_method": "max", diff --git a/tests/api_resources/aisearch/test_tokens.py b/tests/api_resources/aisearch/test_tokens.py index 92ab27fd1db..1090f0fb388 100644 --- a/tests/api_resources/aisearch/test_tokens.py +++ b/tests/api_resources/aisearch/test_tokens.py @@ -148,6 +148,8 @@ def test_method_list(self, client: Cloudflare) -> None: def test_method_list_with_all_params(self, client: Cloudflare) -> None: token = client.aisearch.tokens.list( account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + order_by="created_at", + order_by_direction="asc", page=1, per_page=1, ) @@ -410,6 +412,8 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None: async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: token = await async_client.aisearch.tokens.list( account_id="c3dc5f0b34a14ff8e1b3ec04895e1b22", + order_by="created_at", + order_by_direction="asc", page=1, per_page=1, ) diff --git a/tests/api_resources/email_security/test_investigate.py b/tests/api_resources/email_security/test_investigate.py index 641cd669ad2..2368a3500c3 100644 --- a/tests/api_resources/email_security/test_investigate.py +++ b/tests/api_resources/email_security/test_investigate.py @@ -36,6 +36,7 @@ def test_method_list_with_all_params(self, client: Cloudflare) -> None: detections_only=True, domain="domain", end=parse_datetime("2019-12-27T18:11:19.117Z"), + exact_subject="exact_subject", final_disposition="MALICIOUS", message_action="PREVIEW", message_id="message_id", @@ -152,6 +153,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) detections_only=True, domain="domain", end=parse_datetime("2019-12-27T18:11:19.117Z"), + exact_subject="exact_subject", final_disposition="MALICIOUS", message_action="PREVIEW", message_id="message_id", diff --git a/tests/api_resources/email_security/test_submissions.py b/tests/api_resources/email_security/test_submissions.py index 0645b94fd7a..5c6e59faee4 100644 --- a/tests/api_resources/email_security/test_submissions.py +++ b/tests/api_resources/email_security/test_submissions.py @@ -30,6 +30,7 @@ def test_method_list(self, client: Cloudflare) -> None: def test_method_list_with_all_params(self, client: Cloudflare) -> None: submission = client.email_security.submissions.list( account_id="023e105f4ecef8ad9ca31a8372d0c353", + customer_status="escalated", end=parse_datetime("2019-12-27T18:11:19.117Z"), original_disposition="MALICIOUS", outcome_disposition="MALICIOUS", @@ -92,6 +93,7 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None: async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: submission = await async_client.email_security.submissions.list( account_id="023e105f4ecef8ad9ca31a8372d0c353", + customer_status="escalated", end=parse_datetime("2019-12-27T18:11:19.117Z"), original_disposition="MALICIOUS", outcome_disposition="MALICIOUS", diff --git a/tests/api_resources/magic_transit/sites/test_lans.py b/tests/api_resources/magic_transit/sites/test_lans.py index 967a5ba1c41..b5b9d2a9bc3 100644 --- a/tests/api_resources/magic_transit/sites/test_lans.py +++ b/tests/api_resources/magic_transit/sites/test_lans.py @@ -35,6 +35,8 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", bond_id=2, ha_link=True, + is_breakout=True, + is_prioritized=True, name="name", nat={"static_prefix": "192.0.2.0/24"}, physport=1, @@ -121,6 +123,8 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", bond_id=2, + is_breakout=True, + is_prioritized=True, name="name", nat={"static_prefix": "192.0.2.0/24"}, physport=1, @@ -326,6 +330,8 @@ def test_method_edit_with_all_params(self, client: Cloudflare) -> None: account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", bond_id=2, + is_breakout=True, + is_prioritized=True, name="name", nat={"static_prefix": "192.0.2.0/24"}, physport=1, @@ -488,6 +494,8 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare account_id="023e105f4ecef8ad9ca31a8372d0c353", bond_id=2, ha_link=True, + is_breakout=True, + is_prioritized=True, name="name", nat={"static_prefix": "192.0.2.0/24"}, physport=1, @@ -574,6 +582,8 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", bond_id=2, + is_breakout=True, + is_prioritized=True, name="name", nat={"static_prefix": "192.0.2.0/24"}, physport=1, @@ -779,6 +789,8 @@ async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) account_id="023e105f4ecef8ad9ca31a8372d0c353", site_id="023e105f4ecef8ad9ca31a8372d0c353", bond_id=2, + is_breakout=True, + is_prioritized=True, name="name", nat={"static_prefix": "192.0.2.0/24"}, physport=1, diff --git a/tests/api_resources/magic_transit/test_apps.py b/tests/api_resources/magic_transit/test_apps.py index bfa9adeceb6..688d2516556 100644 --- a/tests/api_resources/magic_transit/test_apps.py +++ b/tests/api_resources/magic_transit/test_apps.py @@ -47,6 +47,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: type="Development", hostnames=["auth.cloudflare.com"], ip_subnets=["192.0.2.0/24"], + source_subnets=["192.0.2.0/24"], ) assert_matches_type(Optional[AppCreateResponse], app, path=["response"]) @@ -118,6 +119,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: hostnames=["auth.cloudflare.com"], ip_subnets=["1.1.1.1/32"], name="Cloudflare Dashboard", + source_subnets=["1.1.1.1/32"], type="Development", ) assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) @@ -291,6 +293,7 @@ def test_method_edit_with_all_params(self, client: Cloudflare) -> None: hostnames=["auth.cloudflare.com"], ip_subnets=["1.1.1.1/32"], name="Cloudflare Dashboard", + source_subnets=["1.1.1.1/32"], type="Development", ) assert_matches_type(Optional[AppEditResponse], app, path=["response"]) @@ -373,6 +376,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare type="Development", hostnames=["auth.cloudflare.com"], ip_subnets=["192.0.2.0/24"], + source_subnets=["192.0.2.0/24"], ) assert_matches_type(Optional[AppCreateResponse], app, path=["response"]) @@ -444,6 +448,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare hostnames=["auth.cloudflare.com"], ip_subnets=["1.1.1.1/32"], name="Cloudflare Dashboard", + source_subnets=["1.1.1.1/32"], type="Development", ) assert_matches_type(Optional[AppUpdateResponse], app, path=["response"]) @@ -617,6 +622,7 @@ async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) hostnames=["auth.cloudflare.com"], ip_subnets=["1.1.1.1/32"], name="Cloudflare Dashboard", + source_subnets=["1.1.1.1/32"], type="Development", ) assert_matches_type(Optional[AppEditResponse], app, path=["response"]) diff --git a/tests/api_resources/magic_transit/test_connectors.py b/tests/api_resources/magic_transit/test_connectors.py index 77bb1d77052..17cf666175a 100644 --- a/tests/api_resources/magic_transit/test_connectors.py +++ b/tests/api_resources/magic_transit/test_connectors.py @@ -49,7 +49,9 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: "serial_number": "serial_number", }, activated=True, - interrupt_window_duration_hours=0, + interrupt_window_days_of_week=["Sunday"], + interrupt_window_duration_hours=1, + interrupt_window_embargo_dates=["string"], interrupt_window_hour_of_day=0, notes="notes", timezone="timezone", @@ -113,7 +115,9 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: connector_id="connector_id", account_id="023e105f4ecef8ad9ca31a8372d0c353", activated=True, - interrupt_window_duration_hours=0, + interrupt_window_days_of_week=["Sunday"], + interrupt_window_duration_hours=1, + interrupt_window_embargo_dates=["string"], interrupt_window_hour_of_day=0, notes="notes", provision_license=True, @@ -261,7 +265,9 @@ def test_method_edit_with_all_params(self, client: Cloudflare) -> None: connector_id="connector_id", account_id="023e105f4ecef8ad9ca31a8372d0c353", activated=True, - interrupt_window_duration_hours=0, + interrupt_window_days_of_week=["Sunday"], + interrupt_window_duration_hours=1, + interrupt_window_embargo_dates=["string"], interrupt_window_hour_of_day=0, notes="notes", provision_license=True, @@ -387,7 +393,9 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare "serial_number": "serial_number", }, activated=True, - interrupt_window_duration_hours=0, + interrupt_window_days_of_week=["Sunday"], + interrupt_window_duration_hours=1, + interrupt_window_embargo_dates=["string"], interrupt_window_hour_of_day=0, notes="notes", timezone="timezone", @@ -451,7 +459,9 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare connector_id="connector_id", account_id="023e105f4ecef8ad9ca31a8372d0c353", activated=True, - interrupt_window_duration_hours=0, + interrupt_window_days_of_week=["Sunday"], + interrupt_window_duration_hours=1, + interrupt_window_embargo_dates=["string"], interrupt_window_hour_of_day=0, notes="notes", provision_license=True, @@ -599,7 +609,9 @@ async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) connector_id="connector_id", account_id="023e105f4ecef8ad9ca31a8372d0c353", activated=True, - interrupt_window_duration_hours=0, + interrupt_window_days_of_week=["Sunday"], + interrupt_window_duration_hours=1, + interrupt_window_embargo_dates=["string"], interrupt_window_hour_of_day=0, notes="notes", provision_license=True, diff --git a/tests/api_resources/radar/ai/test_inference.py b/tests/api_resources/radar/ai/test_inference.py index f9da17395a9..331b1934fd8 100644 --- a/tests/api_resources/radar/ai/test_inference.py +++ b/tests/api_resources/radar/ai/test_inference.py @@ -89,7 +89,7 @@ def test_method_timeseries_groups_v2_with_all_params(self, client: Cloudflare) - limit_per_group=10, location=["string"], name=["main_series"], - normalization="MIN0_MAX", + normalization="PERCENTAGE", ) assert_matches_type(InferenceTimeseriesGroupsV2Response, inference, path=["response"]) @@ -191,7 +191,7 @@ async def test_method_timeseries_groups_v2_with_all_params(self, async_client: A limit_per_group=10, location=["string"], name=["main_series"], - normalization="MIN0_MAX", + normalization="PERCENTAGE", ) assert_matches_type(InferenceTimeseriesGroupsV2Response, inference, path=["response"]) diff --git a/tests/api_resources/radar/test_dns.py b/tests/api_resources/radar/test_dns.py index 9d11fe15abb..f863244f5b0 100644 --- a/tests/api_resources/radar/test_dns.py +++ b/tests/api_resources/radar/test_dns.py @@ -25,14 +25,14 @@ class TestDNS: @parametrize def test_method_summary_v2(self, client: Cloudflare) -> None: dns = client.radar.dns.summary_v2( - dimension="IP_VERSION", + dimension="AS", ) assert_matches_type(DNSSummaryV2Response, dns, path=["response"]) @parametrize def test_method_summary_v2_with_all_params(self, client: Cloudflare) -> None: dns = client.radar.dns.summary_v2( - dimension="IP_VERSION", + dimension="AS", asn=["string"], cache_hit=[True], continent=["string"], @@ -60,7 +60,7 @@ def test_method_summary_v2_with_all_params(self, client: Cloudflare) -> None: @parametrize def test_raw_response_summary_v2(self, client: Cloudflare) -> None: response = client.radar.dns.with_raw_response.summary_v2( - dimension="IP_VERSION", + dimension="AS", ) assert response.is_closed is True @@ -71,7 +71,7 @@ def test_raw_response_summary_v2(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_summary_v2(self, client: Cloudflare) -> None: with client.radar.dns.with_streaming_response.summary_v2( - dimension="IP_VERSION", + dimension="AS", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -136,14 +136,14 @@ def test_streaming_response_timeseries(self, client: Cloudflare) -> None: @parametrize def test_method_timeseries_groups_v2(self, client: Cloudflare) -> None: dns = client.radar.dns.timeseries_groups_v2( - dimension="IP_VERSION", + dimension="AS", ) assert_matches_type(DNSTimeseriesGroupsV2Response, dns, path=["response"]) @parametrize def test_method_timeseries_groups_v2_with_all_params(self, client: Cloudflare) -> None: dns = client.radar.dns.timeseries_groups_v2( - dimension="IP_VERSION", + dimension="AS", agg_interval="1h", asn=["string"], cache_hit=[True], @@ -173,7 +173,7 @@ def test_method_timeseries_groups_v2_with_all_params(self, client: Cloudflare) - @parametrize def test_raw_response_timeseries_groups_v2(self, client: Cloudflare) -> None: response = client.radar.dns.with_raw_response.timeseries_groups_v2( - dimension="IP_VERSION", + dimension="AS", ) assert response.is_closed is True @@ -184,7 +184,7 @@ def test_raw_response_timeseries_groups_v2(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_timeseries_groups_v2(self, client: Cloudflare) -> None: with client.radar.dns.with_streaming_response.timeseries_groups_v2( - dimension="IP_VERSION", + dimension="AS", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -203,14 +203,14 @@ class TestAsyncDNS: @parametrize async def test_method_summary_v2(self, async_client: AsyncCloudflare) -> None: dns = await async_client.radar.dns.summary_v2( - dimension="IP_VERSION", + dimension="AS", ) assert_matches_type(DNSSummaryV2Response, dns, path=["response"]) @parametrize async def test_method_summary_v2_with_all_params(self, async_client: AsyncCloudflare) -> None: dns = await async_client.radar.dns.summary_v2( - dimension="IP_VERSION", + dimension="AS", asn=["string"], cache_hit=[True], continent=["string"], @@ -238,7 +238,7 @@ async def test_method_summary_v2_with_all_params(self, async_client: AsyncCloudf @parametrize async def test_raw_response_summary_v2(self, async_client: AsyncCloudflare) -> None: response = await async_client.radar.dns.with_raw_response.summary_v2( - dimension="IP_VERSION", + dimension="AS", ) assert response.is_closed is True @@ -249,7 +249,7 @@ async def test_raw_response_summary_v2(self, async_client: AsyncCloudflare) -> N @parametrize async def test_streaming_response_summary_v2(self, async_client: AsyncCloudflare) -> None: async with async_client.radar.dns.with_streaming_response.summary_v2( - dimension="IP_VERSION", + dimension="AS", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -314,14 +314,14 @@ async def test_streaming_response_timeseries(self, async_client: AsyncCloudflare @parametrize async def test_method_timeseries_groups_v2(self, async_client: AsyncCloudflare) -> None: dns = await async_client.radar.dns.timeseries_groups_v2( - dimension="IP_VERSION", + dimension="AS", ) assert_matches_type(DNSTimeseriesGroupsV2Response, dns, path=["response"]) @parametrize async def test_method_timeseries_groups_v2_with_all_params(self, async_client: AsyncCloudflare) -> None: dns = await async_client.radar.dns.timeseries_groups_v2( - dimension="IP_VERSION", + dimension="AS", agg_interval="1h", asn=["string"], cache_hit=[True], @@ -351,7 +351,7 @@ async def test_method_timeseries_groups_v2_with_all_params(self, async_client: A @parametrize async def test_raw_response_timeseries_groups_v2(self, async_client: AsyncCloudflare) -> None: response = await async_client.radar.dns.with_raw_response.timeseries_groups_v2( - dimension="IP_VERSION", + dimension="AS", ) assert response.is_closed is True @@ -362,7 +362,7 @@ async def test_raw_response_timeseries_groups_v2(self, async_client: AsyncCloudf @parametrize async def test_streaming_response_timeseries_groups_v2(self, async_client: AsyncCloudflare) -> None: async with async_client.radar.dns.with_streaming_response.timeseries_groups_v2( - dimension="IP_VERSION", + dimension="AS", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" diff --git a/tests/api_resources/rulesets/test_rules.py b/tests/api_resources/rulesets/test_rules.py index a15cd560be1..5d0a23444f9 100644 --- a/tests/api_resources/rulesets/test_rules.py +++ b/tests/api_resources/rulesets/test_rules.py @@ -1467,6 +1467,155 @@ def test_method_create_overload_16(self, client: Cloudflare) -> None: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_method_create_with_all_params_overload_16(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="set_cache_control", + action_parameters={ + "immutable": { + "operation": "set", + "cloudflare_only": False, + }, + "max_age": { + "operation": "set", + "value": 3600, + "cloudflare_only": False, + }, + "must_revalidate": { + "operation": "set", + "cloudflare_only": False, + }, + "must_understand": { + "operation": "set", + "cloudflare_only": False, + }, + "no_cache": { + "operation": "set", + "cloudflare_only": False, + "qualifiers": ["X-Custom-Header"], + }, + "no_store": { + "operation": "set", + "cloudflare_only": False, + }, + "no_transform": { + "operation": "set", + "cloudflare_only": False, + }, + "private": { + "operation": "set", + "cloudflare_only": False, + "qualifiers": ["X-Custom-Header"], + }, + "proxy_revalidate": { + "operation": "set", + "cloudflare_only": False, + }, + "public": { + "operation": "set", + "cloudflare_only": False, + }, + "s_maxage": { + "operation": "set", + "value": 3600, + "cloudflare_only": False, + }, + "stale_if_error": { + "operation": "set", + "value": 3600, + "cloudflare_only": False, + }, + "stale_while_revalidate": { + "operation": "set", + "value": 3600, + "cloudflare_only": False, + }, + }, + description="Modify the cache-control header directives in an Origin response.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_create_overload_16(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_create_overload_16(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_create_overload_16(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_overload_17(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_with_all_params_overload_17(self, client: Cloudflare) -> None: rule = client.rulesets.rules.create( ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="account_id", @@ -1535,6 +1684,9 @@ def test_method_create_with_all_params_overload_16(self, client: Cloudflare) -> "read_timeout": 900, "respect_strong_etags": True, "serve_stale": {"disable_stale_while_updating": True}, + "strip_etags": True, + "strip_last_modified": True, + "strip_set_cookie": True, }, description="Configure settings for how the response is cached.", enabled=True, @@ -1561,7 +1713,7 @@ def test_method_create_with_all_params_overload_16(self, client: Cloudflare) -> @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_raw_response_create_overload_16(self, client: Cloudflare) -> None: + def test_raw_response_create_overload_17(self, client: Cloudflare) -> None: response = client.rulesets.rules.with_raw_response.create( ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="account_id", @@ -1574,7 +1726,7 @@ def test_raw_response_create_overload_16(self, client: Cloudflare) -> None: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_streaming_response_create_overload_16(self, client: Cloudflare) -> None: + def test_streaming_response_create_overload_17(self, client: Cloudflare) -> None: with client.rulesets.rules.with_streaming_response.create( ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="account_id", @@ -1589,7 +1741,7 @@ def test_streaming_response_create_overload_16(self, client: Cloudflare) -> None @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_path_params_create_overload_16(self, client: Cloudflare) -> None: + def test_path_params_create_overload_17(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): client.rulesets.rules.with_raw_response.create( ruleset_id="", @@ -1610,7 +1762,7 @@ def test_path_params_create_overload_16(self, client: Cloudflare) -> None: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_method_create_overload_17(self, client: Cloudflare) -> None: + def test_method_create_overload_18(self, client: Cloudflare) -> None: rule = client.rulesets.rules.create( ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="account_id", @@ -1619,7 +1771,100 @@ def test_method_create_overload_17(self, client: Cloudflare) -> None: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_method_create_with_all_params_overload_17(self, client: Cloudflare) -> None: + def test_method_create_with_all_params_overload_18(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="set_cache_tags", + action_parameters={ + "operation": "add", + "values": ["my-cache-tag"], + }, + description="Modify the cache tags associated with the response.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_create_overload_18(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_create_overload_18(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_create_overload_18(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_overload_19(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_create_with_all_params_overload_19(self, client: Cloudflare) -> None: rule = client.rulesets.rules.create( ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="account_id", @@ -1677,7 +1922,7 @@ def test_method_create_with_all_params_overload_17(self, client: Cloudflare) -> @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_raw_response_create_overload_17(self, client: Cloudflare) -> None: + def test_raw_response_create_overload_19(self, client: Cloudflare) -> None: response = client.rulesets.rules.with_raw_response.create( ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="account_id", @@ -1690,7 +1935,7 @@ def test_raw_response_create_overload_17(self, client: Cloudflare) -> None: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_streaming_response_create_overload_17(self, client: Cloudflare) -> None: + def test_streaming_response_create_overload_19(self, client: Cloudflare) -> None: with client.rulesets.rules.with_streaming_response.create( ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="account_id", @@ -1705,7 +1950,7 @@ def test_streaming_response_create_overload_17(self, client: Cloudflare) -> None @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_path_params_create_overload_17(self, client: Cloudflare) -> None: + def test_path_params_create_overload_19(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): client.rulesets.rules.with_raw_response.create( ruleset_id="", @@ -1726,7 +1971,7 @@ def test_path_params_create_overload_17(self, client: Cloudflare) -> None: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_method_create_overload_18(self, client: Cloudflare) -> None: + def test_method_create_overload_20(self, client: Cloudflare) -> None: rule = client.rulesets.rules.create( ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="account_id", @@ -1735,7 +1980,7 @@ def test_method_create_overload_18(self, client: Cloudflare) -> None: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_method_create_with_all_params_overload_18(self, client: Cloudflare) -> None: + def test_method_create_with_all_params_overload_20(self, client: Cloudflare) -> None: rule = client.rulesets.rules.create( ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="account_id", @@ -1774,7 +2019,7 @@ def test_method_create_with_all_params_overload_18(self, client: Cloudflare) -> @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_raw_response_create_overload_18(self, client: Cloudflare) -> None: + def test_raw_response_create_overload_20(self, client: Cloudflare) -> None: response = client.rulesets.rules.with_raw_response.create( ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="account_id", @@ -1787,7 +2032,7 @@ def test_raw_response_create_overload_18(self, client: Cloudflare) -> None: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_streaming_response_create_overload_18(self, client: Cloudflare) -> None: + def test_streaming_response_create_overload_20(self, client: Cloudflare) -> None: with client.rulesets.rules.with_streaming_response.create( ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="account_id", @@ -1802,7 +2047,7 @@ def test_streaming_response_create_overload_18(self, client: Cloudflare) -> None @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_path_params_create_overload_18(self, client: Cloudflare) -> None: + def test_path_params_create_overload_20(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): client.rulesets.rules.with_raw_response.create( ruleset_id="", @@ -3564,59 +3809,222 @@ def test_method_edit_with_all_params_overload_16(self, client: Cloudflare) -> No ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="account_id", id="3a03d665bac047339bb530ecb439a90d", - action="set_cache_settings", + action="set_cache_control", action_parameters={ - "additional_cacheable_ports": [8080], - "browser_ttl": { - "mode": "override_origin", - "default": 60, + "immutable": { + "operation": "set", + "cloudflare_only": False, }, - "cache": True, - "cache_key": { - "cache_by_device_type": True, - "cache_deception_armor": True, - "custom_key": { - "cookie": { - "check_presence": ["myCookie"], - "include": ["myCookie"], - }, - "header": { - "check_presence": ["my-header"], - "contains": {"my-header": ["my-header-value-1", "my-header-value-2"]}, - "exclude_origin": True, - "include": ["my-header"], - }, - "host": {"resolved": True}, - "query_string": { - "exclude": { - "all": True, - "list": ["foo"], - }, - "include": { - "all": True, - "list": ["foo"], - }, - }, - "user": { - "device_type": True, - "geo": True, - "lang": True, - }, - }, - "ignore_query_strings_order": True, + "max_age": { + "operation": "set", + "value": 3600, + "cloudflare_only": False, }, - "cache_reserve": { - "eligible": True, - "minimum_file_size": 1024, + "must_revalidate": { + "operation": "set", + "cloudflare_only": False, }, - "edge_ttl": { - "mode": "override_origin", - "default": 60, - "status_code_ttl": [ - { - "value": 0, - "status_code": 200, - "status_code_range": { + "must_understand": { + "operation": "set", + "cloudflare_only": False, + }, + "no_cache": { + "operation": "set", + "cloudflare_only": False, + "qualifiers": ["X-Custom-Header"], + }, + "no_store": { + "operation": "set", + "cloudflare_only": False, + }, + "no_transform": { + "operation": "set", + "cloudflare_only": False, + }, + "private": { + "operation": "set", + "cloudflare_only": False, + "qualifiers": ["X-Custom-Header"], + }, + "proxy_revalidate": { + "operation": "set", + "cloudflare_only": False, + }, + "public": { + "operation": "set", + "cloudflare_only": False, + }, + "s_maxage": { + "operation": "set", + "value": 3600, + "cloudflare_only": False, + }, + "stale_if_error": { + "operation": "set", + "value": 3600, + "cloudflare_only": False, + }, + "stale_while_revalidate": { + "operation": "set", + "value": 3600, + "cloudflare_only": False, + }, + }, + description="Modify the cache-control header directives in an Origin response.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_edit_overload_16(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_edit_overload_16(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_edit_overload_16(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_overload_17(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_with_all_params_overload_17(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="set_cache_settings", + action_parameters={ + "additional_cacheable_ports": [8080], + "browser_ttl": { + "mode": "override_origin", + "default": 60, + }, + "cache": True, + "cache_key": { + "cache_by_device_type": True, + "cache_deception_armor": True, + "custom_key": { + "cookie": { + "check_presence": ["myCookie"], + "include": ["myCookie"], + }, + "header": { + "check_presence": ["my-header"], + "contains": {"my-header": ["my-header-value-1", "my-header-value-2"]}, + "exclude_origin": True, + "include": ["my-header"], + }, + "host": {"resolved": True}, + "query_string": { + "exclude": { + "all": True, + "list": ["foo"], + }, + "include": { + "all": True, + "list": ["foo"], + }, + }, + "user": { + "device_type": True, + "geo": True, + "lang": True, + }, + }, + "ignore_query_strings_order": True, + }, + "cache_reserve": { + "eligible": True, + "minimum_file_size": 1024, + }, + "edge_ttl": { + "mode": "override_origin", + "default": 60, + "status_code_ttl": [ + { + "value": 0, + "status_code": 200, + "status_code_range": { "from": 200, "to": 299, }, @@ -3628,6 +4036,9 @@ def test_method_edit_with_all_params_overload_16(self, client: Cloudflare) -> No "read_timeout": 900, "respect_strong_etags": True, "serve_stale": {"disable_stale_while_updating": True}, + "strip_etags": True, + "strip_last_modified": True, + "strip_set_cookie": True, }, description="Configure settings for how the response is cached.", enabled=True, @@ -3654,7 +4065,7 @@ def test_method_edit_with_all_params_overload_16(self, client: Cloudflare) -> No @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_raw_response_edit_overload_16(self, client: Cloudflare) -> None: + def test_raw_response_edit_overload_17(self, client: Cloudflare) -> None: response = client.rulesets.rules.with_raw_response.edit( rule_id="3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", @@ -3668,7 +4079,7 @@ def test_raw_response_edit_overload_16(self, client: Cloudflare) -> None: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_streaming_response_edit_overload_16(self, client: Cloudflare) -> None: + def test_streaming_response_edit_overload_17(self, client: Cloudflare) -> None: with client.rulesets.rules.with_streaming_response.edit( rule_id="3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", @@ -3684,7 +4095,7 @@ def test_streaming_response_edit_overload_16(self, client: Cloudflare) -> None: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_path_params_edit_overload_16(self, client: Cloudflare) -> None: + def test_path_params_edit_overload_17(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): client.rulesets.rules.with_raw_response.edit( rule_id="3a03d665bac047339bb530ecb439a90d", @@ -3715,7 +4126,7 @@ def test_path_params_edit_overload_16(self, client: Cloudflare) -> None: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_method_edit_overload_17(self, client: Cloudflare) -> None: + def test_method_edit_overload_18(self, client: Cloudflare) -> None: rule = client.rulesets.rules.edit( rule_id="3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", @@ -3725,7 +4136,114 @@ def test_method_edit_overload_17(self, client: Cloudflare) -> None: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_method_edit_with_all_params_overload_17(self, client: Cloudflare) -> None: + def test_method_edit_with_all_params_overload_18(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="set_cache_tags", + action_parameters={ + "operation": "add", + "values": ["my-cache-tag"], + }, + description="Modify the cache tags associated with the response.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_raw_response_edit_overload_18(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_streaming_response_edit_overload_18(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_path_params_edit_overload_18(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_overload_19(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + def test_method_edit_with_all_params_overload_19(self, client: Cloudflare) -> None: rule = client.rulesets.rules.edit( rule_id="3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", @@ -3784,7 +4302,7 @@ def test_method_edit_with_all_params_overload_17(self, client: Cloudflare) -> No @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_raw_response_edit_overload_17(self, client: Cloudflare) -> None: + def test_raw_response_edit_overload_19(self, client: Cloudflare) -> None: response = client.rulesets.rules.with_raw_response.edit( rule_id="3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", @@ -3798,7 +4316,7 @@ def test_raw_response_edit_overload_17(self, client: Cloudflare) -> None: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_streaming_response_edit_overload_17(self, client: Cloudflare) -> None: + def test_streaming_response_edit_overload_19(self, client: Cloudflare) -> None: with client.rulesets.rules.with_streaming_response.edit( rule_id="3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", @@ -3814,7 +4332,7 @@ def test_streaming_response_edit_overload_17(self, client: Cloudflare) -> None: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_path_params_edit_overload_17(self, client: Cloudflare) -> None: + def test_path_params_edit_overload_19(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): client.rulesets.rules.with_raw_response.edit( rule_id="3a03d665bac047339bb530ecb439a90d", @@ -3845,7 +4363,7 @@ def test_path_params_edit_overload_17(self, client: Cloudflare) -> None: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_method_edit_overload_18(self, client: Cloudflare) -> None: + def test_method_edit_overload_20(self, client: Cloudflare) -> None: rule = client.rulesets.rules.edit( rule_id="3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", @@ -3855,7 +4373,7 @@ def test_method_edit_overload_18(self, client: Cloudflare) -> None: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_method_edit_with_all_params_overload_18(self, client: Cloudflare) -> None: + def test_method_edit_with_all_params_overload_20(self, client: Cloudflare) -> None: rule = client.rulesets.rules.edit( rule_id="3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", @@ -3895,7 +4413,7 @@ def test_method_edit_with_all_params_overload_18(self, client: Cloudflare) -> No @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_raw_response_edit_overload_18(self, client: Cloudflare) -> None: + def test_raw_response_edit_overload_20(self, client: Cloudflare) -> None: response = client.rulesets.rules.with_raw_response.edit( rule_id="3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", @@ -3909,7 +4427,7 @@ def test_raw_response_edit_overload_18(self, client: Cloudflare) -> None: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_streaming_response_edit_overload_18(self, client: Cloudflare) -> None: + def test_streaming_response_edit_overload_20(self, client: Cloudflare) -> None: with client.rulesets.rules.with_streaming_response.edit( rule_id="3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", @@ -3925,7 +4443,7 @@ def test_streaming_response_edit_overload_18(self, client: Cloudflare) -> None: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - def test_path_params_edit_overload_18(self, client: Cloudflare) -> None: + def test_path_params_edit_overload_20(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): client.rulesets.rules.with_raw_response.edit( rule_id="3a03d665bac047339bb530ecb439a90d", @@ -5406,6 +5924,155 @@ async def test_method_create_overload_16(self, async_client: AsyncCloudflare) -> @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_method_create_with_all_params_overload_16(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="set_cache_control", + action_parameters={ + "immutable": { + "operation": "set", + "cloudflare_only": False, + }, + "max_age": { + "operation": "set", + "value": 3600, + "cloudflare_only": False, + }, + "must_revalidate": { + "operation": "set", + "cloudflare_only": False, + }, + "must_understand": { + "operation": "set", + "cloudflare_only": False, + }, + "no_cache": { + "operation": "set", + "cloudflare_only": False, + "qualifiers": ["X-Custom-Header"], + }, + "no_store": { + "operation": "set", + "cloudflare_only": False, + }, + "no_transform": { + "operation": "set", + "cloudflare_only": False, + }, + "private": { + "operation": "set", + "cloudflare_only": False, + "qualifiers": ["X-Custom-Header"], + }, + "proxy_revalidate": { + "operation": "set", + "cloudflare_only": False, + }, + "public": { + "operation": "set", + "cloudflare_only": False, + }, + "s_maxage": { + "operation": "set", + "value": 3600, + "cloudflare_only": False, + }, + "stale_if_error": { + "operation": "set", + "value": 3600, + "cloudflare_only": False, + }, + "stale_while_revalidate": { + "operation": "set", + "value": 3600, + "cloudflare_only": False, + }, + }, + description="Modify the cache-control header directives in an Origin response.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create_overload_16(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create_overload_16(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create_overload_16(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_overload_17(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params_overload_17(self, async_client: AsyncCloudflare) -> None: rule = await async_client.rulesets.rules.create( ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="account_id", @@ -5474,8 +6141,104 @@ async def test_method_create_with_all_params_overload_16(self, async_client: Asy "read_timeout": 900, "respect_strong_etags": True, "serve_stale": {"disable_stale_while_updating": True}, + "strip_etags": True, + "strip_last_modified": True, + "strip_set_cookie": True, + }, + description="Configure settings for how the response is cached.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_create_overload_17(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_create_overload_17(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_create_overload_17(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_overload_18(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_create_with_all_params_overload_18(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="set_cache_tags", + action_parameters={ + "operation": "add", + "values": ["my-cache-tag"], }, - description="Configure settings for how the response is cached.", + description="Modify the cache tags associated with the response.", enabled=True, exposed_credential_check={ "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', @@ -5500,7 +6263,7 @@ async def test_method_create_with_all_params_overload_16(self, async_client: Asy @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_create_overload_16(self, async_client: AsyncCloudflare) -> None: + async def test_raw_response_create_overload_18(self, async_client: AsyncCloudflare) -> None: response = await async_client.rulesets.rules.with_raw_response.create( ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="account_id", @@ -5513,7 +6276,7 @@ async def test_raw_response_create_overload_16(self, async_client: AsyncCloudfla @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_create_overload_16(self, async_client: AsyncCloudflare) -> None: + async def test_streaming_response_create_overload_18(self, async_client: AsyncCloudflare) -> None: async with async_client.rulesets.rules.with_streaming_response.create( ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="account_id", @@ -5528,7 +6291,7 @@ async def test_streaming_response_create_overload_16(self, async_client: AsyncCl @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_create_overload_16(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_create_overload_18(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): await async_client.rulesets.rules.with_raw_response.create( ruleset_id="", @@ -5549,7 +6312,7 @@ async def test_path_params_create_overload_16(self, async_client: AsyncCloudflar @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_create_overload_17(self, async_client: AsyncCloudflare) -> None: + async def test_method_create_overload_19(self, async_client: AsyncCloudflare) -> None: rule = await async_client.rulesets.rules.create( ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="account_id", @@ -5558,7 +6321,7 @@ async def test_method_create_overload_17(self, async_client: AsyncCloudflare) -> @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_create_with_all_params_overload_17(self, async_client: AsyncCloudflare) -> None: + async def test_method_create_with_all_params_overload_19(self, async_client: AsyncCloudflare) -> None: rule = await async_client.rulesets.rules.create( ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="account_id", @@ -5616,7 +6379,7 @@ async def test_method_create_with_all_params_overload_17(self, async_client: Asy @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_create_overload_17(self, async_client: AsyncCloudflare) -> None: + async def test_raw_response_create_overload_19(self, async_client: AsyncCloudflare) -> None: response = await async_client.rulesets.rules.with_raw_response.create( ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="account_id", @@ -5629,7 +6392,7 @@ async def test_raw_response_create_overload_17(self, async_client: AsyncCloudfla @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_create_overload_17(self, async_client: AsyncCloudflare) -> None: + async def test_streaming_response_create_overload_19(self, async_client: AsyncCloudflare) -> None: async with async_client.rulesets.rules.with_streaming_response.create( ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="account_id", @@ -5644,7 +6407,7 @@ async def test_streaming_response_create_overload_17(self, async_client: AsyncCl @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_create_overload_17(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_create_overload_19(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): await async_client.rulesets.rules.with_raw_response.create( ruleset_id="", @@ -5665,7 +6428,7 @@ async def test_path_params_create_overload_17(self, async_client: AsyncCloudflar @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_create_overload_18(self, async_client: AsyncCloudflare) -> None: + async def test_method_create_overload_20(self, async_client: AsyncCloudflare) -> None: rule = await async_client.rulesets.rules.create( ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="account_id", @@ -5674,7 +6437,7 @@ async def test_method_create_overload_18(self, async_client: AsyncCloudflare) -> @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_create_with_all_params_overload_18(self, async_client: AsyncCloudflare) -> None: + async def test_method_create_with_all_params_overload_20(self, async_client: AsyncCloudflare) -> None: rule = await async_client.rulesets.rules.create( ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="account_id", @@ -5713,7 +6476,7 @@ async def test_method_create_with_all_params_overload_18(self, async_client: Asy @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_create_overload_18(self, async_client: AsyncCloudflare) -> None: + async def test_raw_response_create_overload_20(self, async_client: AsyncCloudflare) -> None: response = await async_client.rulesets.rules.with_raw_response.create( ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="account_id", @@ -5726,7 +6489,7 @@ async def test_raw_response_create_overload_18(self, async_client: AsyncCloudfla @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_create_overload_18(self, async_client: AsyncCloudflare) -> None: + async def test_streaming_response_create_overload_20(self, async_client: AsyncCloudflare) -> None: async with async_client.rulesets.rules.with_streaming_response.create( ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="account_id", @@ -5741,7 +6504,7 @@ async def test_streaming_response_create_overload_18(self, async_client: AsyncCl @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_create_overload_18(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_create_overload_20(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): await async_client.rulesets.rules.with_raw_response.create( ruleset_id="", @@ -7498,6 +8261,169 @@ async def test_method_edit_overload_16(self, async_client: AsyncCloudflare) -> N @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_method_edit_with_all_params_overload_16(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="set_cache_control", + action_parameters={ + "immutable": { + "operation": "set", + "cloudflare_only": False, + }, + "max_age": { + "operation": "set", + "value": 3600, + "cloudflare_only": False, + }, + "must_revalidate": { + "operation": "set", + "cloudflare_only": False, + }, + "must_understand": { + "operation": "set", + "cloudflare_only": False, + }, + "no_cache": { + "operation": "set", + "cloudflare_only": False, + "qualifiers": ["X-Custom-Header"], + }, + "no_store": { + "operation": "set", + "cloudflare_only": False, + }, + "no_transform": { + "operation": "set", + "cloudflare_only": False, + }, + "private": { + "operation": "set", + "cloudflare_only": False, + "qualifiers": ["X-Custom-Header"], + }, + "proxy_revalidate": { + "operation": "set", + "cloudflare_only": False, + }, + "public": { + "operation": "set", + "cloudflare_only": False, + }, + "s_maxage": { + "operation": "set", + "value": 3600, + "cloudflare_only": False, + }, + "stale_if_error": { + "operation": "set", + "value": 3600, + "cloudflare_only": False, + }, + "stale_while_revalidate": { + "operation": "set", + "value": 3600, + "cloudflare_only": False, + }, + }, + description="Modify the cache-control header directives in an Origin response.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_edit_overload_16(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_edit_overload_16(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_edit_overload_16(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_overload_17(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_with_all_params_overload_17(self, async_client: AsyncCloudflare) -> None: rule = await async_client.rulesets.rules.edit( rule_id="3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", @@ -7567,6 +8493,9 @@ async def test_method_edit_with_all_params_overload_16(self, async_client: Async "read_timeout": 900, "respect_strong_etags": True, "serve_stale": {"disable_stale_while_updating": True}, + "strip_etags": True, + "strip_last_modified": True, + "strip_set_cookie": True, }, description="Configure settings for how the response is cached.", enabled=True, @@ -7593,7 +8522,7 @@ async def test_method_edit_with_all_params_overload_16(self, async_client: Async @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_edit_overload_16(self, async_client: AsyncCloudflare) -> None: + async def test_raw_response_edit_overload_17(self, async_client: AsyncCloudflare) -> None: response = await async_client.rulesets.rules.with_raw_response.edit( rule_id="3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", @@ -7607,7 +8536,7 @@ async def test_raw_response_edit_overload_16(self, async_client: AsyncCloudflare @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_edit_overload_16(self, async_client: AsyncCloudflare) -> None: + async def test_streaming_response_edit_overload_17(self, async_client: AsyncCloudflare) -> None: async with async_client.rulesets.rules.with_streaming_response.edit( rule_id="3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", @@ -7623,7 +8552,7 @@ async def test_streaming_response_edit_overload_16(self, async_client: AsyncClou @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_edit_overload_16(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_edit_overload_17(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): await async_client.rulesets.rules.with_raw_response.edit( rule_id="3a03d665bac047339bb530ecb439a90d", @@ -7654,7 +8583,7 @@ async def test_path_params_edit_overload_16(self, async_client: AsyncCloudflare) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_edit_overload_17(self, async_client: AsyncCloudflare) -> None: + async def test_method_edit_overload_18(self, async_client: AsyncCloudflare) -> None: rule = await async_client.rulesets.rules.edit( rule_id="3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", @@ -7664,7 +8593,114 @@ async def test_method_edit_overload_17(self, async_client: AsyncCloudflare) -> N @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_edit_with_all_params_overload_17(self, async_client: AsyncCloudflare) -> None: + async def test_method_edit_with_all_params_overload_18(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + id="3a03d665bac047339bb530ecb439a90d", + action="set_cache_tags", + action_parameters={ + "operation": "add", + "values": ["my-cache-tag"], + }, + description="Modify the cache tags associated with the response.", + enabled=True, + exposed_credential_check={ + "password_expression": 'url_decode(http.request.body.form[\\"password\\"][0])', + "username_expression": 'url_decode(http.request.body.form[\\"username\\"][0])', + }, + expression="ip.src eq 1.1.1.1", + logging={"enabled": True}, + position={"before": "da5e8e506c8e7877fe06cdf4c41add54"}, + ratelimit={ + "characteristics": ["cf.colo.id"], + "period": 60, + "counting_expression": 'http.request.body.raw eq "abcd"', + "mitigation_timeout": 600, + "requests_per_period": 1000, + "requests_to_origin": True, + "score_per_period": 400, + "score_response_header_name": "my-score", + }, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_raw_response_edit_overload_18(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_streaming_response_edit_overload_18(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_path_params_edit_overload_18(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + ) + + with pytest.raises(ValueError, match=r"You must provide either account_id or zone_id"): + await async_client.rulesets.rules.with_raw_response.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_overload_19(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + rule_id="3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="account_id", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip(reason="TODO: investigate broken test") + @parametrize + async def test_method_edit_with_all_params_overload_19(self, async_client: AsyncCloudflare) -> None: rule = await async_client.rulesets.rules.edit( rule_id="3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", @@ -7723,7 +8759,7 @@ async def test_method_edit_with_all_params_overload_17(self, async_client: Async @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_edit_overload_17(self, async_client: AsyncCloudflare) -> None: + async def test_raw_response_edit_overload_19(self, async_client: AsyncCloudflare) -> None: response = await async_client.rulesets.rules.with_raw_response.edit( rule_id="3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", @@ -7737,7 +8773,7 @@ async def test_raw_response_edit_overload_17(self, async_client: AsyncCloudflare @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_edit_overload_17(self, async_client: AsyncCloudflare) -> None: + async def test_streaming_response_edit_overload_19(self, async_client: AsyncCloudflare) -> None: async with async_client.rulesets.rules.with_streaming_response.edit( rule_id="3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", @@ -7753,7 +8789,7 @@ async def test_streaming_response_edit_overload_17(self, async_client: AsyncClou @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_edit_overload_17(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_edit_overload_19(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): await async_client.rulesets.rules.with_raw_response.edit( rule_id="3a03d665bac047339bb530ecb439a90d", @@ -7784,7 +8820,7 @@ async def test_path_params_edit_overload_17(self, async_client: AsyncCloudflare) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_edit_overload_18(self, async_client: AsyncCloudflare) -> None: + async def test_method_edit_overload_20(self, async_client: AsyncCloudflare) -> None: rule = await async_client.rulesets.rules.edit( rule_id="3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", @@ -7794,7 +8830,7 @@ async def test_method_edit_overload_18(self, async_client: AsyncCloudflare) -> N @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_method_edit_with_all_params_overload_18(self, async_client: AsyncCloudflare) -> None: + async def test_method_edit_with_all_params_overload_20(self, async_client: AsyncCloudflare) -> None: rule = await async_client.rulesets.rules.edit( rule_id="3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", @@ -7834,7 +8870,7 @@ async def test_method_edit_with_all_params_overload_18(self, async_client: Async @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_raw_response_edit_overload_18(self, async_client: AsyncCloudflare) -> None: + async def test_raw_response_edit_overload_20(self, async_client: AsyncCloudflare) -> None: response = await async_client.rulesets.rules.with_raw_response.edit( rule_id="3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", @@ -7848,7 +8884,7 @@ async def test_raw_response_edit_overload_18(self, async_client: AsyncCloudflare @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_streaming_response_edit_overload_18(self, async_client: AsyncCloudflare) -> None: + async def test_streaming_response_edit_overload_20(self, async_client: AsyncCloudflare) -> None: async with async_client.rulesets.rules.with_streaming_response.edit( rule_id="3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", @@ -7864,7 +8900,7 @@ async def test_streaming_response_edit_overload_18(self, async_client: AsyncClou @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize - async def test_path_params_edit_overload_18(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_edit_overload_20(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): await async_client.rulesets.rules.with_raw_response.edit( rule_id="3a03d665bac047339bb530ecb439a90d", diff --git a/tests/api_resources/speed/test_schedule.py b/tests/api_resources/speed/test_schedule.py index 96eab910c45..b229ad71ff1 100644 --- a/tests/api_resources/speed/test_schedule.py +++ b/tests/api_resources/speed/test_schedule.py @@ -34,6 +34,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: schedule = client.speed.schedule.create( url="example.com", zone_id="023e105f4ecef8ad9ca31a8372d0c353", + frequency="DAILY", region="us-central1", ) assert_matches_type(Optional[ScheduleCreateResponse], schedule, path=["response"]) @@ -211,6 +212,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare schedule = await async_client.speed.schedule.create( url="example.com", zone_id="023e105f4ecef8ad9ca31a8372d0c353", + frequency="DAILY", region="us-central1", ) assert_matches_type(Optional[ScheduleCreateResponse], schedule, path=["response"]) diff --git a/tests/api_resources/test_ai_gateway.py b/tests/api_resources/test_ai_gateway.py index d0b981f22c6..56982a727da 100644 --- a/tests/api_resources/test_ai_gateway.py +++ b/tests/api_resources/test_ai_gateway.py @@ -50,11 +50,11 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: rate_limiting_limit=0, rate_limiting_technique="fixed", authentication=True, - is_default=True, log_management=10000, log_management_strategy="STOP_INSERTING", logpush=True, logpush_public_key="xxxxxxxxxxxxxxxx", + workers_ai_billing_mode="postpaid", zdr=True, ) assert_matches_type(AIGatewayCreateResponse, ai_gateway, path=["response"]) @@ -142,7 +142,6 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: "enabled": True, "profiles": ["string"], }, - is_default=True, log_management=10000, log_management_strategy="STOP_INSERTING", logpush=True, @@ -152,6 +151,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: "authorization": "authorization", "headers": {"foo": "string"}, "url": "url", + "content_type": "json", } ], store_id="store_id", @@ -159,6 +159,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: "authorization": "authorization", "usage_events": [{"payload": "payload"}], }, + workers_ai_billing_mode="postpaid", zdr=True, ) assert_matches_type(AIGatewayUpdateResponse, ai_gateway, path=["response"]) @@ -403,11 +404,11 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare rate_limiting_limit=0, rate_limiting_technique="fixed", authentication=True, - is_default=True, log_management=10000, log_management_strategy="STOP_INSERTING", logpush=True, logpush_public_key="xxxxxxxxxxxxxxxx", + workers_ai_billing_mode="postpaid", zdr=True, ) assert_matches_type(AIGatewayCreateResponse, ai_gateway, path=["response"]) @@ -495,7 +496,6 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare "enabled": True, "profiles": ["string"], }, - is_default=True, log_management=10000, log_management_strategy="STOP_INSERTING", logpush=True, @@ -505,6 +505,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare "authorization": "authorization", "headers": {"foo": "string"}, "url": "url", + "content_type": "json", } ], store_id="store_id", @@ -512,6 +513,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare "authorization": "authorization", "usage_events": [{"payload": "payload"}], }, + workers_ai_billing_mode="postpaid", zdr=True, ) assert_matches_type(AIGatewayUpdateResponse, ai_gateway, path=["response"]) diff --git a/tests/api_resources/test_workflows.py b/tests/api_resources/test_workflows.py index bcc84aa9081..50b603500c7 100644 --- a/tests/api_resources/test_workflows.py +++ b/tests/api_resources/test_workflows.py @@ -33,6 +33,17 @@ def test_method_update(self, client: Cloudflare) -> None: ) assert_matches_type(WorkflowUpdateResponse, workflow, path=["response"]) + @parametrize + def test_method_update_with_all_params(self, client: Cloudflare) -> None: + workflow = client.workflows.update( + workflow_name="x", + account_id="account_id", + class_name="x", + script_name="x", + limits={"steps": 1}, + ) + assert_matches_type(WorkflowUpdateResponse, workflow, path=["response"]) + @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: response = client.workflows.with_raw_response.update( @@ -241,6 +252,17 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(WorkflowUpdateResponse, workflow, path=["response"]) + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: + workflow = await async_client.workflows.update( + workflow_name="x", + account_id="account_id", + class_name="x", + script_name="x", + limits={"steps": 1}, + ) + assert_matches_type(WorkflowUpdateResponse, workflow, path=["response"]) + @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: response = await async_client.workflows.with_raw_response.update( diff --git a/tests/api_resources/workflows/test_instances.py b/tests/api_resources/workflows/test_instances.py index f5af61e88cb..9d29e7aa3e7 100644 --- a/tests/api_resources/workflows/test_instances.py +++ b/tests/api_resources/workflows/test_instances.py @@ -224,6 +224,17 @@ def test_method_get(self, client: Cloudflare) -> None: ) assert_matches_type(InstanceGetResponse, instance, path=["response"]) + @parametrize + def test_method_get_with_all_params(self, client: Cloudflare) -> None: + instance = client.workflows.instances.get( + instance_id="x", + account_id="account_id", + workflow_name="x", + order="asc", + simple="true", + ) + assert_matches_type(InstanceGetResponse, instance, path=["response"]) + @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: response = client.workflows.instances.with_raw_response.get( @@ -481,6 +492,17 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(InstanceGetResponse, instance, path=["response"]) + @parametrize + async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: + instance = await async_client.workflows.instances.get( + instance_id="x", + account_id="account_id", + workflow_name="x", + order="asc", + simple="true", + ) + assert_matches_type(InstanceGetResponse, instance, path=["response"]) + @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: response = await async_client.workflows.instances.with_raw_response.get( diff --git a/tests/api_resources/zero_trust/dlp/profiles/test_custom.py b/tests/api_resources/zero_trust/dlp/profiles/test_custom.py index f26540bad38..14f32d2505d 100644 --- a/tests/api_resources/zero_trust/dlp/profiles/test_custom.py +++ b/tests/api_resources/zero_trust/dlp/profiles/test_custom.py @@ -37,6 +37,8 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: "enabled": True, "skip": {"files": True}, }, + data_classes=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"], + data_tags=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"], description="description", entries=[ { @@ -50,6 +52,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: } ], ocr_enabled=True, + sensitivity_levels=[["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"]], shared_entries=[ { "enabled": True, @@ -115,6 +118,8 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: "enabled": True, "skip": {"files": True}, }, + data_classes=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"], + data_tags=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"], description="description", entries=[ { @@ -129,6 +134,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: } ], ocr_enabled=True, + sensitivity_levels=[["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"]], shared_entries=[ { "enabled": True, @@ -304,6 +310,8 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare "enabled": True, "skip": {"files": True}, }, + data_classes=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"], + data_tags=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"], description="description", entries=[ { @@ -317,6 +325,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare } ], ocr_enabled=True, + sensitivity_levels=[["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"]], shared_entries=[ { "enabled": True, @@ -382,6 +391,8 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare "enabled": True, "skip": {"files": True}, }, + data_classes=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"], + data_tags=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"], description="description", entries=[ { @@ -396,6 +407,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare } ], ocr_enabled=True, + sensitivity_levels=[["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"]], shared_entries=[ { "enabled": True, From d0805c4e4aafcd05da0ca2e91393a49544be2cfc Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 5 Mar 2026 21:31:57 +0000 Subject: [PATCH 11/12] chore(api): update composite API spec --- .stats.yml | 4 +- .../zero_trust/organizations/organizations.py | 20 ------ .../access/application_create_params.py | 64 +++++++++---------- .../access/application_create_response.py | 64 +++++++++---------- .../access/application_get_response.py | 64 +++++++++---------- .../access/application_list_response.py | 64 +++++++++---------- .../access/application_update_params.py | 64 +++++++++---------- .../access/application_update_response.py | 64 +++++++++---------- .../access/applications/access_rule.py | 21 +++++- .../access/applications/access_rule_param.py | 21 +++++- .../applications/policy_create_params.py | 4 +- .../applications/policy_create_response.py | 4 +- .../applications/policy_get_response.py | 4 +- .../applications/policy_list_response.py | 4 +- .../applications/policy_test_create_params.py | 4 +- .../applications/policy_update_params.py | 4 +- .../applications/policy_update_response.py | 4 +- .../zero_trust/access/policy_create_params.py | 4 +- .../access/policy_create_response.py | 4 +- .../zero_trust/access/policy_get_response.py | 4 +- .../zero_trust/access/policy_list_response.py | 4 +- .../zero_trust/access/policy_update_params.py | 4 +- .../access/policy_update_response.py | 4 +- .../types/zero_trust/organization.py | 6 -- .../zero_trust/organization_create_params.py | 6 -- .../zero_trust/organization_update_params.py | 6 -- .../access/applications/test_policies.py | 8 +-- .../access/applications/test_policy_tests.py | 4 +- .../zero_trust/access/test_applications.py | 32 +++++----- .../zero_trust/access/test_policies.py | 8 +-- .../zero_trust/test_organizations.py | 4 -- 31 files changed, 284 insertions(+), 292 deletions(-) diff --git a/.stats.yml b/.stats.yml index 10011598aba..33026388f2e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 2049 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ee23c4fe5cfe74e6576003db5f37b8b85cd8aaae1ff7576ccd2e16fa47008934.yml -openapi_spec_hash: 20046482414d30b12cdc7ab777b15e94 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2290f772d9da747604b876da6e05a038187c26179245af12a64d198f25ef3fd0.yml +openapi_spec_hash: f46a7fc30fe001095a2b484fb6ada3e9 config_hash: ebde54bdd7ec58f9abf7de1c45a2c076 diff --git a/src/cloudflare/resources/zero_trust/organizations/organizations.py b/src/cloudflare/resources/zero_trust/organizations/organizations.py index 9a5730fae56..baeb18dbcb7 100644 --- a/src/cloudflare/resources/zero_trust/organizations/organizations.py +++ b/src/cloudflare/resources/zero_trust/organizations/organizations.py @@ -76,7 +76,6 @@ def create( is_ui_read_only: bool | Omit = omit, login_design: LoginDesignParam | Omit = omit, mfa_config: organization_create_params.MfaConfig | Omit = omit, - mfa_configuration_allowed: bool | Omit = omit, mfa_required_for_all_apps: bool | Omit = omit, session_duration: str | Omit = omit, ui_read_only_toggle_reason: str | Omit = omit, @@ -123,9 +122,6 @@ def create( mfa_config: Configures multi-factor authentication (MFA) settings for an organization. - mfa_configuration_allowed: Indicates if this organization can enforce multi-factor authentication (MFA) - requirements at the application and policy level. - mfa_required_for_all_apps: Determines whether global MFA settings apply to applications by default. The organization must have MFA enabled with at least one authentication method and a session duration configured. @@ -178,7 +174,6 @@ def create( "is_ui_read_only": is_ui_read_only, "login_design": login_design, "mfa_config": mfa_config, - "mfa_configuration_allowed": mfa_configuration_allowed, "mfa_required_for_all_apps": mfa_required_for_all_apps, "session_duration": session_duration, "ui_read_only_toggle_reason": ui_read_only_toggle_reason, @@ -211,7 +206,6 @@ def update( is_ui_read_only: bool | Omit = omit, login_design: LoginDesignParam | Omit = omit, mfa_config: organization_update_params.MfaConfig | Omit = omit, - mfa_configuration_allowed: bool | Omit = omit, mfa_required_for_all_apps: bool | Omit = omit, name: str | Omit = omit, session_duration: str | Omit = omit, @@ -257,9 +251,6 @@ def update( mfa_config: Configures multi-factor authentication (MFA) settings for an organization. - mfa_configuration_allowed: Indicates if this organization can enforce multi-factor authentication (MFA) - requirements at the application and policy level. - mfa_required_for_all_apps: Determines whether global MFA settings apply to applications by default. The organization must have MFA enabled with at least one authentication method and a session duration configured. @@ -314,7 +305,6 @@ def update( "is_ui_read_only": is_ui_read_only, "login_design": login_design, "mfa_config": mfa_config, - "mfa_configuration_allowed": mfa_configuration_allowed, "mfa_required_for_all_apps": mfa_required_for_all_apps, "name": name, "session_duration": session_duration, @@ -508,7 +498,6 @@ async def create( is_ui_read_only: bool | Omit = omit, login_design: LoginDesignParam | Omit = omit, mfa_config: organization_create_params.MfaConfig | Omit = omit, - mfa_configuration_allowed: bool | Omit = omit, mfa_required_for_all_apps: bool | Omit = omit, session_duration: str | Omit = omit, ui_read_only_toggle_reason: str | Omit = omit, @@ -555,9 +544,6 @@ async def create( mfa_config: Configures multi-factor authentication (MFA) settings for an organization. - mfa_configuration_allowed: Indicates if this organization can enforce multi-factor authentication (MFA) - requirements at the application and policy level. - mfa_required_for_all_apps: Determines whether global MFA settings apply to applications by default. The organization must have MFA enabled with at least one authentication method and a session duration configured. @@ -610,7 +596,6 @@ async def create( "is_ui_read_only": is_ui_read_only, "login_design": login_design, "mfa_config": mfa_config, - "mfa_configuration_allowed": mfa_configuration_allowed, "mfa_required_for_all_apps": mfa_required_for_all_apps, "session_duration": session_duration, "ui_read_only_toggle_reason": ui_read_only_toggle_reason, @@ -643,7 +628,6 @@ async def update( is_ui_read_only: bool | Omit = omit, login_design: LoginDesignParam | Omit = omit, mfa_config: organization_update_params.MfaConfig | Omit = omit, - mfa_configuration_allowed: bool | Omit = omit, mfa_required_for_all_apps: bool | Omit = omit, name: str | Omit = omit, session_duration: str | Omit = omit, @@ -689,9 +673,6 @@ async def update( mfa_config: Configures multi-factor authentication (MFA) settings for an organization. - mfa_configuration_allowed: Indicates if this organization can enforce multi-factor authentication (MFA) - requirements at the application and policy level. - mfa_required_for_all_apps: Determines whether global MFA settings apply to applications by default. The organization must have MFA enabled with at least one authentication method and a session duration configured. @@ -746,7 +727,6 @@ async def update( "is_ui_read_only": is_ui_read_only, "login_design": login_design, "mfa_config": mfa_config, - "mfa_configuration_allowed": mfa_configuration_allowed, "mfa_required_for_all_apps": mfa_required_for_all_apps, "name": name, "session_duration": session_duration, diff --git a/src/cloudflare/types/zero_trust/access/application_create_params.py b/src/cloudflare/types/zero_trust/access/application_create_params.py index c1c5b442226..a8bca59a618 100644 --- a/src/cloudflare/types/zero_trust/access/application_create_params.py +++ b/src/cloudflare/types/zero_trust/access/application_create_params.py @@ -448,8 +448,8 @@ class SelfHostedApplicationMfaConfig(TypedDict, total=False): allowed_authenticators: List[Literal["totp", "biometrics", "security_key"]] """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: bool - """Indicates whether to bypass MFA for this resource. + mfa_disabled: bool + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -560,8 +560,8 @@ class SelfHostedApplicationPolicyUnionMember2MfaConfig(TypedDict, total=False): allowed_authenticators: List[Literal["totp", "biometrics", "security_key"]] """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: bool - """Indicates whether to bypass MFA for this resource. + mfa_disabled: bool + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -828,8 +828,8 @@ class SaaSApplicationPolicyUnionMember2MfaConfig(TypedDict, total=False): allowed_authenticators: List[Literal["totp", "biometrics", "security_key"]] """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: bool - """Indicates whether to bypass MFA for this resource. + mfa_disabled: bool + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -1262,8 +1262,8 @@ class BrowserSSHApplicationMfaConfig(TypedDict, total=False): allowed_authenticators: List[Literal["totp", "biometrics", "security_key"]] """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: bool - """Indicates whether to bypass MFA for this resource. + mfa_disabled: bool + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -1374,8 +1374,8 @@ class BrowserSSHApplicationPolicyUnionMember2MfaConfig(TypedDict, total=False): allowed_authenticators: List[Literal["totp", "biometrics", "security_key"]] """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: bool - """Indicates whether to bypass MFA for this resource. + mfa_disabled: bool + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -1808,8 +1808,8 @@ class BrowserVNCApplicationMfaConfig(TypedDict, total=False): allowed_authenticators: List[Literal["totp", "biometrics", "security_key"]] """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: bool - """Indicates whether to bypass MFA for this resource. + mfa_disabled: bool + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -1920,8 +1920,8 @@ class BrowserVNCApplicationPolicyUnionMember2MfaConfig(TypedDict, total=False): allowed_authenticators: List[Literal["totp", "biometrics", "security_key"]] """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: bool - """Indicates whether to bypass MFA for this resource. + mfa_disabled: bool + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -2246,8 +2246,8 @@ class AppLauncherApplicationPolicyUnionMember2MfaConfig(TypedDict, total=False): allowed_authenticators: List[Literal["totp", "biometrics", "security_key"]] """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: bool - """Indicates whether to bypass MFA for this resource. + mfa_disabled: bool + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -2410,8 +2410,8 @@ class DeviceEnrollmentPermissionsApplicationPolicyUnionMember2MfaConfig(TypedDic allowed_authenticators: List[Literal["totp", "biometrics", "security_key"]] """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: bool - """Indicates whether to bypass MFA for this resource. + mfa_disabled: bool + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -2576,8 +2576,8 @@ class BrowserIsolationPermissionsApplicationPolicyUnionMember2MfaConfig(TypedDic allowed_authenticators: List[Literal["totp", "biometrics", "security_key"]] """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: bool - """Indicates whether to bypass MFA for this resource. + mfa_disabled: bool + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -2751,8 +2751,8 @@ class GatewayIdentityProxyEndpointApplicationPolicyUnionMember2MfaConfig(TypedDi allowed_authenticators: List[Literal["totp", "biometrics", "security_key"]] """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: bool - """Indicates whether to bypass MFA for this resource. + mfa_disabled: bool + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -2899,8 +2899,8 @@ class BookmarkApplicationPolicyUnionMember2MfaConfig(TypedDict, total=False): allowed_authenticators: List[Literal["totp", "biometrics", "security_key"]] """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: bool - """Indicates whether to bypass MFA for this resource. + mfa_disabled: bool + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -3324,8 +3324,8 @@ class BrowserRDPApplicationMfaConfig(TypedDict, total=False): allowed_authenticators: List[Literal["totp", "biometrics", "security_key"]] """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: bool - """Indicates whether to bypass MFA for this resource. + mfa_disabled: bool + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -3436,8 +3436,8 @@ class BrowserRDPApplicationPolicyUnionMember2MfaConfig(TypedDict, total=False): allowed_authenticators: List[Literal["totp", "biometrics", "security_key"]] """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: bool - """Indicates whether to bypass MFA for this resource. + mfa_disabled: bool + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -3883,8 +3883,8 @@ class McpServerApplicationPolicyUnionMember2MfaConfig(TypedDict, total=False): allowed_authenticators: List[Literal["totp", "biometrics", "security_key"]] """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: bool - """Indicates whether to bypass MFA for this resource. + mfa_disabled: bool + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -4336,8 +4336,8 @@ class McpServerPortalApplicationPolicyUnionMember2MfaConfig(TypedDict, total=Fal allowed_authenticators: List[Literal["totp", "biometrics", "security_key"]] """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: bool - """Indicates whether to bypass MFA for this resource. + mfa_disabled: bool + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ diff --git a/src/cloudflare/types/zero_trust/access/application_create_response.py b/src/cloudflare/types/zero_trust/access/application_create_response.py index 55500554b08..4b7f7e0395c 100644 --- a/src/cloudflare/types/zero_trust/access/application_create_response.py +++ b/src/cloudflare/types/zero_trust/access/application_create_response.py @@ -240,8 +240,8 @@ class SelfHostedApplicationMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -339,8 +339,8 @@ class SelfHostedApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -738,8 +738,8 @@ class SaaSApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -1052,8 +1052,8 @@ class BrowserSSHApplicationMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -1151,8 +1151,8 @@ class BrowserSSHApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -1602,8 +1602,8 @@ class BrowserVNCApplicationMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -1701,8 +1701,8 @@ class BrowserVNCApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -2142,8 +2142,8 @@ class AppLauncherApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -2356,8 +2356,8 @@ class DeviceEnrollmentPermissionsApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -2537,8 +2537,8 @@ class BrowserIsolationPermissionsApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -2718,8 +2718,8 @@ class GatewayIdentityProxyEndpointApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -2899,8 +2899,8 @@ class BookmarkApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -3202,8 +3202,8 @@ class BrowserRDPApplicationMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -3301,8 +3301,8 @@ class BrowserRDPApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -3818,8 +3818,8 @@ class McpServerApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -4271,8 +4271,8 @@ class McpServerPortalApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ diff --git a/src/cloudflare/types/zero_trust/access/application_get_response.py b/src/cloudflare/types/zero_trust/access/application_get_response.py index 18fe3f2a3d6..c9d356a54de 100644 --- a/src/cloudflare/types/zero_trust/access/application_get_response.py +++ b/src/cloudflare/types/zero_trust/access/application_get_response.py @@ -240,8 +240,8 @@ class SelfHostedApplicationMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -339,8 +339,8 @@ class SelfHostedApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -738,8 +738,8 @@ class SaaSApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -1052,8 +1052,8 @@ class BrowserSSHApplicationMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -1151,8 +1151,8 @@ class BrowserSSHApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -1602,8 +1602,8 @@ class BrowserVNCApplicationMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -1701,8 +1701,8 @@ class BrowserVNCApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -2142,8 +2142,8 @@ class AppLauncherApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -2356,8 +2356,8 @@ class DeviceEnrollmentPermissionsApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -2537,8 +2537,8 @@ class BrowserIsolationPermissionsApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -2718,8 +2718,8 @@ class GatewayIdentityProxyEndpointApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -2899,8 +2899,8 @@ class BookmarkApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -3202,8 +3202,8 @@ class BrowserRDPApplicationMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -3301,8 +3301,8 @@ class BrowserRDPApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -3818,8 +3818,8 @@ class McpServerApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -4271,8 +4271,8 @@ class McpServerPortalApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ diff --git a/src/cloudflare/types/zero_trust/access/application_list_response.py b/src/cloudflare/types/zero_trust/access/application_list_response.py index 4b779844b2b..1ff25475ba2 100644 --- a/src/cloudflare/types/zero_trust/access/application_list_response.py +++ b/src/cloudflare/types/zero_trust/access/application_list_response.py @@ -240,8 +240,8 @@ class SelfHostedApplicationMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -339,8 +339,8 @@ class SelfHostedApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -738,8 +738,8 @@ class SaaSApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -1052,8 +1052,8 @@ class BrowserSSHApplicationMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -1151,8 +1151,8 @@ class BrowserSSHApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -1602,8 +1602,8 @@ class BrowserVNCApplicationMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -1701,8 +1701,8 @@ class BrowserVNCApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -2142,8 +2142,8 @@ class AppLauncherApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -2356,8 +2356,8 @@ class DeviceEnrollmentPermissionsApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -2537,8 +2537,8 @@ class BrowserIsolationPermissionsApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -2718,8 +2718,8 @@ class GatewayIdentityProxyEndpointApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -2899,8 +2899,8 @@ class BookmarkApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -3202,8 +3202,8 @@ class BrowserRDPApplicationMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -3301,8 +3301,8 @@ class BrowserRDPApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -3818,8 +3818,8 @@ class McpServerApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -4271,8 +4271,8 @@ class McpServerPortalApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ diff --git a/src/cloudflare/types/zero_trust/access/application_update_params.py b/src/cloudflare/types/zero_trust/access/application_update_params.py index 03c6de94cb4..c812ed225d1 100644 --- a/src/cloudflare/types/zero_trust/access/application_update_params.py +++ b/src/cloudflare/types/zero_trust/access/application_update_params.py @@ -448,8 +448,8 @@ class SelfHostedApplicationMfaConfig(TypedDict, total=False): allowed_authenticators: List[Literal["totp", "biometrics", "security_key"]] """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: bool - """Indicates whether to bypass MFA for this resource. + mfa_disabled: bool + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -560,8 +560,8 @@ class SelfHostedApplicationPolicyUnionMember2MfaConfig(TypedDict, total=False): allowed_authenticators: List[Literal["totp", "biometrics", "security_key"]] """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: bool - """Indicates whether to bypass MFA for this resource. + mfa_disabled: bool + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -828,8 +828,8 @@ class SaaSApplicationPolicyUnionMember2MfaConfig(TypedDict, total=False): allowed_authenticators: List[Literal["totp", "biometrics", "security_key"]] """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: bool - """Indicates whether to bypass MFA for this resource. + mfa_disabled: bool + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -1262,8 +1262,8 @@ class BrowserSSHApplicationMfaConfig(TypedDict, total=False): allowed_authenticators: List[Literal["totp", "biometrics", "security_key"]] """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: bool - """Indicates whether to bypass MFA for this resource. + mfa_disabled: bool + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -1374,8 +1374,8 @@ class BrowserSSHApplicationPolicyUnionMember2MfaConfig(TypedDict, total=False): allowed_authenticators: List[Literal["totp", "biometrics", "security_key"]] """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: bool - """Indicates whether to bypass MFA for this resource. + mfa_disabled: bool + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -1808,8 +1808,8 @@ class BrowserVNCApplicationMfaConfig(TypedDict, total=False): allowed_authenticators: List[Literal["totp", "biometrics", "security_key"]] """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: bool - """Indicates whether to bypass MFA for this resource. + mfa_disabled: bool + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -1920,8 +1920,8 @@ class BrowserVNCApplicationPolicyUnionMember2MfaConfig(TypedDict, total=False): allowed_authenticators: List[Literal["totp", "biometrics", "security_key"]] """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: bool - """Indicates whether to bypass MFA for this resource. + mfa_disabled: bool + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -2246,8 +2246,8 @@ class AppLauncherApplicationPolicyUnionMember2MfaConfig(TypedDict, total=False): allowed_authenticators: List[Literal["totp", "biometrics", "security_key"]] """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: bool - """Indicates whether to bypass MFA for this resource. + mfa_disabled: bool + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -2410,8 +2410,8 @@ class DeviceEnrollmentPermissionsApplicationPolicyUnionMember2MfaConfig(TypedDic allowed_authenticators: List[Literal["totp", "biometrics", "security_key"]] """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: bool - """Indicates whether to bypass MFA for this resource. + mfa_disabled: bool + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -2576,8 +2576,8 @@ class BrowserIsolationPermissionsApplicationPolicyUnionMember2MfaConfig(TypedDic allowed_authenticators: List[Literal["totp", "biometrics", "security_key"]] """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: bool - """Indicates whether to bypass MFA for this resource. + mfa_disabled: bool + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -2751,8 +2751,8 @@ class GatewayIdentityProxyEndpointApplicationPolicyUnionMember2MfaConfig(TypedDi allowed_authenticators: List[Literal["totp", "biometrics", "security_key"]] """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: bool - """Indicates whether to bypass MFA for this resource. + mfa_disabled: bool + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -2899,8 +2899,8 @@ class BookmarkApplicationPolicyUnionMember2MfaConfig(TypedDict, total=False): allowed_authenticators: List[Literal["totp", "biometrics", "security_key"]] """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: bool - """Indicates whether to bypass MFA for this resource. + mfa_disabled: bool + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -3324,8 +3324,8 @@ class BrowserRDPApplicationMfaConfig(TypedDict, total=False): allowed_authenticators: List[Literal["totp", "biometrics", "security_key"]] """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: bool - """Indicates whether to bypass MFA for this resource. + mfa_disabled: bool + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -3436,8 +3436,8 @@ class BrowserRDPApplicationPolicyUnionMember2MfaConfig(TypedDict, total=False): allowed_authenticators: List[Literal["totp", "biometrics", "security_key"]] """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: bool - """Indicates whether to bypass MFA for this resource. + mfa_disabled: bool + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -3883,8 +3883,8 @@ class McpServerApplicationPolicyUnionMember2MfaConfig(TypedDict, total=False): allowed_authenticators: List[Literal["totp", "biometrics", "security_key"]] """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: bool - """Indicates whether to bypass MFA for this resource. + mfa_disabled: bool + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -4336,8 +4336,8 @@ class McpServerPortalApplicationPolicyUnionMember2MfaConfig(TypedDict, total=Fal allowed_authenticators: List[Literal["totp", "biometrics", "security_key"]] """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: bool - """Indicates whether to bypass MFA for this resource. + mfa_disabled: bool + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ diff --git a/src/cloudflare/types/zero_trust/access/application_update_response.py b/src/cloudflare/types/zero_trust/access/application_update_response.py index fb3ebf8f7bf..d29527de7be 100644 --- a/src/cloudflare/types/zero_trust/access/application_update_response.py +++ b/src/cloudflare/types/zero_trust/access/application_update_response.py @@ -240,8 +240,8 @@ class SelfHostedApplicationMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -339,8 +339,8 @@ class SelfHostedApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -738,8 +738,8 @@ class SaaSApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -1052,8 +1052,8 @@ class BrowserSSHApplicationMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -1151,8 +1151,8 @@ class BrowserSSHApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -1602,8 +1602,8 @@ class BrowserVNCApplicationMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -1701,8 +1701,8 @@ class BrowserVNCApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -2142,8 +2142,8 @@ class AppLauncherApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -2356,8 +2356,8 @@ class DeviceEnrollmentPermissionsApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -2537,8 +2537,8 @@ class BrowserIsolationPermissionsApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -2718,8 +2718,8 @@ class GatewayIdentityProxyEndpointApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -2899,8 +2899,8 @@ class BookmarkApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -3202,8 +3202,8 @@ class BrowserRDPApplicationMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -3301,8 +3301,8 @@ class BrowserRDPApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -3818,8 +3818,8 @@ class McpServerApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ @@ -4271,8 +4271,8 @@ class McpServerPortalApplicationPolicyMfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ diff --git a/src/cloudflare/types/zero_trust/access/applications/access_rule.py b/src/cloudflare/types/zero_trust/access/applications/access_rule.py index 67f2997529e..c9ea53edc3f 100644 --- a/src/cloudflare/types/zero_trust/access/applications/access_rule.py +++ b/src/cloudflare/types/zero_trust/access/applications/access_rule.py @@ -1,7 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Union -from typing_extensions import TypeAlias +from typing import List, Union +from typing_extensions import Literal, TypeAlias from .ip_rule import IPRule from .email_rule import EmailRule @@ -36,6 +36,8 @@ "AccessOIDCClaimRuleOIDC", "AccessLinkedAppTokenRule", "AccessLinkedAppTokenRuleLinkedAppToken", + "AccessUserRiskScoreRule", + "AccessUserRiskScoreRuleUserRiskScore", ] @@ -114,6 +116,20 @@ class AccessLinkedAppTokenRule(BaseModel): linked_app_token: AccessLinkedAppTokenRuleLinkedAppToken +class AccessUserRiskScoreRuleUserRiskScore(BaseModel): + user_risk_score: List[Literal["low", "medium", "high", "unscored"]] + """A list of risk score levels to match. + + Values can be low, medium, high, or unscored. + """ + + +class AccessUserRiskScoreRule(BaseModel): + """Matches a user's risk score.""" + + user_risk_score: AccessUserRiskScoreRuleUserRiskScore + + AccessRule: TypeAlias = Union[ GroupRule, AnyValidServiceTokenRule, @@ -139,4 +155,5 @@ class AccessLinkedAppTokenRule(BaseModel): AccessOIDCClaimRule, ServiceTokenRule, AccessLinkedAppTokenRule, + AccessUserRiskScoreRule, ] diff --git a/src/cloudflare/types/zero_trust/access/applications/access_rule_param.py b/src/cloudflare/types/zero_trust/access/applications/access_rule_param.py index ce3a266fe9f..65d2137c1aa 100644 --- a/src/cloudflare/types/zero_trust/access/applications/access_rule_param.py +++ b/src/cloudflare/types/zero_trust/access/applications/access_rule_param.py @@ -2,8 +2,8 @@ from __future__ import annotations -from typing import Union -from typing_extensions import Required, TypeAlias, TypedDict +from typing import List, Union +from typing_extensions import Literal, Required, TypeAlias, TypedDict from .ip_rule_param import IPRuleParam from .email_rule_param import EmailRuleParam @@ -37,6 +37,8 @@ "AccessOIDCClaimRuleOIDC", "AccessLinkedAppTokenRule", "AccessLinkedAppTokenRuleLinkedAppToken", + "AccessUserRiskScoreRule", + "AccessUserRiskScoreRuleUserRiskScore", ] @@ -115,6 +117,20 @@ class AccessLinkedAppTokenRule(TypedDict, total=False): linked_app_token: Required[AccessLinkedAppTokenRuleLinkedAppToken] +class AccessUserRiskScoreRuleUserRiskScore(TypedDict, total=False): + user_risk_score: Required[List[Literal["low", "medium", "high", "unscored"]]] + """A list of risk score levels to match. + + Values can be low, medium, high, or unscored. + """ + + +class AccessUserRiskScoreRule(TypedDict, total=False): + """Matches a user's risk score.""" + + user_risk_score: Required[AccessUserRiskScoreRuleUserRiskScore] + + AccessRuleParam: TypeAlias = Union[ GroupRuleParam, AnyValidServiceTokenRuleParam, @@ -140,4 +156,5 @@ class AccessLinkedAppTokenRule(TypedDict, total=False): AccessOIDCClaimRule, ServiceTokenRuleParam, AccessLinkedAppTokenRule, + AccessUserRiskScoreRule, ] diff --git a/src/cloudflare/types/zero_trust/access/applications/policy_create_params.py b/src/cloudflare/types/zero_trust/access/applications/policy_create_params.py index 9dd797afa07..6477b49cf17 100644 --- a/src/cloudflare/types/zero_trust/access/applications/policy_create_params.py +++ b/src/cloudflare/types/zero_trust/access/applications/policy_create_params.py @@ -91,8 +91,8 @@ class MfaConfig(TypedDict, total=False): allowed_authenticators: List[Literal["totp", "biometrics", "security_key"]] """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: bool - """Indicates whether to bypass MFA for this resource. + mfa_disabled: bool + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ diff --git a/src/cloudflare/types/zero_trust/access/applications/policy_create_response.py b/src/cloudflare/types/zero_trust/access/applications/policy_create_response.py index 05d87c5ee24..cdf59ce5d0d 100644 --- a/src/cloudflare/types/zero_trust/access/applications/policy_create_response.py +++ b/src/cloudflare/types/zero_trust/access/applications/policy_create_response.py @@ -41,8 +41,8 @@ class MfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ diff --git a/src/cloudflare/types/zero_trust/access/applications/policy_get_response.py b/src/cloudflare/types/zero_trust/access/applications/policy_get_response.py index 4bc53c6fe31..d7538baf291 100644 --- a/src/cloudflare/types/zero_trust/access/applications/policy_get_response.py +++ b/src/cloudflare/types/zero_trust/access/applications/policy_get_response.py @@ -41,8 +41,8 @@ class MfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ diff --git a/src/cloudflare/types/zero_trust/access/applications/policy_list_response.py b/src/cloudflare/types/zero_trust/access/applications/policy_list_response.py index 2ab9487d994..57b971525ba 100644 --- a/src/cloudflare/types/zero_trust/access/applications/policy_list_response.py +++ b/src/cloudflare/types/zero_trust/access/applications/policy_list_response.py @@ -41,8 +41,8 @@ class MfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ diff --git a/src/cloudflare/types/zero_trust/access/applications/policy_test_create_params.py b/src/cloudflare/types/zero_trust/access/applications/policy_test_create_params.py index 26bb9d12cda..6be89506f1f 100755 --- a/src/cloudflare/types/zero_trust/access/applications/policy_test_create_params.py +++ b/src/cloudflare/types/zero_trust/access/applications/policy_test_create_params.py @@ -56,8 +56,8 @@ class PolicyUnionMember0MfaConfig(TypedDict, total=False): allowed_authenticators: List[Literal["totp", "biometrics", "security_key"]] """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: bool - """Indicates whether to bypass MFA for this resource. + mfa_disabled: bool + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ diff --git a/src/cloudflare/types/zero_trust/access/applications/policy_update_params.py b/src/cloudflare/types/zero_trust/access/applications/policy_update_params.py index c659d26c501..329852be992 100644 --- a/src/cloudflare/types/zero_trust/access/applications/policy_update_params.py +++ b/src/cloudflare/types/zero_trust/access/applications/policy_update_params.py @@ -94,8 +94,8 @@ class MfaConfig(TypedDict, total=False): allowed_authenticators: List[Literal["totp", "biometrics", "security_key"]] """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: bool - """Indicates whether to bypass MFA for this resource. + mfa_disabled: bool + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ diff --git a/src/cloudflare/types/zero_trust/access/applications/policy_update_response.py b/src/cloudflare/types/zero_trust/access/applications/policy_update_response.py index 00c9ac9a19a..05cddf19586 100644 --- a/src/cloudflare/types/zero_trust/access/applications/policy_update_response.py +++ b/src/cloudflare/types/zero_trust/access/applications/policy_update_response.py @@ -41,8 +41,8 @@ class MfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ diff --git a/src/cloudflare/types/zero_trust/access/policy_create_params.py b/src/cloudflare/types/zero_trust/access/policy_create_params.py index a9c3015f40a..880b61d6c48 100644 --- a/src/cloudflare/types/zero_trust/access/policy_create_params.py +++ b/src/cloudflare/types/zero_trust/access/policy_create_params.py @@ -111,8 +111,8 @@ class MfaConfig(TypedDict, total=False): allowed_authenticators: List[Literal["totp", "biometrics", "security_key"]] """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: bool - """Indicates whether to bypass MFA for this resource. + mfa_disabled: bool + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ diff --git a/src/cloudflare/types/zero_trust/access/policy_create_response.py b/src/cloudflare/types/zero_trust/access/policy_create_response.py index aec26906ba5..49c180e3f85 100644 --- a/src/cloudflare/types/zero_trust/access/policy_create_response.py +++ b/src/cloudflare/types/zero_trust/access/policy_create_response.py @@ -41,8 +41,8 @@ class MfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ diff --git a/src/cloudflare/types/zero_trust/access/policy_get_response.py b/src/cloudflare/types/zero_trust/access/policy_get_response.py index 966a199fbe6..5cad1569744 100644 --- a/src/cloudflare/types/zero_trust/access/policy_get_response.py +++ b/src/cloudflare/types/zero_trust/access/policy_get_response.py @@ -41,8 +41,8 @@ class MfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ diff --git a/src/cloudflare/types/zero_trust/access/policy_list_response.py b/src/cloudflare/types/zero_trust/access/policy_list_response.py index 39477e671db..d765cdd4eba 100644 --- a/src/cloudflare/types/zero_trust/access/policy_list_response.py +++ b/src/cloudflare/types/zero_trust/access/policy_list_response.py @@ -41,8 +41,8 @@ class MfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ diff --git a/src/cloudflare/types/zero_trust/access/policy_update_params.py b/src/cloudflare/types/zero_trust/access/policy_update_params.py index 6ac7aea58d4..57c3cd9cd3a 100644 --- a/src/cloudflare/types/zero_trust/access/policy_update_params.py +++ b/src/cloudflare/types/zero_trust/access/policy_update_params.py @@ -111,8 +111,8 @@ class MfaConfig(TypedDict, total=False): allowed_authenticators: List[Literal["totp", "biometrics", "security_key"]] """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: bool - """Indicates whether to bypass MFA for this resource. + mfa_disabled: bool + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ diff --git a/src/cloudflare/types/zero_trust/access/policy_update_response.py b/src/cloudflare/types/zero_trust/access/policy_update_response.py index 9da2c852379..ca249923729 100644 --- a/src/cloudflare/types/zero_trust/access/policy_update_response.py +++ b/src/cloudflare/types/zero_trust/access/policy_update_response.py @@ -41,8 +41,8 @@ class MfaConfig(BaseModel): allowed_authenticators: Optional[List[Literal["totp", "biometrics", "security_key"]]] = None """Lists the MFA methods that users can authenticate with.""" - mfa_bypass: Optional[bool] = None - """Indicates whether to bypass MFA for this resource. + mfa_disabled: Optional[bool] = None + """Indicates whether to disable MFA for this resource. This option is available at the application and policy level. """ diff --git a/src/cloudflare/types/zero_trust/organization.py b/src/cloudflare/types/zero_trust/organization.py index 7eb81796fec..e7ecc57d573 100644 --- a/src/cloudflare/types/zero_trust/organization.py +++ b/src/cloudflare/types/zero_trust/organization.py @@ -80,12 +80,6 @@ class Organization(BaseModel): mfa_config: Optional[MfaConfig] = None """Configures multi-factor authentication (MFA) settings for an organization.""" - mfa_configuration_allowed: Optional[bool] = None - """ - Indicates if this organization can enforce multi-factor authentication (MFA) - requirements at the application and policy level. - """ - mfa_required_for_all_apps: Optional[bool] = None """Determines whether global MFA settings apply to applications by default. diff --git a/src/cloudflare/types/zero_trust/organization_create_params.py b/src/cloudflare/types/zero_trust/organization_create_params.py index e01bbfb4c42..e64aacb705f 100644 --- a/src/cloudflare/types/zero_trust/organization_create_params.py +++ b/src/cloudflare/types/zero_trust/organization_create_params.py @@ -64,12 +64,6 @@ class OrganizationCreateParams(TypedDict, total=False): mfa_config: MfaConfig """Configures multi-factor authentication (MFA) settings for an organization.""" - mfa_configuration_allowed: bool - """ - Indicates if this organization can enforce multi-factor authentication (MFA) - requirements at the application and policy level. - """ - mfa_required_for_all_apps: bool """Determines whether global MFA settings apply to applications by default. diff --git a/src/cloudflare/types/zero_trust/organization_update_params.py b/src/cloudflare/types/zero_trust/organization_update_params.py index 6654c9d2882..e568ad6832a 100644 --- a/src/cloudflare/types/zero_trust/organization_update_params.py +++ b/src/cloudflare/types/zero_trust/organization_update_params.py @@ -63,12 +63,6 @@ class OrganizationUpdateParams(TypedDict, total=False): mfa_config: MfaConfig """Configures multi-factor authentication (MFA) settings for an organization.""" - mfa_configuration_allowed: bool - """ - Indicates if this organization can enforce multi-factor authentication (MFA) - requirements at the application and policy level. - """ - mfa_required_for_all_apps: bool """Determines whether global MFA settings apply to applications by default. diff --git a/tests/api_resources/zero_trust/access/applications/test_policies.py b/tests/api_resources/zero_trust/access/applications/test_policies.py index 52266e52dda..79329c5028a 100644 --- a/tests/api_resources/zero_trust/access/applications/test_policies.py +++ b/tests/api_resources/zero_trust/access/applications/test_policies.py @@ -61,7 +61,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: isolation_required=False, mfa_config={ "allowed_authenticators": ["totp", "biometrics", "security_key"], - "mfa_bypass": False, + "mfa_disabled": False, "session_duration": "24h", }, precedence=0, @@ -159,7 +159,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: isolation_required=False, mfa_config={ "allowed_authenticators": ["totp", "biometrics", "security_key"], - "mfa_bypass": False, + "mfa_disabled": False, "session_duration": "24h", }, precedence=0, @@ -504,7 +504,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare isolation_required=False, mfa_config={ "allowed_authenticators": ["totp", "biometrics", "security_key"], - "mfa_bypass": False, + "mfa_disabled": False, "session_duration": "24h", }, precedence=0, @@ -602,7 +602,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare isolation_required=False, mfa_config={ "allowed_authenticators": ["totp", "biometrics", "security_key"], - "mfa_bypass": False, + "mfa_disabled": False, "session_duration": "24h", }, precedence=0, diff --git a/tests/api_resources/zero_trust/access/applications/test_policy_tests.py b/tests/api_resources/zero_trust/access/applications/test_policy_tests.py index 5cd0138cda0..e987c50a3c1 100755 --- a/tests/api_resources/zero_trust/access/applications/test_policy_tests.py +++ b/tests/api_resources/zero_trust/access/applications/test_policy_tests.py @@ -59,7 +59,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: "isolation_required": False, "mfa_config": { "allowed_authenticators": ["totp", "biometrics", "security_key"], - "mfa_bypass": False, + "mfa_disabled": False, "session_duration": "24h", }, "purpose_justification_prompt": "Please enter a justification for entering this protected domain.", @@ -195,7 +195,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare "isolation_required": False, "mfa_config": { "allowed_authenticators": ["totp", "biometrics", "security_key"], - "mfa_bypass": False, + "mfa_disabled": False, "session_duration": "24h", }, "purpose_justification_prompt": "Please enter a justification for entering this protected domain.", diff --git a/tests/api_resources/zero_trust/access/test_applications.py b/tests/api_resources/zero_trust/access/test_applications.py index 89e7f8a31ce..ba7c58edd8a 100644 --- a/tests/api_resources/zero_trust/access/test_applications.py +++ b/tests/api_resources/zero_trust/access/test_applications.py @@ -103,7 +103,7 @@ def test_method_create_with_all_params_overload_1(self, client: Cloudflare) -> N logo_url="https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg", mfa_config={ "allowed_authenticators": ["totp", "biometrics", "security_key"], - "mfa_bypass": False, + "mfa_disabled": False, "session_duration": "24h", }, name="Admin Site", @@ -413,7 +413,7 @@ def test_method_create_with_all_params_overload_3(self, client: Cloudflare) -> N logo_url="https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg", mfa_config={ "allowed_authenticators": ["totp", "biometrics", "security_key"], - "mfa_bypass": False, + "mfa_disabled": False, "session_duration": "24h", }, name="Admin Site", @@ -600,7 +600,7 @@ def test_method_create_with_all_params_overload_4(self, client: Cloudflare) -> N logo_url="https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg", mfa_config={ "allowed_authenticators": ["totp", "biometrics", "security_key"], - "mfa_bypass": False, + "mfa_disabled": False, "session_duration": "24h", }, name="Admin Site", @@ -1298,7 +1298,7 @@ def test_method_create_with_all_params_overload_11(self, client: Cloudflare) -> logo_url="https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg", mfa_config={ "allowed_authenticators": ["totp", "biometrics", "security_key"], - "mfa_bypass": False, + "mfa_disabled": False, "session_duration": "24h", }, name="Admin Site", @@ -1830,7 +1830,7 @@ def test_method_update_with_all_params_overload_1(self, client: Cloudflare) -> N logo_url="https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg", mfa_config={ "allowed_authenticators": ["totp", "biometrics", "security_key"], - "mfa_bypass": False, + "mfa_disabled": False, "session_duration": "24h", }, name="Admin Site", @@ -2166,7 +2166,7 @@ def test_method_update_with_all_params_overload_3(self, client: Cloudflare) -> N logo_url="https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg", mfa_config={ "allowed_authenticators": ["totp", "biometrics", "security_key"], - "mfa_bypass": False, + "mfa_disabled": False, "session_duration": "24h", }, name="Admin Site", @@ -2367,7 +2367,7 @@ def test_method_update_with_all_params_overload_4(self, client: Cloudflare) -> N logo_url="https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg", mfa_config={ "allowed_authenticators": ["totp", "biometrics", "security_key"], - "mfa_bypass": False, + "mfa_disabled": False, "session_duration": "24h", }, name="Admin Site", @@ -3163,7 +3163,7 @@ def test_method_update_with_all_params_overload_11(self, client: Cloudflare) -> logo_url="https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg", mfa_config={ "allowed_authenticators": ["totp", "biometrics", "security_key"], - "mfa_bypass": False, + "mfa_disabled": False, "session_duration": "24h", }, name="Admin Site", @@ -4008,7 +4008,7 @@ async def test_method_create_with_all_params_overload_1(self, async_client: Asyn logo_url="https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg", mfa_config={ "allowed_authenticators": ["totp", "biometrics", "security_key"], - "mfa_bypass": False, + "mfa_disabled": False, "session_duration": "24h", }, name="Admin Site", @@ -4318,7 +4318,7 @@ async def test_method_create_with_all_params_overload_3(self, async_client: Asyn logo_url="https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg", mfa_config={ "allowed_authenticators": ["totp", "biometrics", "security_key"], - "mfa_bypass": False, + "mfa_disabled": False, "session_duration": "24h", }, name="Admin Site", @@ -4505,7 +4505,7 @@ async def test_method_create_with_all_params_overload_4(self, async_client: Asyn logo_url="https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg", mfa_config={ "allowed_authenticators": ["totp", "biometrics", "security_key"], - "mfa_bypass": False, + "mfa_disabled": False, "session_duration": "24h", }, name="Admin Site", @@ -5203,7 +5203,7 @@ async def test_method_create_with_all_params_overload_11(self, async_client: Asy logo_url="https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg", mfa_config={ "allowed_authenticators": ["totp", "biometrics", "security_key"], - "mfa_bypass": False, + "mfa_disabled": False, "session_duration": "24h", }, name="Admin Site", @@ -5735,7 +5735,7 @@ async def test_method_update_with_all_params_overload_1(self, async_client: Asyn logo_url="https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg", mfa_config={ "allowed_authenticators": ["totp", "biometrics", "security_key"], - "mfa_bypass": False, + "mfa_disabled": False, "session_duration": "24h", }, name="Admin Site", @@ -6071,7 +6071,7 @@ async def test_method_update_with_all_params_overload_3(self, async_client: Asyn logo_url="https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg", mfa_config={ "allowed_authenticators": ["totp", "biometrics", "security_key"], - "mfa_bypass": False, + "mfa_disabled": False, "session_duration": "24h", }, name="Admin Site", @@ -6272,7 +6272,7 @@ async def test_method_update_with_all_params_overload_4(self, async_client: Asyn logo_url="https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg", mfa_config={ "allowed_authenticators": ["totp", "biometrics", "security_key"], - "mfa_bypass": False, + "mfa_disabled": False, "session_duration": "24h", }, name="Admin Site", @@ -7068,7 +7068,7 @@ async def test_method_update_with_all_params_overload_11(self, async_client: Asy logo_url="https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg", mfa_config={ "allowed_authenticators": ["totp", "biometrics", "security_key"], - "mfa_bypass": False, + "mfa_disabled": False, "session_duration": "24h", }, name="Admin Site", diff --git a/tests/api_resources/zero_trust/access/test_policies.py b/tests/api_resources/zero_trust/access/test_policies.py index 5f4a60a6752..7986e7f7922 100644 --- a/tests/api_resources/zero_trust/access/test_policies.py +++ b/tests/api_resources/zero_trust/access/test_policies.py @@ -64,7 +64,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: isolation_required=False, mfa_config={ "allowed_authenticators": ["totp", "biometrics", "security_key"], - "mfa_bypass": False, + "mfa_disabled": False, "session_duration": "24h", }, purpose_justification_prompt="Please enter a justification for entering this protected domain.", @@ -156,7 +156,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: isolation_required=False, mfa_config={ "allowed_authenticators": ["totp", "biometrics", "security_key"], - "mfa_bypass": False, + "mfa_disabled": False, "session_duration": "24h", }, purpose_justification_prompt="Please enter a justification for entering this protected domain.", @@ -407,7 +407,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare isolation_required=False, mfa_config={ "allowed_authenticators": ["totp", "biometrics", "security_key"], - "mfa_bypass": False, + "mfa_disabled": False, "session_duration": "24h", }, purpose_justification_prompt="Please enter a justification for entering this protected domain.", @@ -499,7 +499,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare isolation_required=False, mfa_config={ "allowed_authenticators": ["totp", "biometrics", "security_key"], - "mfa_bypass": False, + "mfa_disabled": False, "session_duration": "24h", }, purpose_justification_prompt="Please enter a justification for entering this protected domain.", diff --git a/tests/api_resources/zero_trust/test_organizations.py b/tests/api_resources/zero_trust/test_organizations.py index b8030ef3754..ddeaada72d5 100644 --- a/tests/api_resources/zero_trust/test_organizations.py +++ b/tests/api_resources/zero_trust/test_organizations.py @@ -53,7 +53,6 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: "allowed_authenticators": ["totp", "biometrics", "security_key"], "session_duration": "24h", }, - mfa_configuration_allowed=True, mfa_required_for_all_apps=False, session_duration="24h", ui_read_only_toggle_reason="Temporarily turn off the UI read only lock to make a change via the UI", @@ -143,7 +142,6 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: "allowed_authenticators": ["totp", "biometrics", "security_key"], "session_duration": "24h", }, - mfa_configuration_allowed=True, mfa_required_for_all_apps=False, name="Widget Corps Internal Applications", session_duration="24h", @@ -351,7 +349,6 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare "allowed_authenticators": ["totp", "biometrics", "security_key"], "session_duration": "24h", }, - mfa_configuration_allowed=True, mfa_required_for_all_apps=False, session_duration="24h", ui_read_only_toggle_reason="Temporarily turn off the UI read only lock to make a change via the UI", @@ -441,7 +438,6 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare "allowed_authenticators": ["totp", "biometrics", "security_key"], "session_duration": "24h", }, - mfa_configuration_allowed=True, mfa_required_for_all_apps=False, name="Widget Corps Internal Applications", session_duration="24h", From e6917d2724f84bfac4693c6625d11ee0f5361f03 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 5 Mar 2026 22:30:35 +0000 Subject: [PATCH 12/12] feat: feat(tags): GRM-385 add resource_tagging routes * build: bump CI image * feat(tags): GRM-385 add resource_tagging routes --- .stats.yml | 6 +- api.md | 64 ++ src/cloudflare/_client.py | 38 + .../resources/resource_tagging/__init__.py | 75 ++ .../resource_tagging/account_tags.py | 792 ++++++++++++++++++ .../resources/resource_tagging/keys.py | 186 ++++ .../resource_tagging/resource_tagging.py | 443 ++++++++++ .../resources/resource_tagging/values.py | 272 ++++++ .../resources/resource_tagging/zone_tags.py | 670 +++++++++++++++ .../types/resource_tagging/__init__.py | 18 + .../account_tag_get_params.py | 44 + .../account_tag_get_response.py | 747 +++++++++++++++++ .../account_tag_update_params.py | 105 +++ .../account_tag_update_response.py | 747 +++++++++++++++++ .../types/resource_tagging/key_list_params.py | 15 + .../resource_tagging/key_list_response.py | 7 + .../resource_tagging_list_params.py | 77 ++ .../resource_tagging_list_response.py | 747 +++++++++++++++++ .../resource_tagging/value_list_params.py | 46 + .../resource_tagging/value_list_response.py | 7 + .../resource_tagging/zone_tag_get_params.py | 34 + .../resource_tagging/zone_tag_get_response.py | 747 +++++++++++++++++ .../zone_tag_update_params.py | 73 ++ .../zone_tag_update_response.py | 747 +++++++++++++++++ .../resource_tagging/__init__.py | 1 + .../resource_tagging/test_account_tags.py | 481 +++++++++++ .../resource_tagging/test_keys.py | 117 +++ .../resource_tagging/test_values.py | 141 ++++ .../resource_tagging/test_zone_tags.py | 481 +++++++++++ tests/api_resources/test_resource_tagging.py | 131 +++ 30 files changed, 8056 insertions(+), 3 deletions(-) create mode 100644 src/cloudflare/resources/resource_tagging/__init__.py create mode 100644 src/cloudflare/resources/resource_tagging/account_tags.py create mode 100644 src/cloudflare/resources/resource_tagging/keys.py create mode 100644 src/cloudflare/resources/resource_tagging/resource_tagging.py create mode 100644 src/cloudflare/resources/resource_tagging/values.py create mode 100644 src/cloudflare/resources/resource_tagging/zone_tags.py create mode 100644 src/cloudflare/types/resource_tagging/__init__.py create mode 100644 src/cloudflare/types/resource_tagging/account_tag_get_params.py create mode 100644 src/cloudflare/types/resource_tagging/account_tag_get_response.py create mode 100644 src/cloudflare/types/resource_tagging/account_tag_update_params.py create mode 100644 src/cloudflare/types/resource_tagging/account_tag_update_response.py create mode 100644 src/cloudflare/types/resource_tagging/key_list_params.py create mode 100644 src/cloudflare/types/resource_tagging/key_list_response.py create mode 100644 src/cloudflare/types/resource_tagging/resource_tagging_list_params.py create mode 100644 src/cloudflare/types/resource_tagging/resource_tagging_list_response.py create mode 100644 src/cloudflare/types/resource_tagging/value_list_params.py create mode 100644 src/cloudflare/types/resource_tagging/value_list_response.py create mode 100644 src/cloudflare/types/resource_tagging/zone_tag_get_params.py create mode 100644 src/cloudflare/types/resource_tagging/zone_tag_get_response.py create mode 100644 src/cloudflare/types/resource_tagging/zone_tag_update_params.py create mode 100644 src/cloudflare/types/resource_tagging/zone_tag_update_response.py create mode 100644 tests/api_resources/resource_tagging/__init__.py create mode 100644 tests/api_resources/resource_tagging/test_account_tags.py create mode 100644 tests/api_resources/resource_tagging/test_keys.py create mode 100644 tests/api_resources/resource_tagging/test_values.py create mode 100644 tests/api_resources/resource_tagging/test_zone_tags.py create mode 100644 tests/api_resources/test_resource_tagging.py diff --git a/.stats.yml b/.stats.yml index 33026388f2e..f8d714a9ebd 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 2049 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2290f772d9da747604b876da6e05a038187c26179245af12a64d198f25ef3fd0.yml +configured_endpoints: 2058 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-27d7c57107c9203d814f63f6686c63b76aadb365ce0ee0549dfb214f40db12ef.yml openapi_spec_hash: f46a7fc30fe001095a2b484fb6ada3e9 -config_hash: ebde54bdd7ec58f9abf7de1c45a2c076 +config_hash: b78af95529f71a3da2339b6fd717ed86 diff --git a/api.md b/api.md index fdf2a04d227..ec569c47ec4 100644 --- a/api.md +++ b/api.md @@ -10540,6 +10540,70 @@ Methods: - client.resource_sharing.resources.delete(resource_id, \*, account_id, share_id) -> Optional[ResourceDeleteResponse] - client.resource_sharing.resources.get(resource_id, \*, account_id, share_id) -> Optional[ResourceGetResponse] +# ResourceTagging + +Types: + +```python +from cloudflare.types.resource_tagging import ResourceTaggingListResponse +``` + +Methods: + +- client.resource_tagging.list(\*, account_id, \*\*params) -> SyncCursorPaginationAfter[ResourceTaggingListResponse] + +## AccountTags + +Types: + +```python +from cloudflare.types.resource_tagging import AccountTagUpdateResponse, AccountTagGetResponse +``` + +Methods: + +- client.resource_tagging.account_tags.update(\*, account_id, \*\*params) -> Optional[AccountTagUpdateResponse] +- client.resource_tagging.account_tags.delete(\*, account_id) -> None +- client.resource_tagging.account_tags.get(\*, account_id, \*\*params) -> Optional[AccountTagGetResponse] + +## ZoneTags + +Types: + +```python +from cloudflare.types.resource_tagging import ZoneTagUpdateResponse, ZoneTagGetResponse +``` + +Methods: + +- client.resource_tagging.zone_tags.update(\*, zone_id, \*\*params) -> Optional[ZoneTagUpdateResponse] +- client.resource_tagging.zone_tags.delete(\*, zone_id) -> None +- client.resource_tagging.zone_tags.get(\*, zone_id, \*\*params) -> Optional[ZoneTagGetResponse] + +## Keys + +Types: + +```python +from cloudflare.types.resource_tagging import KeyListResponse +``` + +Methods: + +- client.resource_tagging.keys.list(\*, account_id, \*\*params) -> SyncCursorPaginationAfter[KeyListResponse] + +## Values + +Types: + +```python +from cloudflare.types.resource_tagging import ValueListResponse +``` + +Methods: + +- client.resource_tagging.values.list(tag_key, \*, account_id, \*\*params) -> SyncCursorPaginationAfter[ValueListResponse] + # LeakedCredentialChecks Types: diff --git a/src/cloudflare/_client.py b/src/cloudflare/_client.py index edc473185de..06911dbf10b 100644 --- a/src/cloudflare/_client.py +++ b/src/cloudflare/_client.py @@ -117,6 +117,7 @@ content_scanning, custom_hostnames, resource_sharing, + resource_tagging, token_validation, browser_rendering, mtls_certificates, @@ -230,6 +231,7 @@ from .resources.content_scanning.content_scanning import ContentScanningResource, AsyncContentScanningResource from .resources.custom_hostnames.custom_hostnames import CustomHostnamesResource, AsyncCustomHostnamesResource from .resources.resource_sharing.resource_sharing import ResourceSharingResource, AsyncResourceSharingResource + from .resources.resource_tagging.resource_tagging import ResourceTaggingResource, AsyncResourceTaggingResource from .resources.token_validation.token_validation import TokenValidationResource, AsyncTokenValidationResource from .resources.browser_rendering.browser_rendering import BrowserRenderingResource, AsyncBrowserRenderingResource from .resources.mtls_certificates.mtls_certificates import MTLSCertificatesResource, AsyncMTLSCertificatesResource @@ -897,6 +899,12 @@ def resource_sharing(self) -> ResourceSharingResource: return ResourceSharingResource(self) + @cached_property + def resource_tagging(self) -> ResourceTaggingResource: + from .resources.resource_tagging import ResourceTaggingResource + + return ResourceTaggingResource(self) + @cached_property def leaked_credential_checks(self) -> LeakedCredentialChecksResource: from .resources.leaked_credential_checks import LeakedCredentialChecksResource @@ -1763,6 +1771,12 @@ def resource_sharing(self) -> AsyncResourceSharingResource: return AsyncResourceSharingResource(self) + @cached_property + def resource_tagging(self) -> AsyncResourceTaggingResource: + from .resources.resource_tagging import AsyncResourceTaggingResource + + return AsyncResourceTaggingResource(self) + @cached_property def leaked_credential_checks(self) -> AsyncLeakedCredentialChecksResource: from .resources.leaked_credential_checks import AsyncLeakedCredentialChecksResource @@ -2559,6 +2573,12 @@ def resource_sharing(self) -> resource_sharing.ResourceSharingResourceWithRawRes return ResourceSharingResourceWithRawResponse(self._client.resource_sharing) + @cached_property + def resource_tagging(self) -> resource_tagging.ResourceTaggingResourceWithRawResponse: + from .resources.resource_tagging import ResourceTaggingResourceWithRawResponse + + return ResourceTaggingResourceWithRawResponse(self._client.resource_tagging) + @cached_property def leaked_credential_checks(self) -> leaked_credential_checks.LeakedCredentialChecksResourceWithRawResponse: from .resources.leaked_credential_checks import LeakedCredentialChecksResourceWithRawResponse @@ -3180,6 +3200,12 @@ def resource_sharing(self) -> resource_sharing.AsyncResourceSharingResourceWithR return AsyncResourceSharingResourceWithRawResponse(self._client.resource_sharing) + @cached_property + def resource_tagging(self) -> resource_tagging.AsyncResourceTaggingResourceWithRawResponse: + from .resources.resource_tagging import AsyncResourceTaggingResourceWithRawResponse + + return AsyncResourceTaggingResourceWithRawResponse(self._client.resource_tagging) + @cached_property def leaked_credential_checks(self) -> leaked_credential_checks.AsyncLeakedCredentialChecksResourceWithRawResponse: from .resources.leaked_credential_checks import AsyncLeakedCredentialChecksResourceWithRawResponse @@ -3801,6 +3827,12 @@ def resource_sharing(self) -> resource_sharing.ResourceSharingResourceWithStream return ResourceSharingResourceWithStreamingResponse(self._client.resource_sharing) + @cached_property + def resource_tagging(self) -> resource_tagging.ResourceTaggingResourceWithStreamingResponse: + from .resources.resource_tagging import ResourceTaggingResourceWithStreamingResponse + + return ResourceTaggingResourceWithStreamingResponse(self._client.resource_tagging) + @cached_property def leaked_credential_checks(self) -> leaked_credential_checks.LeakedCredentialChecksResourceWithStreamingResponse: from .resources.leaked_credential_checks import LeakedCredentialChecksResourceWithStreamingResponse @@ -4430,6 +4462,12 @@ def resource_sharing(self) -> resource_sharing.AsyncResourceSharingResourceWithS return AsyncResourceSharingResourceWithStreamingResponse(self._client.resource_sharing) + @cached_property + def resource_tagging(self) -> resource_tagging.AsyncResourceTaggingResourceWithStreamingResponse: + from .resources.resource_tagging import AsyncResourceTaggingResourceWithStreamingResponse + + return AsyncResourceTaggingResourceWithStreamingResponse(self._client.resource_tagging) + @cached_property def leaked_credential_checks( self, diff --git a/src/cloudflare/resources/resource_tagging/__init__.py b/src/cloudflare/resources/resource_tagging/__init__.py new file mode 100644 index 00000000000..bf3595821b2 --- /dev/null +++ b/src/cloudflare/resources/resource_tagging/__init__.py @@ -0,0 +1,75 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .keys import ( + KeysResource, + AsyncKeysResource, + KeysResourceWithRawResponse, + AsyncKeysResourceWithRawResponse, + KeysResourceWithStreamingResponse, + AsyncKeysResourceWithStreamingResponse, +) +from .values import ( + ValuesResource, + AsyncValuesResource, + ValuesResourceWithRawResponse, + AsyncValuesResourceWithRawResponse, + ValuesResourceWithStreamingResponse, + AsyncValuesResourceWithStreamingResponse, +) +from .zone_tags import ( + ZoneTagsResource, + AsyncZoneTagsResource, + ZoneTagsResourceWithRawResponse, + AsyncZoneTagsResourceWithRawResponse, + ZoneTagsResourceWithStreamingResponse, + AsyncZoneTagsResourceWithStreamingResponse, +) +from .account_tags import ( + AccountTagsResource, + AsyncAccountTagsResource, + AccountTagsResourceWithRawResponse, + AsyncAccountTagsResourceWithRawResponse, + AccountTagsResourceWithStreamingResponse, + AsyncAccountTagsResourceWithStreamingResponse, +) +from .resource_tagging import ( + ResourceTaggingResource, + AsyncResourceTaggingResource, + ResourceTaggingResourceWithRawResponse, + AsyncResourceTaggingResourceWithRawResponse, + ResourceTaggingResourceWithStreamingResponse, + AsyncResourceTaggingResourceWithStreamingResponse, +) + +__all__ = [ + "AccountTagsResource", + "AsyncAccountTagsResource", + "AccountTagsResourceWithRawResponse", + "AsyncAccountTagsResourceWithRawResponse", + "AccountTagsResourceWithStreamingResponse", + "AsyncAccountTagsResourceWithStreamingResponse", + "ZoneTagsResource", + "AsyncZoneTagsResource", + "ZoneTagsResourceWithRawResponse", + "AsyncZoneTagsResourceWithRawResponse", + "ZoneTagsResourceWithStreamingResponse", + "AsyncZoneTagsResourceWithStreamingResponse", + "KeysResource", + "AsyncKeysResource", + "KeysResourceWithRawResponse", + "AsyncKeysResourceWithRawResponse", + "KeysResourceWithStreamingResponse", + "AsyncKeysResourceWithStreamingResponse", + "ValuesResource", + "AsyncValuesResource", + "ValuesResourceWithRawResponse", + "AsyncValuesResourceWithRawResponse", + "ValuesResourceWithStreamingResponse", + "AsyncValuesResourceWithStreamingResponse", + "ResourceTaggingResource", + "AsyncResourceTaggingResource", + "ResourceTaggingResourceWithRawResponse", + "AsyncResourceTaggingResourceWithRawResponse", + "ResourceTaggingResourceWithStreamingResponse", + "AsyncResourceTaggingResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/resource_tagging/account_tags.py b/src/cloudflare/resources/resource_tagging/account_tags.py new file mode 100644 index 00000000000..64017813a3b --- /dev/null +++ b/src/cloudflare/resources/resource_tagging/account_tags.py @@ -0,0 +1,792 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Any, Dict, Optional, cast +from typing_extensions import Literal, overload + +import httpx + +from ..._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given +from ..._utils import required_args, maybe_transform, strip_not_given, async_maybe_transform +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..._wrappers import ResultWrapper +from ..._base_client import make_request_options +from ...types.resource_tagging import account_tag_get_params, account_tag_update_params +from ...types.resource_tagging.account_tag_get_response import AccountTagGetResponse +from ...types.resource_tagging.account_tag_update_response import AccountTagUpdateResponse + +__all__ = ["AccountTagsResource", "AsyncAccountTagsResource"] + + +class AccountTagsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> AccountTagsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AccountTagsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AccountTagsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AccountTagsResourceWithStreamingResponse(self) + + @overload + def update( + self, + *, + account_id: str, + resource_id: str, + resource_type: Literal[ + "access_application", + "access_group", + "account", + "ai_gateway", + "alerting_policy", + "alerting_webhook", + "cloudflared_tunnel", + "d1_database", + "durable_object_namespace", + "gateway_list", + "gateway_rule", + "image", + "kv_namespace", + "queue", + "r2_bucket", + "resource_share", + "stream_live_input", + "stream_video", + "worker", + "worker_version", + ], + worker_id: str, + tags: Dict[str, str] | Omit = omit, + if_match: str | Omit = omit, + # 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[AccountTagUpdateResponse]: + """ + Creates or updates tags for a specific account-level resource. + + Args: + account_id: Identifier. + + resource_id: Identifies the unique resource. + + resource_type: Enum for base account-level resource types (those with no extra required + fields). + + worker_id: Worker ID is required only for worker_version resources + + tags: Contains key-value pairs of tags. + + 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 + """ + ... + + @overload + def update( + self, + *, + account_id: str, + resource_id: str, + resource_type: Literal[ + "access_application", + "access_group", + "account", + "ai_gateway", + "alerting_policy", + "alerting_webhook", + "cloudflared_tunnel", + "d1_database", + "durable_object_namespace", + "gateway_list", + "gateway_rule", + "image", + "kv_namespace", + "queue", + "r2_bucket", + "resource_share", + "stream_live_input", + "stream_video", + "worker", + ], + tags: Dict[str, str] | Omit = omit, + if_match: str | Omit = omit, + # 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[AccountTagUpdateResponse]: + """ + Creates or updates tags for a specific account-level resource. + + Args: + account_id: Identifier. + + resource_id: Identifies the unique resource. + + resource_type: Enum for base account-level resource types (those with no extra required + fields). + + tags: Contains key-value pairs of tags. + + 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 + """ + ... + + @required_args( + ["account_id", "resource_id", "resource_type", "worker_id"], ["account_id", "resource_id", "resource_type"] + ) + def update( + self, + *, + account_id: str, + resource_id: str, + resource_type: Literal[ + "access_application", + "access_group", + "account", + "ai_gateway", + "alerting_policy", + "alerting_webhook", + "cloudflared_tunnel", + "d1_database", + "durable_object_namespace", + "gateway_list", + "gateway_rule", + "image", + "kv_namespace", + "queue", + "r2_bucket", + "resource_share", + "stream_live_input", + "stream_video", + "worker", + "worker_version", + ] + | Literal[ + "access_application", + "access_group", + "account", + "ai_gateway", + "alerting_policy", + "alerting_webhook", + "cloudflared_tunnel", + "d1_database", + "durable_object_namespace", + "gateway_list", + "gateway_rule", + "image", + "kv_namespace", + "queue", + "r2_bucket", + "resource_share", + "stream_live_input", + "stream_video", + "worker", + ], + worker_id: str | Omit = omit, + tags: Dict[str, str] | Omit = omit, + if_match: str | Omit = omit, + # 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[AccountTagUpdateResponse]: + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + extra_headers = {**strip_not_given({"If-Match": if_match}), **(extra_headers or {})} + return cast( + Optional[AccountTagUpdateResponse], + self._put( + f"/accounts/{account_id}/tags", + body=maybe_transform( + { + "resource_id": resource_id, + "resource_type": resource_type, + "worker_id": worker_id, + "tags": tags, + }, + account_tag_update_params.AccountTagUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[AccountTagUpdateResponse]]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[AccountTagUpdateResponse] + ), # Union types cannot be passed in as arguments in the type system + ), + ) + + def delete( + self, + *, + account_id: str, + if_match: str | Omit = omit, + # 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, + ) -> None: + """ + Removes all tags from a specific account-level resource. + + Args: + account_id: Identifier. + + 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}") + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + extra_headers = {**strip_not_given({"If-Match": if_match}), **(extra_headers or {})} + return self._delete( + f"/accounts/{account_id}/tags", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=NoneType, + ) + + def get( + self, + *, + account_id: str, + resource_id: str, + resource_type: Literal[ + "access_application", + "access_group", + "account", + "ai_gateway", + "alerting_policy", + "alerting_webhook", + "cloudflared_tunnel", + "d1_database", + "durable_object_namespace", + "gateway_list", + "gateway_rule", + "image", + "kv_namespace", + "queue", + "r2_bucket", + "resource_share", + "stream_live_input", + "stream_video", + "worker", + "worker_version", + ], + worker_id: str | Omit = omit, + # 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[AccountTagGetResponse]: + """ + Retrieves tags for a specific account-level resource. + + Args: + account_id: Identifier. + + resource_id: The ID of the resource to retrieve tags for. + + resource_type: The type of the resource. + + worker_id: Worker identifier. Required for worker_version resources. + + 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 cast( + Optional[AccountTagGetResponse], + self._get( + f"/accounts/{account_id}/tags", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "resource_id": resource_id, + "resource_type": resource_type, + "worker_id": worker_id, + }, + account_tag_get_params.AccountTagGetParams, + ), + post_parser=ResultWrapper[Optional[AccountTagGetResponse]]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[AccountTagGetResponse] + ), # Union types cannot be passed in as arguments in the type system + ), + ) + + +class AsyncAccountTagsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncAccountTagsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncAccountTagsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncAccountTagsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncAccountTagsResourceWithStreamingResponse(self) + + @overload + async def update( + self, + *, + account_id: str, + resource_id: str, + resource_type: Literal[ + "access_application", + "access_group", + "account", + "ai_gateway", + "alerting_policy", + "alerting_webhook", + "cloudflared_tunnel", + "d1_database", + "durable_object_namespace", + "gateway_list", + "gateway_rule", + "image", + "kv_namespace", + "queue", + "r2_bucket", + "resource_share", + "stream_live_input", + "stream_video", + "worker", + "worker_version", + ], + worker_id: str, + tags: Dict[str, str] | Omit = omit, + if_match: str | Omit = omit, + # 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[AccountTagUpdateResponse]: + """ + Creates or updates tags for a specific account-level resource. + + Args: + account_id: Identifier. + + resource_id: Identifies the unique resource. + + resource_type: Enum for base account-level resource types (those with no extra required + fields). + + worker_id: Worker ID is required only for worker_version resources + + tags: Contains key-value pairs of tags. + + 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 + """ + ... + + @overload + async def update( + self, + *, + account_id: str, + resource_id: str, + resource_type: Literal[ + "access_application", + "access_group", + "account", + "ai_gateway", + "alerting_policy", + "alerting_webhook", + "cloudflared_tunnel", + "d1_database", + "durable_object_namespace", + "gateway_list", + "gateway_rule", + "image", + "kv_namespace", + "queue", + "r2_bucket", + "resource_share", + "stream_live_input", + "stream_video", + "worker", + ], + tags: Dict[str, str] | Omit = omit, + if_match: str | Omit = omit, + # 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[AccountTagUpdateResponse]: + """ + Creates or updates tags for a specific account-level resource. + + Args: + account_id: Identifier. + + resource_id: Identifies the unique resource. + + resource_type: Enum for base account-level resource types (those with no extra required + fields). + + tags: Contains key-value pairs of tags. + + 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 + """ + ... + + @required_args( + ["account_id", "resource_id", "resource_type", "worker_id"], ["account_id", "resource_id", "resource_type"] + ) + async def update( + self, + *, + account_id: str, + resource_id: str, + resource_type: Literal[ + "access_application", + "access_group", + "account", + "ai_gateway", + "alerting_policy", + "alerting_webhook", + "cloudflared_tunnel", + "d1_database", + "durable_object_namespace", + "gateway_list", + "gateway_rule", + "image", + "kv_namespace", + "queue", + "r2_bucket", + "resource_share", + "stream_live_input", + "stream_video", + "worker", + "worker_version", + ] + | Literal[ + "access_application", + "access_group", + "account", + "ai_gateway", + "alerting_policy", + "alerting_webhook", + "cloudflared_tunnel", + "d1_database", + "durable_object_namespace", + "gateway_list", + "gateway_rule", + "image", + "kv_namespace", + "queue", + "r2_bucket", + "resource_share", + "stream_live_input", + "stream_video", + "worker", + ], + worker_id: str | Omit = omit, + tags: Dict[str, str] | Omit = omit, + if_match: str | Omit = omit, + # 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[AccountTagUpdateResponse]: + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + extra_headers = {**strip_not_given({"If-Match": if_match}), **(extra_headers or {})} + return cast( + Optional[AccountTagUpdateResponse], + await self._put( + f"/accounts/{account_id}/tags", + body=await async_maybe_transform( + { + "resource_id": resource_id, + "resource_type": resource_type, + "worker_id": worker_id, + "tags": tags, + }, + account_tag_update_params.AccountTagUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[AccountTagUpdateResponse]]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[AccountTagUpdateResponse] + ), # Union types cannot be passed in as arguments in the type system + ), + ) + + async def delete( + self, + *, + account_id: str, + if_match: str | Omit = omit, + # 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, + ) -> None: + """ + Removes all tags from a specific account-level resource. + + Args: + account_id: Identifier. + + 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}") + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + extra_headers = {**strip_not_given({"If-Match": if_match}), **(extra_headers or {})} + return await self._delete( + f"/accounts/{account_id}/tags", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=NoneType, + ) + + async def get( + self, + *, + account_id: str, + resource_id: str, + resource_type: Literal[ + "access_application", + "access_group", + "account", + "ai_gateway", + "alerting_policy", + "alerting_webhook", + "cloudflared_tunnel", + "d1_database", + "durable_object_namespace", + "gateway_list", + "gateway_rule", + "image", + "kv_namespace", + "queue", + "r2_bucket", + "resource_share", + "stream_live_input", + "stream_video", + "worker", + "worker_version", + ], + worker_id: str | Omit = omit, + # 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[AccountTagGetResponse]: + """ + Retrieves tags for a specific account-level resource. + + Args: + account_id: Identifier. + + resource_id: The ID of the resource to retrieve tags for. + + resource_type: The type of the resource. + + worker_id: Worker identifier. Required for worker_version resources. + + 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 cast( + Optional[AccountTagGetResponse], + await self._get( + f"/accounts/{account_id}/tags", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "resource_id": resource_id, + "resource_type": resource_type, + "worker_id": worker_id, + }, + account_tag_get_params.AccountTagGetParams, + ), + post_parser=ResultWrapper[Optional[AccountTagGetResponse]]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[AccountTagGetResponse] + ), # Union types cannot be passed in as arguments in the type system + ), + ) + + +class AccountTagsResourceWithRawResponse: + def __init__(self, account_tags: AccountTagsResource) -> None: + self._account_tags = account_tags + + self.update = to_raw_response_wrapper( + account_tags.update, + ) + self.delete = to_raw_response_wrapper( + account_tags.delete, + ) + self.get = to_raw_response_wrapper( + account_tags.get, + ) + + +class AsyncAccountTagsResourceWithRawResponse: + def __init__(self, account_tags: AsyncAccountTagsResource) -> None: + self._account_tags = account_tags + + self.update = async_to_raw_response_wrapper( + account_tags.update, + ) + self.delete = async_to_raw_response_wrapper( + account_tags.delete, + ) + self.get = async_to_raw_response_wrapper( + account_tags.get, + ) + + +class AccountTagsResourceWithStreamingResponse: + def __init__(self, account_tags: AccountTagsResource) -> None: + self._account_tags = account_tags + + self.update = to_streamed_response_wrapper( + account_tags.update, + ) + self.delete = to_streamed_response_wrapper( + account_tags.delete, + ) + self.get = to_streamed_response_wrapper( + account_tags.get, + ) + + +class AsyncAccountTagsResourceWithStreamingResponse: + def __init__(self, account_tags: AsyncAccountTagsResource) -> None: + self._account_tags = account_tags + + self.update = async_to_streamed_response_wrapper( + account_tags.update, + ) + self.delete = async_to_streamed_response_wrapper( + account_tags.delete, + ) + self.get = async_to_streamed_response_wrapper( + account_tags.get, + ) diff --git a/src/cloudflare/resources/resource_tagging/keys.py b/src/cloudflare/resources/resource_tagging/keys.py new file mode 100644 index 00000000000..4a106e55917 --- /dev/null +++ b/src/cloudflare/resources/resource_tagging/keys.py @@ -0,0 +1,186 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +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 ...pagination import SyncCursorPaginationAfter, AsyncCursorPaginationAfter +from ..._base_client import AsyncPaginator, make_request_options +from ...types.resource_tagging import key_list_params +from ...types.resource_tagging.key_list_response import KeyListResponse + +__all__ = ["KeysResource", "AsyncKeysResource"] + + +class KeysResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> KeysResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return KeysResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> KeysResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return KeysResourceWithStreamingResponse(self) + + def list( + self, + *, + account_id: str, + cursor: str | Omit = omit, + # 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, + ) -> SyncCursorPaginationAfter[KeyListResponse]: + """ + Lists all distinct tag keys used across resources in an account. + + Args: + account_id: Identifier. + + cursor: Cursor for pagination. + + 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}/tags/keys", + page=SyncCursorPaginationAfter[KeyListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform({"cursor": cursor}, key_list_params.KeyListParams), + ), + model=str, + ) + + +class AsyncKeysResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncKeysResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncKeysResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncKeysResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncKeysResourceWithStreamingResponse(self) + + def list( + self, + *, + account_id: str, + cursor: str | Omit = omit, + # 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[KeyListResponse, AsyncCursorPaginationAfter[KeyListResponse]]: + """ + Lists all distinct tag keys used across resources in an account. + + Args: + account_id: Identifier. + + cursor: Cursor for pagination. + + 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}/tags/keys", + page=AsyncCursorPaginationAfter[KeyListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform({"cursor": cursor}, key_list_params.KeyListParams), + ), + model=str, + ) + + +class KeysResourceWithRawResponse: + def __init__(self, keys: KeysResource) -> None: + self._keys = keys + + self.list = to_raw_response_wrapper( + keys.list, + ) + + +class AsyncKeysResourceWithRawResponse: + def __init__(self, keys: AsyncKeysResource) -> None: + self._keys = keys + + self.list = async_to_raw_response_wrapper( + keys.list, + ) + + +class KeysResourceWithStreamingResponse: + def __init__(self, keys: KeysResource) -> None: + self._keys = keys + + self.list = to_streamed_response_wrapper( + keys.list, + ) + + +class AsyncKeysResourceWithStreamingResponse: + def __init__(self, keys: AsyncKeysResource) -> None: + self._keys = keys + + self.list = async_to_streamed_response_wrapper( + keys.list, + ) diff --git a/src/cloudflare/resources/resource_tagging/resource_tagging.py b/src/cloudflare/resources/resource_tagging/resource_tagging.py new file mode 100644 index 00000000000..56a27620fc6 --- /dev/null +++ b/src/cloudflare/resources/resource_tagging/resource_tagging.py @@ -0,0 +1,443 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Any, List, cast +from typing_extensions import Literal + +import httpx + +from .keys import ( + KeysResource, + AsyncKeysResource, + KeysResourceWithRawResponse, + AsyncKeysResourceWithRawResponse, + KeysResourceWithStreamingResponse, + AsyncKeysResourceWithStreamingResponse, +) +from .values import ( + ValuesResource, + AsyncValuesResource, + ValuesResourceWithRawResponse, + AsyncValuesResourceWithRawResponse, + ValuesResourceWithStreamingResponse, + AsyncValuesResourceWithStreamingResponse, +) +from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given +from ..._utils import maybe_transform +from ..._compat import cached_property +from .zone_tags import ( + ZoneTagsResource, + AsyncZoneTagsResource, + ZoneTagsResourceWithRawResponse, + AsyncZoneTagsResourceWithRawResponse, + ZoneTagsResourceWithStreamingResponse, + AsyncZoneTagsResourceWithStreamingResponse, +) +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 ...pagination import SyncCursorPaginationAfter, AsyncCursorPaginationAfter +from .account_tags import ( + AccountTagsResource, + AsyncAccountTagsResource, + AccountTagsResourceWithRawResponse, + AsyncAccountTagsResourceWithRawResponse, + AccountTagsResourceWithStreamingResponse, + AsyncAccountTagsResourceWithStreamingResponse, +) +from ..._base_client import AsyncPaginator, make_request_options +from ...types.resource_tagging import resource_tagging_list_params +from ...types.resource_tagging.resource_tagging_list_response import ResourceTaggingListResponse + +__all__ = ["ResourceTaggingResource", "AsyncResourceTaggingResource"] + + +class ResourceTaggingResource(SyncAPIResource): + @cached_property + def account_tags(self) -> AccountTagsResource: + return AccountTagsResource(self._client) + + @cached_property + def zone_tags(self) -> ZoneTagsResource: + return ZoneTagsResource(self._client) + + @cached_property + def keys(self) -> KeysResource: + return KeysResource(self._client) + + @cached_property + def values(self) -> ValuesResource: + return ValuesResource(self._client) + + @cached_property + def with_raw_response(self) -> ResourceTaggingResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return ResourceTaggingResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ResourceTaggingResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return ResourceTaggingResourceWithStreamingResponse(self) + + def list( + self, + *, + account_id: str, + cursor: str | Omit = omit, + tag: SequenceNotStr[str] | Omit = omit, + type: List[ + Literal[ + "access_application", + "access_application_policy", + "access_group", + "account", + "ai_gateway", + "alerting_policy", + "alerting_webhook", + "api_gateway_operation", + "cloudflared_tunnel", + "custom_certificate", + "custom_hostname", + "d1_database", + "dns_record", + "durable_object_namespace", + "gateway_list", + "gateway_rule", + "image", + "kv_namespace", + "managed_client_certificate", + "queue", + "r2_bucket", + "resource_share", + "stream_live_input", + "stream_video", + "worker", + "worker_version", + "zone", + ] + ] + | Omit = omit, + # 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, + ) -> SyncCursorPaginationAfter[ResourceTaggingListResponse]: + """ + Lists all tagged resources for an account. + + Args: + account_id: Identifier. + + cursor: Cursor for pagination. + + tag: Filter resources by tag criteria. This parameter can be repeated multiple times, + with AND logic between parameters. + + Supported syntax: + + - **Key-only**: `tag=` - Resource must have the tag key (e.g., + `tag=production`) + - **Key-value**: `tag==` - Resource must have the tag with specific + value (e.g., `tag=env=prod`) + - **Multiple values (OR)**: `tag==,` - Resource must have tag with + any of the values (e.g., `tag=env=prod,staging`) + - **Negate key-only**: `tag=!` - Resource must not have the tag key (e.g., + `tag=!archived`) + - **Negate key-value**: `tag=!=` - Resource must not have the tag + with specific value (e.g., `tag=region!=us-west-1`) + + Multiple tag parameters are combined with AND logic. + + type: Filter by resource type. Can be repeated to filter by multiple types (OR logic). + Example: ?type=zone&type=worker + + 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}/tags/resources", + page=SyncCursorPaginationAfter[ResourceTaggingListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "cursor": cursor, + "tag": tag, + "type": type, + }, + resource_tagging_list_params.ResourceTaggingListParams, + ), + ), + model=cast( + Any, ResourceTaggingListResponse + ), # Union types cannot be passed in as arguments in the type system + ) + + +class AsyncResourceTaggingResource(AsyncAPIResource): + @cached_property + def account_tags(self) -> AsyncAccountTagsResource: + return AsyncAccountTagsResource(self._client) + + @cached_property + def zone_tags(self) -> AsyncZoneTagsResource: + return AsyncZoneTagsResource(self._client) + + @cached_property + def keys(self) -> AsyncKeysResource: + return AsyncKeysResource(self._client) + + @cached_property + def values(self) -> AsyncValuesResource: + return AsyncValuesResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncResourceTaggingResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncResourceTaggingResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncResourceTaggingResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncResourceTaggingResourceWithStreamingResponse(self) + + def list( + self, + *, + account_id: str, + cursor: str | Omit = omit, + tag: SequenceNotStr[str] | Omit = omit, + type: List[ + Literal[ + "access_application", + "access_application_policy", + "access_group", + "account", + "ai_gateway", + "alerting_policy", + "alerting_webhook", + "api_gateway_operation", + "cloudflared_tunnel", + "custom_certificate", + "custom_hostname", + "d1_database", + "dns_record", + "durable_object_namespace", + "gateway_list", + "gateway_rule", + "image", + "kv_namespace", + "managed_client_certificate", + "queue", + "r2_bucket", + "resource_share", + "stream_live_input", + "stream_video", + "worker", + "worker_version", + "zone", + ] + ] + | Omit = omit, + # 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[ResourceTaggingListResponse, AsyncCursorPaginationAfter[ResourceTaggingListResponse]]: + """ + Lists all tagged resources for an account. + + Args: + account_id: Identifier. + + cursor: Cursor for pagination. + + tag: Filter resources by tag criteria. This parameter can be repeated multiple times, + with AND logic between parameters. + + Supported syntax: + + - **Key-only**: `tag=` - Resource must have the tag key (e.g., + `tag=production`) + - **Key-value**: `tag==` - Resource must have the tag with specific + value (e.g., `tag=env=prod`) + - **Multiple values (OR)**: `tag==,` - Resource must have tag with + any of the values (e.g., `tag=env=prod,staging`) + - **Negate key-only**: `tag=!` - Resource must not have the tag key (e.g., + `tag=!archived`) + - **Negate key-value**: `tag=!=` - Resource must not have the tag + with specific value (e.g., `tag=region!=us-west-1`) + + Multiple tag parameters are combined with AND logic. + + type: Filter by resource type. Can be repeated to filter by multiple types (OR logic). + Example: ?type=zone&type=worker + + 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}/tags/resources", + page=AsyncCursorPaginationAfter[ResourceTaggingListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "cursor": cursor, + "tag": tag, + "type": type, + }, + resource_tagging_list_params.ResourceTaggingListParams, + ), + ), + model=cast( + Any, ResourceTaggingListResponse + ), # Union types cannot be passed in as arguments in the type system + ) + + +class ResourceTaggingResourceWithRawResponse: + def __init__(self, resource_tagging: ResourceTaggingResource) -> None: + self._resource_tagging = resource_tagging + + self.list = to_raw_response_wrapper( + resource_tagging.list, + ) + + @cached_property + def account_tags(self) -> AccountTagsResourceWithRawResponse: + return AccountTagsResourceWithRawResponse(self._resource_tagging.account_tags) + + @cached_property + def zone_tags(self) -> ZoneTagsResourceWithRawResponse: + return ZoneTagsResourceWithRawResponse(self._resource_tagging.zone_tags) + + @cached_property + def keys(self) -> KeysResourceWithRawResponse: + return KeysResourceWithRawResponse(self._resource_tagging.keys) + + @cached_property + def values(self) -> ValuesResourceWithRawResponse: + return ValuesResourceWithRawResponse(self._resource_tagging.values) + + +class AsyncResourceTaggingResourceWithRawResponse: + def __init__(self, resource_tagging: AsyncResourceTaggingResource) -> None: + self._resource_tagging = resource_tagging + + self.list = async_to_raw_response_wrapper( + resource_tagging.list, + ) + + @cached_property + def account_tags(self) -> AsyncAccountTagsResourceWithRawResponse: + return AsyncAccountTagsResourceWithRawResponse(self._resource_tagging.account_tags) + + @cached_property + def zone_tags(self) -> AsyncZoneTagsResourceWithRawResponse: + return AsyncZoneTagsResourceWithRawResponse(self._resource_tagging.zone_tags) + + @cached_property + def keys(self) -> AsyncKeysResourceWithRawResponse: + return AsyncKeysResourceWithRawResponse(self._resource_tagging.keys) + + @cached_property + def values(self) -> AsyncValuesResourceWithRawResponse: + return AsyncValuesResourceWithRawResponse(self._resource_tagging.values) + + +class ResourceTaggingResourceWithStreamingResponse: + def __init__(self, resource_tagging: ResourceTaggingResource) -> None: + self._resource_tagging = resource_tagging + + self.list = to_streamed_response_wrapper( + resource_tagging.list, + ) + + @cached_property + def account_tags(self) -> AccountTagsResourceWithStreamingResponse: + return AccountTagsResourceWithStreamingResponse(self._resource_tagging.account_tags) + + @cached_property + def zone_tags(self) -> ZoneTagsResourceWithStreamingResponse: + return ZoneTagsResourceWithStreamingResponse(self._resource_tagging.zone_tags) + + @cached_property + def keys(self) -> KeysResourceWithStreamingResponse: + return KeysResourceWithStreamingResponse(self._resource_tagging.keys) + + @cached_property + def values(self) -> ValuesResourceWithStreamingResponse: + return ValuesResourceWithStreamingResponse(self._resource_tagging.values) + + +class AsyncResourceTaggingResourceWithStreamingResponse: + def __init__(self, resource_tagging: AsyncResourceTaggingResource) -> None: + self._resource_tagging = resource_tagging + + self.list = async_to_streamed_response_wrapper( + resource_tagging.list, + ) + + @cached_property + def account_tags(self) -> AsyncAccountTagsResourceWithStreamingResponse: + return AsyncAccountTagsResourceWithStreamingResponse(self._resource_tagging.account_tags) + + @cached_property + def zone_tags(self) -> AsyncZoneTagsResourceWithStreamingResponse: + return AsyncZoneTagsResourceWithStreamingResponse(self._resource_tagging.zone_tags) + + @cached_property + def keys(self) -> AsyncKeysResourceWithStreamingResponse: + return AsyncKeysResourceWithStreamingResponse(self._resource_tagging.keys) + + @cached_property + def values(self) -> AsyncValuesResourceWithStreamingResponse: + return AsyncValuesResourceWithStreamingResponse(self._resource_tagging.values) diff --git a/src/cloudflare/resources/resource_tagging/values.py b/src/cloudflare/resources/resource_tagging/values.py new file mode 100644 index 00000000000..b2b278b99f4 --- /dev/null +++ b/src/cloudflare/resources/resource_tagging/values.py @@ -0,0 +1,272 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal + +import httpx + +from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +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 ...pagination import SyncCursorPaginationAfter, AsyncCursorPaginationAfter +from ..._base_client import AsyncPaginator, make_request_options +from ...types.resource_tagging import value_list_params +from ...types.resource_tagging.value_list_response import ValueListResponse + +__all__ = ["ValuesResource", "AsyncValuesResource"] + + +class ValuesResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> ValuesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return ValuesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ValuesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return ValuesResourceWithStreamingResponse(self) + + def list( + self, + tag_key: str, + *, + account_id: str, + cursor: str | Omit = omit, + type: Literal[ + "access_application", + "access_application_policy", + "access_group", + "account", + "ai_gateway", + "alerting_policy", + "alerting_webhook", + "api_gateway_operation", + "cloudflared_tunnel", + "custom_certificate", + "custom_hostname", + "d1_database", + "dns_record", + "durable_object_namespace", + "gateway_list", + "gateway_rule", + "image", + "kv_namespace", + "managed_client_certificate", + "queue", + "r2_bucket", + "resource_share", + "stream_live_input", + "stream_video", + "worker", + "worker_version", + "zone", + ] + | Omit = omit, + # 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, + ) -> SyncCursorPaginationAfter[ValueListResponse]: + """ + Lists all distinct values for a given tag key, optionally filtered by resource + type. + + Args: + account_id: Identifier. + + cursor: Cursor for pagination. + + type: Filter by resource type. + + 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 tag_key: + raise ValueError(f"Expected a non-empty value for `tag_key` but received {tag_key!r}") + return self._get_api_list( + f"/accounts/{account_id}/tags/values/{tag_key}", + page=SyncCursorPaginationAfter[ValueListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "cursor": cursor, + "type": type, + }, + value_list_params.ValueListParams, + ), + ), + model=str, + ) + + +class AsyncValuesResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncValuesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncValuesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncValuesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncValuesResourceWithStreamingResponse(self) + + def list( + self, + tag_key: str, + *, + account_id: str, + cursor: str | Omit = omit, + type: Literal[ + "access_application", + "access_application_policy", + "access_group", + "account", + "ai_gateway", + "alerting_policy", + "alerting_webhook", + "api_gateway_operation", + "cloudflared_tunnel", + "custom_certificate", + "custom_hostname", + "d1_database", + "dns_record", + "durable_object_namespace", + "gateway_list", + "gateway_rule", + "image", + "kv_namespace", + "managed_client_certificate", + "queue", + "r2_bucket", + "resource_share", + "stream_live_input", + "stream_video", + "worker", + "worker_version", + "zone", + ] + | Omit = omit, + # 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[ValueListResponse, AsyncCursorPaginationAfter[ValueListResponse]]: + """ + Lists all distinct values for a given tag key, optionally filtered by resource + type. + + Args: + account_id: Identifier. + + cursor: Cursor for pagination. + + type: Filter by resource type. + + 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 tag_key: + raise ValueError(f"Expected a non-empty value for `tag_key` but received {tag_key!r}") + return self._get_api_list( + f"/accounts/{account_id}/tags/values/{tag_key}", + page=AsyncCursorPaginationAfter[ValueListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "cursor": cursor, + "type": type, + }, + value_list_params.ValueListParams, + ), + ), + model=str, + ) + + +class ValuesResourceWithRawResponse: + def __init__(self, values: ValuesResource) -> None: + self._values = values + + self.list = to_raw_response_wrapper( + values.list, + ) + + +class AsyncValuesResourceWithRawResponse: + def __init__(self, values: AsyncValuesResource) -> None: + self._values = values + + self.list = async_to_raw_response_wrapper( + values.list, + ) + + +class ValuesResourceWithStreamingResponse: + def __init__(self, values: ValuesResource) -> None: + self._values = values + + self.list = to_streamed_response_wrapper( + values.list, + ) + + +class AsyncValuesResourceWithStreamingResponse: + def __init__(self, values: AsyncValuesResource) -> None: + self._values = values + + self.list = async_to_streamed_response_wrapper( + values.list, + ) diff --git a/src/cloudflare/resources/resource_tagging/zone_tags.py b/src/cloudflare/resources/resource_tagging/zone_tags.py new file mode 100644 index 00000000000..8b5224337f1 --- /dev/null +++ b/src/cloudflare/resources/resource_tagging/zone_tags.py @@ -0,0 +1,670 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Any, Dict, Optional, cast +from typing_extensions import Literal, overload + +import httpx + +from ..._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given +from ..._utils import required_args, maybe_transform, strip_not_given, async_maybe_transform +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..._wrappers import ResultWrapper +from ..._base_client import make_request_options +from ...types.resource_tagging import zone_tag_get_params, zone_tag_update_params +from ...types.resource_tagging.zone_tag_get_response import ZoneTagGetResponse +from ...types.resource_tagging.zone_tag_update_response import ZoneTagUpdateResponse + +__all__ = ["ZoneTagsResource", "AsyncZoneTagsResource"] + + +class ZoneTagsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> ZoneTagsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return ZoneTagsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ZoneTagsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return ZoneTagsResourceWithStreamingResponse(self) + + @overload + def update( + self, + *, + zone_id: str, + resource_id: str, + resource_type: Literal[ + "api_gateway_operation", + "custom_certificate", + "custom_hostname", + "dns_record", + "managed_client_certificate", + "zone", + ], + tags: Dict[str, str] | Omit = omit, + if_match: str | Omit = omit, + # 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[ZoneTagUpdateResponse]: + """Creates or updates tags for a specific zone-level resource. + + Replaces all + existing tags for the resource. + + Args: + zone_id: Zone ID is required only for zone-level resources + + resource_id: Identifies the unique resource. + + resource_type: Enum for base zone-level resource types (those with no extra required fields). + + tags: Contains key-value pairs of tags. + + 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 + """ + ... + + @overload + def update( + self, + *, + zone_id: str, + access_application_id: str, + resource_id: str, + resource_type: Literal[ + "api_gateway_operation", + "custom_certificate", + "custom_hostname", + "dns_record", + "managed_client_certificate", + "zone", + "access_application_policy", + ], + tags: Dict[str, str] | Omit = omit, + if_match: str | Omit = omit, + # 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[ZoneTagUpdateResponse]: + """Creates or updates tags for a specific zone-level resource. + + Replaces all + existing tags for the resource. + + Args: + zone_id: Zone ID is required only for zone-level resources + + access_application_id: Access application ID is required only for access_application_policy resources + + resource_id: Identifies the unique resource. + + resource_type: Enum for base zone-level resource types (those with no extra required fields). + + tags: Contains key-value pairs of tags. + + 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 + """ + ... + + @required_args( + ["zone_id", "resource_id", "resource_type"], + ["zone_id", "access_application_id", "resource_id", "resource_type"], + ) + def update( + self, + *, + zone_id: str, + resource_id: str, + resource_type: Literal[ + "api_gateway_operation", + "custom_certificate", + "custom_hostname", + "dns_record", + "managed_client_certificate", + "zone", + ] + | Literal[ + "api_gateway_operation", + "custom_certificate", + "custom_hostname", + "dns_record", + "managed_client_certificate", + "zone", + "access_application_policy", + ], + tags: Dict[str, str] | Omit = omit, + if_match: str | Omit = omit, + access_application_id: str | Omit = omit, + # 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[ZoneTagUpdateResponse]: + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + extra_headers = {**strip_not_given({"If-Match": if_match}), **(extra_headers or {})} + return cast( + Optional[ZoneTagUpdateResponse], + self._put( + f"/zones/{zone_id}/tags", + body=maybe_transform( + { + "resource_id": resource_id, + "resource_type": resource_type, + "tags": tags, + "access_application_id": access_application_id, + }, + zone_tag_update_params.ZoneTagUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ZoneTagUpdateResponse]]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[ZoneTagUpdateResponse] + ), # Union types cannot be passed in as arguments in the type system + ), + ) + + def delete( + self, + *, + zone_id: str, + if_match: str | Omit = omit, + # 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, + ) -> None: + """ + Removes all tags from a specific zone-level resource. + + Args: + zone_id: Zone ID is required only for zone-level resources + + 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 zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + extra_headers = {**strip_not_given({"If-Match": if_match}), **(extra_headers or {})} + return self._delete( + f"/zones/{zone_id}/tags", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=NoneType, + ) + + def get( + self, + *, + zone_id: str, + resource_id: str, + resource_type: Literal[ + "access_application_policy", + "api_gateway_operation", + "custom_certificate", + "custom_hostname", + "dns_record", + "managed_client_certificate", + "zone", + ], + access_application_id: str | Omit = omit, + # 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[ZoneTagGetResponse]: + """ + Retrieves tags for a specific zone-level resource. + + Args: + zone_id: Zone ID is required only for zone-level resources + + resource_id: The ID of the resource to retrieve tags for. + + resource_type: The type of the resource. + + access_application_id: Access application ID identifier. Required for access_application_policy + resources. + + 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 zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return cast( + Optional[ZoneTagGetResponse], + self._get( + f"/zones/{zone_id}/tags", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "resource_id": resource_id, + "resource_type": resource_type, + "access_application_id": access_application_id, + }, + zone_tag_get_params.ZoneTagGetParams, + ), + post_parser=ResultWrapper[Optional[ZoneTagGetResponse]]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[ZoneTagGetResponse] + ), # Union types cannot be passed in as arguments in the type system + ), + ) + + +class AsyncZoneTagsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncZoneTagsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncZoneTagsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncZoneTagsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncZoneTagsResourceWithStreamingResponse(self) + + @overload + async def update( + self, + *, + zone_id: str, + resource_id: str, + resource_type: Literal[ + "api_gateway_operation", + "custom_certificate", + "custom_hostname", + "dns_record", + "managed_client_certificate", + "zone", + ], + tags: Dict[str, str] | Omit = omit, + if_match: str | Omit = omit, + # 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[ZoneTagUpdateResponse]: + """Creates or updates tags for a specific zone-level resource. + + Replaces all + existing tags for the resource. + + Args: + zone_id: Zone ID is required only for zone-level resources + + resource_id: Identifies the unique resource. + + resource_type: Enum for base zone-level resource types (those with no extra required fields). + + tags: Contains key-value pairs of tags. + + 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 + """ + ... + + @overload + async def update( + self, + *, + zone_id: str, + access_application_id: str, + resource_id: str, + resource_type: Literal[ + "api_gateway_operation", + "custom_certificate", + "custom_hostname", + "dns_record", + "managed_client_certificate", + "zone", + "access_application_policy", + ], + tags: Dict[str, str] | Omit = omit, + if_match: str | Omit = omit, + # 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[ZoneTagUpdateResponse]: + """Creates or updates tags for a specific zone-level resource. + + Replaces all + existing tags for the resource. + + Args: + zone_id: Zone ID is required only for zone-level resources + + access_application_id: Access application ID is required only for access_application_policy resources + + resource_id: Identifies the unique resource. + + resource_type: Enum for base zone-level resource types (those with no extra required fields). + + tags: Contains key-value pairs of tags. + + 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 + """ + ... + + @required_args( + ["zone_id", "resource_id", "resource_type"], + ["zone_id", "access_application_id", "resource_id", "resource_type"], + ) + async def update( + self, + *, + zone_id: str, + resource_id: str, + resource_type: Literal[ + "api_gateway_operation", + "custom_certificate", + "custom_hostname", + "dns_record", + "managed_client_certificate", + "zone", + ] + | Literal[ + "api_gateway_operation", + "custom_certificate", + "custom_hostname", + "dns_record", + "managed_client_certificate", + "zone", + "access_application_policy", + ], + tags: Dict[str, str] | Omit = omit, + if_match: str | Omit = omit, + access_application_id: str | Omit = omit, + # 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[ZoneTagUpdateResponse]: + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + extra_headers = {**strip_not_given({"If-Match": if_match}), **(extra_headers or {})} + return cast( + Optional[ZoneTagUpdateResponse], + await self._put( + f"/zones/{zone_id}/tags", + body=await async_maybe_transform( + { + "resource_id": resource_id, + "resource_type": resource_type, + "tags": tags, + "access_application_id": access_application_id, + }, + zone_tag_update_params.ZoneTagUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ZoneTagUpdateResponse]]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[ZoneTagUpdateResponse] + ), # Union types cannot be passed in as arguments in the type system + ), + ) + + async def delete( + self, + *, + zone_id: str, + if_match: str | Omit = omit, + # 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, + ) -> None: + """ + Removes all tags from a specific zone-level resource. + + Args: + zone_id: Zone ID is required only for zone-level resources + + 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 zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + extra_headers = {"Accept": "*/*", **(extra_headers or {})} + extra_headers = {**strip_not_given({"If-Match": if_match}), **(extra_headers or {})} + return await self._delete( + f"/zones/{zone_id}/tags", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=NoneType, + ) + + async def get( + self, + *, + zone_id: str, + resource_id: str, + resource_type: Literal[ + "access_application_policy", + "api_gateway_operation", + "custom_certificate", + "custom_hostname", + "dns_record", + "managed_client_certificate", + "zone", + ], + access_application_id: str | Omit = omit, + # 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[ZoneTagGetResponse]: + """ + Retrieves tags for a specific zone-level resource. + + Args: + zone_id: Zone ID is required only for zone-level resources + + resource_id: The ID of the resource to retrieve tags for. + + resource_type: The type of the resource. + + access_application_id: Access application ID identifier. Required for access_application_policy + resources. + + 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 zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + return cast( + Optional[ZoneTagGetResponse], + await self._get( + f"/zones/{zone_id}/tags", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "resource_id": resource_id, + "resource_type": resource_type, + "access_application_id": access_application_id, + }, + zone_tag_get_params.ZoneTagGetParams, + ), + post_parser=ResultWrapper[Optional[ZoneTagGetResponse]]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[ZoneTagGetResponse] + ), # Union types cannot be passed in as arguments in the type system + ), + ) + + +class ZoneTagsResourceWithRawResponse: + def __init__(self, zone_tags: ZoneTagsResource) -> None: + self._zone_tags = zone_tags + + self.update = to_raw_response_wrapper( + zone_tags.update, + ) + self.delete = to_raw_response_wrapper( + zone_tags.delete, + ) + self.get = to_raw_response_wrapper( + zone_tags.get, + ) + + +class AsyncZoneTagsResourceWithRawResponse: + def __init__(self, zone_tags: AsyncZoneTagsResource) -> None: + self._zone_tags = zone_tags + + self.update = async_to_raw_response_wrapper( + zone_tags.update, + ) + self.delete = async_to_raw_response_wrapper( + zone_tags.delete, + ) + self.get = async_to_raw_response_wrapper( + zone_tags.get, + ) + + +class ZoneTagsResourceWithStreamingResponse: + def __init__(self, zone_tags: ZoneTagsResource) -> None: + self._zone_tags = zone_tags + + self.update = to_streamed_response_wrapper( + zone_tags.update, + ) + self.delete = to_streamed_response_wrapper( + zone_tags.delete, + ) + self.get = to_streamed_response_wrapper( + zone_tags.get, + ) + + +class AsyncZoneTagsResourceWithStreamingResponse: + def __init__(self, zone_tags: AsyncZoneTagsResource) -> None: + self._zone_tags = zone_tags + + self.update = async_to_streamed_response_wrapper( + zone_tags.update, + ) + self.delete = async_to_streamed_response_wrapper( + zone_tags.delete, + ) + self.get = async_to_streamed_response_wrapper( + zone_tags.get, + ) diff --git a/src/cloudflare/types/resource_tagging/__init__.py b/src/cloudflare/types/resource_tagging/__init__.py new file mode 100644 index 00000000000..35b85d44a3b --- /dev/null +++ b/src/cloudflare/types/resource_tagging/__init__.py @@ -0,0 +1,18 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .key_list_params import KeyListParams as KeyListParams +from .key_list_response import KeyListResponse as KeyListResponse +from .value_list_params import ValueListParams as ValueListParams +from .value_list_response import ValueListResponse as ValueListResponse +from .zone_tag_get_params import ZoneTagGetParams as ZoneTagGetParams +from .zone_tag_get_response import ZoneTagGetResponse as ZoneTagGetResponse +from .account_tag_get_params import AccountTagGetParams as AccountTagGetParams +from .zone_tag_update_params import ZoneTagUpdateParams as ZoneTagUpdateParams +from .account_tag_get_response import AccountTagGetResponse as AccountTagGetResponse +from .zone_tag_update_response import ZoneTagUpdateResponse as ZoneTagUpdateResponse +from .account_tag_update_params import AccountTagUpdateParams as AccountTagUpdateParams +from .account_tag_update_response import AccountTagUpdateResponse as AccountTagUpdateResponse +from .resource_tagging_list_params import ResourceTaggingListParams as ResourceTaggingListParams +from .resource_tagging_list_response import ResourceTaggingListResponse as ResourceTaggingListResponse diff --git a/src/cloudflare/types/resource_tagging/account_tag_get_params.py b/src/cloudflare/types/resource_tagging/account_tag_get_params.py new file mode 100644 index 00000000000..7a0340f55ab --- /dev/null +++ b/src/cloudflare/types/resource_tagging/account_tag_get_params.py @@ -0,0 +1,44 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["AccountTagGetParams"] + + +class AccountTagGetParams(TypedDict, total=False): + account_id: Required[str] + """Identifier.""" + + resource_id: Required[str] + """The ID of the resource to retrieve tags for.""" + + resource_type: Required[ + Literal[ + "access_application", + "access_group", + "account", + "ai_gateway", + "alerting_policy", + "alerting_webhook", + "cloudflared_tunnel", + "d1_database", + "durable_object_namespace", + "gateway_list", + "gateway_rule", + "image", + "kv_namespace", + "queue", + "r2_bucket", + "resource_share", + "stream_live_input", + "stream_video", + "worker", + "worker_version", + ] + ] + """The type of the resource.""" + + worker_id: str + """Worker identifier. Required for worker_version resources.""" diff --git a/src/cloudflare/types/resource_tagging/account_tag_get_response.py b/src/cloudflare/types/resource_tagging/account_tag_get_response.py new file mode 100644 index 00000000000..ea42615d755 --- /dev/null +++ b/src/cloudflare/types/resource_tagging/account_tag_get_response.py @@ -0,0 +1,747 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, Union +from typing_extensions import Literal, Annotated, TypeAlias + +from ..._utils import PropertyInfo +from ..._models import BaseModel + +__all__ = [ + "AccountTagGetResponse", + "ResourceTaggingTaggedResourceObjectAccessApplication", + "ResourceTaggingTaggedResourceObjectAccessApplicationPolicy", + "ResourceTaggingTaggedResourceObjectAccessGroup", + "ResourceTaggingTaggedResourceObjectAccount", + "ResourceTaggingTaggedResourceObjectAIGateway", + "ResourceTaggingTaggedResourceObjectAlertingPolicy", + "ResourceTaggingTaggedResourceObjectAlertingWebhook", + "ResourceTaggingTaggedResourceObjectAPIGatewayOperation", + "ResourceTaggingTaggedResourceObjectCloudflaredTunnel", + "ResourceTaggingTaggedResourceObjectCustomCertificate", + "ResourceTaggingTaggedResourceObjectCustomHostname", + "ResourceTaggingTaggedResourceObjectD1Database", + "ResourceTaggingTaggedResourceObjectDNSRecord", + "ResourceTaggingTaggedResourceObjectDurableObjectNamespace", + "ResourceTaggingTaggedResourceObjectGatewayList", + "ResourceTaggingTaggedResourceObjectGatewayRule", + "ResourceTaggingTaggedResourceObjectImage", + "ResourceTaggingTaggedResourceObjectKVNamespace", + "ResourceTaggingTaggedResourceObjectManagedClientCertificate", + "ResourceTaggingTaggedResourceObjectQueue", + "ResourceTaggingTaggedResourceObjectR2Bucket", + "ResourceTaggingTaggedResourceObjectResourceShare", + "ResourceTaggingTaggedResourceObjectStreamLiveInput", + "ResourceTaggingTaggedResourceObjectStreamVideo", + "ResourceTaggingTaggedResourceObjectWorker", + "ResourceTaggingTaggedResourceObjectWorkerVersion", + "ResourceTaggingTaggedResourceObjectZone", +] + + +class ResourceTaggingTaggedResourceObjectAccessApplication(BaseModel): + """Response for access_application resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["access_application"] + + +class ResourceTaggingTaggedResourceObjectAccessApplicationPolicy(BaseModel): + """Response for access_application_policy resources""" + + id: str + """Identifies the unique resource.""" + + access_application_id: str + """Access application ID is required only for access_application_policy resources""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["access_application_policy"] + + zone_id: str + """Zone ID is required only for zone-level resources""" + + +class ResourceTaggingTaggedResourceObjectAccessGroup(BaseModel): + """Response for access_group resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["access_group"] + + +class ResourceTaggingTaggedResourceObjectAccount(BaseModel): + """Response for account resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["account"] + + +class ResourceTaggingTaggedResourceObjectAIGateway(BaseModel): + """Response for ai_gateway resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["ai_gateway"] + + +class ResourceTaggingTaggedResourceObjectAlertingPolicy(BaseModel): + """Response for alerting_policy resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["alerting_policy"] + + +class ResourceTaggingTaggedResourceObjectAlertingWebhook(BaseModel): + """Response for alerting_webhook resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["alerting_webhook"] + + +class ResourceTaggingTaggedResourceObjectAPIGatewayOperation(BaseModel): + """Response for api_gateway_operation resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["api_gateway_operation"] + + zone_id: str + """Zone ID is required only for zone-level resources""" + + +class ResourceTaggingTaggedResourceObjectCloudflaredTunnel(BaseModel): + """Response for cloudflared_tunnel resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["cloudflared_tunnel"] + + +class ResourceTaggingTaggedResourceObjectCustomCertificate(BaseModel): + """Response for custom_certificate resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["custom_certificate"] + + zone_id: str + """Zone ID is required only for zone-level resources""" + + +class ResourceTaggingTaggedResourceObjectCustomHostname(BaseModel): + """Response for custom_hostname resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["custom_hostname"] + + zone_id: str + """Zone ID is required only for zone-level resources""" + + +class ResourceTaggingTaggedResourceObjectD1Database(BaseModel): + """Response for d1_database resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["d1_database"] + + +class ResourceTaggingTaggedResourceObjectDNSRecord(BaseModel): + """Response for dns_record resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["dns_record"] + + zone_id: str + """Zone ID is required only for zone-level resources""" + + +class ResourceTaggingTaggedResourceObjectDurableObjectNamespace(BaseModel): + """Response for durable_object_namespace resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["durable_object_namespace"] + + +class ResourceTaggingTaggedResourceObjectGatewayList(BaseModel): + """Response for gateway_list resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["gateway_list"] + + +class ResourceTaggingTaggedResourceObjectGatewayRule(BaseModel): + """Response for gateway_rule resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["gateway_rule"] + + +class ResourceTaggingTaggedResourceObjectImage(BaseModel): + """Response for image resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["image"] + + +class ResourceTaggingTaggedResourceObjectKVNamespace(BaseModel): + """Response for kv_namespace resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["kv_namespace"] + + +class ResourceTaggingTaggedResourceObjectManagedClientCertificate(BaseModel): + """Response for managed_client_certificate resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["managed_client_certificate"] + + zone_id: str + """Zone ID is required only for zone-level resources""" + + +class ResourceTaggingTaggedResourceObjectQueue(BaseModel): + """Response for queue resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["queue"] + + +class ResourceTaggingTaggedResourceObjectR2Bucket(BaseModel): + """Response for r2_bucket resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["r2_bucket"] + + +class ResourceTaggingTaggedResourceObjectResourceShare(BaseModel): + """Response for resource_share resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["resource_share"] + + +class ResourceTaggingTaggedResourceObjectStreamLiveInput(BaseModel): + """Response for stream_live_input resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["stream_live_input"] + + +class ResourceTaggingTaggedResourceObjectStreamVideo(BaseModel): + """Response for stream_video resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["stream_video"] + + +class ResourceTaggingTaggedResourceObjectWorker(BaseModel): + """Response for worker resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["worker"] + + +class ResourceTaggingTaggedResourceObjectWorkerVersion(BaseModel): + """Response for worker_version resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["worker_version"] + + worker_id: str + """Worker ID is required only for worker_version resources""" + + +class ResourceTaggingTaggedResourceObjectZone(BaseModel): + """Response for zone resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["zone"] + + zone_id: str + """Zone ID is required only for zone-level resources""" + + +AccountTagGetResponse: TypeAlias = Annotated[ + Union[ + ResourceTaggingTaggedResourceObjectAccessApplication, + ResourceTaggingTaggedResourceObjectAccessApplicationPolicy, + ResourceTaggingTaggedResourceObjectAccessGroup, + ResourceTaggingTaggedResourceObjectAccount, + ResourceTaggingTaggedResourceObjectAIGateway, + ResourceTaggingTaggedResourceObjectAlertingPolicy, + ResourceTaggingTaggedResourceObjectAlertingWebhook, + ResourceTaggingTaggedResourceObjectAPIGatewayOperation, + ResourceTaggingTaggedResourceObjectCloudflaredTunnel, + ResourceTaggingTaggedResourceObjectCustomCertificate, + ResourceTaggingTaggedResourceObjectCustomHostname, + ResourceTaggingTaggedResourceObjectD1Database, + ResourceTaggingTaggedResourceObjectDNSRecord, + ResourceTaggingTaggedResourceObjectDurableObjectNamespace, + ResourceTaggingTaggedResourceObjectGatewayList, + ResourceTaggingTaggedResourceObjectGatewayRule, + ResourceTaggingTaggedResourceObjectImage, + ResourceTaggingTaggedResourceObjectKVNamespace, + ResourceTaggingTaggedResourceObjectManagedClientCertificate, + ResourceTaggingTaggedResourceObjectQueue, + ResourceTaggingTaggedResourceObjectR2Bucket, + ResourceTaggingTaggedResourceObjectResourceShare, + ResourceTaggingTaggedResourceObjectStreamLiveInput, + ResourceTaggingTaggedResourceObjectStreamVideo, + ResourceTaggingTaggedResourceObjectWorker, + ResourceTaggingTaggedResourceObjectWorkerVersion, + ResourceTaggingTaggedResourceObjectZone, + ], + PropertyInfo(discriminator="type"), +] diff --git a/src/cloudflare/types/resource_tagging/account_tag_update_params.py b/src/cloudflare/types/resource_tagging/account_tag_update_params.py new file mode 100644 index 00000000000..1fb41f29a2a --- /dev/null +++ b/src/cloudflare/types/resource_tagging/account_tag_update_params.py @@ -0,0 +1,105 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict, Union +from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict + +from ..._utils import PropertyInfo + +__all__ = [ + "AccountTagUpdateParams", + "ResourceTaggingSetTagsRequestAccountLevelWorkerVersion", + "ResourceTaggingSetTagsRequestAccountLevelBase", +] + + +class ResourceTaggingSetTagsRequestAccountLevelWorkerVersion(TypedDict, total=False): + account_id: Required[str] + """Identifier.""" + + resource_id: Required[str] + """Identifies the unique resource.""" + + resource_type: Required[ + Literal[ + "access_application", + "access_group", + "account", + "ai_gateway", + "alerting_policy", + "alerting_webhook", + "cloudflared_tunnel", + "d1_database", + "durable_object_namespace", + "gateway_list", + "gateway_rule", + "image", + "kv_namespace", + "queue", + "r2_bucket", + "resource_share", + "stream_live_input", + "stream_video", + "worker", + "worker_version", + ] + ] + """ + Enum for base account-level resource types (those with no extra required + fields). + """ + + worker_id: Required[str] + """Worker ID is required only for worker_version resources""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + if_match: Annotated[str, PropertyInfo(alias="If-Match")] + + +class ResourceTaggingSetTagsRequestAccountLevelBase(TypedDict, total=False): + account_id: Required[str] + """Identifier.""" + + resource_id: Required[str] + """Identifies the unique resource.""" + + resource_type: Required[ + Literal[ + "access_application", + "access_group", + "account", + "ai_gateway", + "alerting_policy", + "alerting_webhook", + "cloudflared_tunnel", + "d1_database", + "durable_object_namespace", + "gateway_list", + "gateway_rule", + "image", + "kv_namespace", + "queue", + "r2_bucket", + "resource_share", + "stream_live_input", + "stream_video", + "worker", + ] + ] + """ + Enum for base account-level resource types (those with no extra required + fields). + """ + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + if_match: Annotated[str, PropertyInfo(alias="If-Match")] + + +AccountTagUpdateParams: TypeAlias = Union[ + ResourceTaggingSetTagsRequestAccountLevelWorkerVersion, ResourceTaggingSetTagsRequestAccountLevelBase +] diff --git a/src/cloudflare/types/resource_tagging/account_tag_update_response.py b/src/cloudflare/types/resource_tagging/account_tag_update_response.py new file mode 100644 index 00000000000..77d06d6ed2b --- /dev/null +++ b/src/cloudflare/types/resource_tagging/account_tag_update_response.py @@ -0,0 +1,747 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, Union +from typing_extensions import Literal, Annotated, TypeAlias + +from ..._utils import PropertyInfo +from ..._models import BaseModel + +__all__ = [ + "AccountTagUpdateResponse", + "ResourceTaggingTaggedResourceObjectAccessApplication", + "ResourceTaggingTaggedResourceObjectAccessApplicationPolicy", + "ResourceTaggingTaggedResourceObjectAccessGroup", + "ResourceTaggingTaggedResourceObjectAccount", + "ResourceTaggingTaggedResourceObjectAIGateway", + "ResourceTaggingTaggedResourceObjectAlertingPolicy", + "ResourceTaggingTaggedResourceObjectAlertingWebhook", + "ResourceTaggingTaggedResourceObjectAPIGatewayOperation", + "ResourceTaggingTaggedResourceObjectCloudflaredTunnel", + "ResourceTaggingTaggedResourceObjectCustomCertificate", + "ResourceTaggingTaggedResourceObjectCustomHostname", + "ResourceTaggingTaggedResourceObjectD1Database", + "ResourceTaggingTaggedResourceObjectDNSRecord", + "ResourceTaggingTaggedResourceObjectDurableObjectNamespace", + "ResourceTaggingTaggedResourceObjectGatewayList", + "ResourceTaggingTaggedResourceObjectGatewayRule", + "ResourceTaggingTaggedResourceObjectImage", + "ResourceTaggingTaggedResourceObjectKVNamespace", + "ResourceTaggingTaggedResourceObjectManagedClientCertificate", + "ResourceTaggingTaggedResourceObjectQueue", + "ResourceTaggingTaggedResourceObjectR2Bucket", + "ResourceTaggingTaggedResourceObjectResourceShare", + "ResourceTaggingTaggedResourceObjectStreamLiveInput", + "ResourceTaggingTaggedResourceObjectStreamVideo", + "ResourceTaggingTaggedResourceObjectWorker", + "ResourceTaggingTaggedResourceObjectWorkerVersion", + "ResourceTaggingTaggedResourceObjectZone", +] + + +class ResourceTaggingTaggedResourceObjectAccessApplication(BaseModel): + """Response for access_application resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["access_application"] + + +class ResourceTaggingTaggedResourceObjectAccessApplicationPolicy(BaseModel): + """Response for access_application_policy resources""" + + id: str + """Identifies the unique resource.""" + + access_application_id: str + """Access application ID is required only for access_application_policy resources""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["access_application_policy"] + + zone_id: str + """Zone ID is required only for zone-level resources""" + + +class ResourceTaggingTaggedResourceObjectAccessGroup(BaseModel): + """Response for access_group resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["access_group"] + + +class ResourceTaggingTaggedResourceObjectAccount(BaseModel): + """Response for account resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["account"] + + +class ResourceTaggingTaggedResourceObjectAIGateway(BaseModel): + """Response for ai_gateway resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["ai_gateway"] + + +class ResourceTaggingTaggedResourceObjectAlertingPolicy(BaseModel): + """Response for alerting_policy resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["alerting_policy"] + + +class ResourceTaggingTaggedResourceObjectAlertingWebhook(BaseModel): + """Response for alerting_webhook resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["alerting_webhook"] + + +class ResourceTaggingTaggedResourceObjectAPIGatewayOperation(BaseModel): + """Response for api_gateway_operation resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["api_gateway_operation"] + + zone_id: str + """Zone ID is required only for zone-level resources""" + + +class ResourceTaggingTaggedResourceObjectCloudflaredTunnel(BaseModel): + """Response for cloudflared_tunnel resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["cloudflared_tunnel"] + + +class ResourceTaggingTaggedResourceObjectCustomCertificate(BaseModel): + """Response for custom_certificate resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["custom_certificate"] + + zone_id: str + """Zone ID is required only for zone-level resources""" + + +class ResourceTaggingTaggedResourceObjectCustomHostname(BaseModel): + """Response for custom_hostname resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["custom_hostname"] + + zone_id: str + """Zone ID is required only for zone-level resources""" + + +class ResourceTaggingTaggedResourceObjectD1Database(BaseModel): + """Response for d1_database resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["d1_database"] + + +class ResourceTaggingTaggedResourceObjectDNSRecord(BaseModel): + """Response for dns_record resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["dns_record"] + + zone_id: str + """Zone ID is required only for zone-level resources""" + + +class ResourceTaggingTaggedResourceObjectDurableObjectNamespace(BaseModel): + """Response for durable_object_namespace resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["durable_object_namespace"] + + +class ResourceTaggingTaggedResourceObjectGatewayList(BaseModel): + """Response for gateway_list resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["gateway_list"] + + +class ResourceTaggingTaggedResourceObjectGatewayRule(BaseModel): + """Response for gateway_rule resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["gateway_rule"] + + +class ResourceTaggingTaggedResourceObjectImage(BaseModel): + """Response for image resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["image"] + + +class ResourceTaggingTaggedResourceObjectKVNamespace(BaseModel): + """Response for kv_namespace resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["kv_namespace"] + + +class ResourceTaggingTaggedResourceObjectManagedClientCertificate(BaseModel): + """Response for managed_client_certificate resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["managed_client_certificate"] + + zone_id: str + """Zone ID is required only for zone-level resources""" + + +class ResourceTaggingTaggedResourceObjectQueue(BaseModel): + """Response for queue resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["queue"] + + +class ResourceTaggingTaggedResourceObjectR2Bucket(BaseModel): + """Response for r2_bucket resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["r2_bucket"] + + +class ResourceTaggingTaggedResourceObjectResourceShare(BaseModel): + """Response for resource_share resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["resource_share"] + + +class ResourceTaggingTaggedResourceObjectStreamLiveInput(BaseModel): + """Response for stream_live_input resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["stream_live_input"] + + +class ResourceTaggingTaggedResourceObjectStreamVideo(BaseModel): + """Response for stream_video resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["stream_video"] + + +class ResourceTaggingTaggedResourceObjectWorker(BaseModel): + """Response for worker resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["worker"] + + +class ResourceTaggingTaggedResourceObjectWorkerVersion(BaseModel): + """Response for worker_version resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["worker_version"] + + worker_id: str + """Worker ID is required only for worker_version resources""" + + +class ResourceTaggingTaggedResourceObjectZone(BaseModel): + """Response for zone resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["zone"] + + zone_id: str + """Zone ID is required only for zone-level resources""" + + +AccountTagUpdateResponse: TypeAlias = Annotated[ + Union[ + ResourceTaggingTaggedResourceObjectAccessApplication, + ResourceTaggingTaggedResourceObjectAccessApplicationPolicy, + ResourceTaggingTaggedResourceObjectAccessGroup, + ResourceTaggingTaggedResourceObjectAccount, + ResourceTaggingTaggedResourceObjectAIGateway, + ResourceTaggingTaggedResourceObjectAlertingPolicy, + ResourceTaggingTaggedResourceObjectAlertingWebhook, + ResourceTaggingTaggedResourceObjectAPIGatewayOperation, + ResourceTaggingTaggedResourceObjectCloudflaredTunnel, + ResourceTaggingTaggedResourceObjectCustomCertificate, + ResourceTaggingTaggedResourceObjectCustomHostname, + ResourceTaggingTaggedResourceObjectD1Database, + ResourceTaggingTaggedResourceObjectDNSRecord, + ResourceTaggingTaggedResourceObjectDurableObjectNamespace, + ResourceTaggingTaggedResourceObjectGatewayList, + ResourceTaggingTaggedResourceObjectGatewayRule, + ResourceTaggingTaggedResourceObjectImage, + ResourceTaggingTaggedResourceObjectKVNamespace, + ResourceTaggingTaggedResourceObjectManagedClientCertificate, + ResourceTaggingTaggedResourceObjectQueue, + ResourceTaggingTaggedResourceObjectR2Bucket, + ResourceTaggingTaggedResourceObjectResourceShare, + ResourceTaggingTaggedResourceObjectStreamLiveInput, + ResourceTaggingTaggedResourceObjectStreamVideo, + ResourceTaggingTaggedResourceObjectWorker, + ResourceTaggingTaggedResourceObjectWorkerVersion, + ResourceTaggingTaggedResourceObjectZone, + ], + PropertyInfo(discriminator="type"), +] diff --git a/src/cloudflare/types/resource_tagging/key_list_params.py b/src/cloudflare/types/resource_tagging/key_list_params.py new file mode 100644 index 00000000000..3511a00e252 --- /dev/null +++ b/src/cloudflare/types/resource_tagging/key_list_params.py @@ -0,0 +1,15 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["KeyListParams"] + + +class KeyListParams(TypedDict, total=False): + account_id: Required[str] + """Identifier.""" + + cursor: str + """Cursor for pagination.""" diff --git a/src/cloudflare/types/resource_tagging/key_list_response.py b/src/cloudflare/types/resource_tagging/key_list_response.py new file mode 100644 index 00000000000..2c54f926ce4 --- /dev/null +++ b/src/cloudflare/types/resource_tagging/key_list_response.py @@ -0,0 +1,7 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing_extensions import TypeAlias + +__all__ = ["KeyListResponse"] + +KeyListResponse: TypeAlias = str diff --git a/src/cloudflare/types/resource_tagging/resource_tagging_list_params.py b/src/cloudflare/types/resource_tagging/resource_tagging_list_params.py new file mode 100644 index 00000000000..ed7e4758489 --- /dev/null +++ b/src/cloudflare/types/resource_tagging/resource_tagging_list_params.py @@ -0,0 +1,77 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List +from typing_extensions import Literal, Required, TypedDict + +from ..._types import SequenceNotStr + +__all__ = ["ResourceTaggingListParams"] + + +class ResourceTaggingListParams(TypedDict, total=False): + account_id: Required[str] + """Identifier.""" + + cursor: str + """Cursor for pagination.""" + + tag: SequenceNotStr[str] + """Filter resources by tag criteria. + + This parameter can be repeated multiple times, with AND logic between + parameters. + + Supported syntax: + + - **Key-only**: `tag=` - Resource must have the tag key (e.g., + `tag=production`) + - **Key-value**: `tag==` - Resource must have the tag with specific + value (e.g., `tag=env=prod`) + - **Multiple values (OR)**: `tag==,` - Resource must have tag with + any of the values (e.g., `tag=env=prod,staging`) + - **Negate key-only**: `tag=!` - Resource must not have the tag key (e.g., + `tag=!archived`) + - **Negate key-value**: `tag=!=` - Resource must not have the tag + with specific value (e.g., `tag=region!=us-west-1`) + + Multiple tag parameters are combined with AND logic. + """ + + type: List[ + Literal[ + "access_application", + "access_application_policy", + "access_group", + "account", + "ai_gateway", + "alerting_policy", + "alerting_webhook", + "api_gateway_operation", + "cloudflared_tunnel", + "custom_certificate", + "custom_hostname", + "d1_database", + "dns_record", + "durable_object_namespace", + "gateway_list", + "gateway_rule", + "image", + "kv_namespace", + "managed_client_certificate", + "queue", + "r2_bucket", + "resource_share", + "stream_live_input", + "stream_video", + "worker", + "worker_version", + "zone", + ] + ] + """Filter by resource type. + + Can be repeated to filter by multiple types (OR logic). Example: + ?type=zone&type=worker + """ diff --git a/src/cloudflare/types/resource_tagging/resource_tagging_list_response.py b/src/cloudflare/types/resource_tagging/resource_tagging_list_response.py new file mode 100644 index 00000000000..c6015538be0 --- /dev/null +++ b/src/cloudflare/types/resource_tagging/resource_tagging_list_response.py @@ -0,0 +1,747 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, Union +from typing_extensions import Literal, Annotated, TypeAlias + +from ..._utils import PropertyInfo +from ..._models import BaseModel + +__all__ = [ + "ResourceTaggingListResponse", + "ResourceTaggingTaggedResourceObjectAccessApplication", + "ResourceTaggingTaggedResourceObjectAccessApplicationPolicy", + "ResourceTaggingTaggedResourceObjectAccessGroup", + "ResourceTaggingTaggedResourceObjectAccount", + "ResourceTaggingTaggedResourceObjectAIGateway", + "ResourceTaggingTaggedResourceObjectAlertingPolicy", + "ResourceTaggingTaggedResourceObjectAlertingWebhook", + "ResourceTaggingTaggedResourceObjectAPIGatewayOperation", + "ResourceTaggingTaggedResourceObjectCloudflaredTunnel", + "ResourceTaggingTaggedResourceObjectCustomCertificate", + "ResourceTaggingTaggedResourceObjectCustomHostname", + "ResourceTaggingTaggedResourceObjectD1Database", + "ResourceTaggingTaggedResourceObjectDNSRecord", + "ResourceTaggingTaggedResourceObjectDurableObjectNamespace", + "ResourceTaggingTaggedResourceObjectGatewayList", + "ResourceTaggingTaggedResourceObjectGatewayRule", + "ResourceTaggingTaggedResourceObjectImage", + "ResourceTaggingTaggedResourceObjectKVNamespace", + "ResourceTaggingTaggedResourceObjectManagedClientCertificate", + "ResourceTaggingTaggedResourceObjectQueue", + "ResourceTaggingTaggedResourceObjectR2Bucket", + "ResourceTaggingTaggedResourceObjectResourceShare", + "ResourceTaggingTaggedResourceObjectStreamLiveInput", + "ResourceTaggingTaggedResourceObjectStreamVideo", + "ResourceTaggingTaggedResourceObjectWorker", + "ResourceTaggingTaggedResourceObjectWorkerVersion", + "ResourceTaggingTaggedResourceObjectZone", +] + + +class ResourceTaggingTaggedResourceObjectAccessApplication(BaseModel): + """Response for access_application resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["access_application"] + + +class ResourceTaggingTaggedResourceObjectAccessApplicationPolicy(BaseModel): + """Response for access_application_policy resources""" + + id: str + """Identifies the unique resource.""" + + access_application_id: str + """Access application ID is required only for access_application_policy resources""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["access_application_policy"] + + zone_id: str + """Zone ID is required only for zone-level resources""" + + +class ResourceTaggingTaggedResourceObjectAccessGroup(BaseModel): + """Response for access_group resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["access_group"] + + +class ResourceTaggingTaggedResourceObjectAccount(BaseModel): + """Response for account resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["account"] + + +class ResourceTaggingTaggedResourceObjectAIGateway(BaseModel): + """Response for ai_gateway resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["ai_gateway"] + + +class ResourceTaggingTaggedResourceObjectAlertingPolicy(BaseModel): + """Response for alerting_policy resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["alerting_policy"] + + +class ResourceTaggingTaggedResourceObjectAlertingWebhook(BaseModel): + """Response for alerting_webhook resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["alerting_webhook"] + + +class ResourceTaggingTaggedResourceObjectAPIGatewayOperation(BaseModel): + """Response for api_gateway_operation resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["api_gateway_operation"] + + zone_id: str + """Zone ID is required only for zone-level resources""" + + +class ResourceTaggingTaggedResourceObjectCloudflaredTunnel(BaseModel): + """Response for cloudflared_tunnel resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["cloudflared_tunnel"] + + +class ResourceTaggingTaggedResourceObjectCustomCertificate(BaseModel): + """Response for custom_certificate resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["custom_certificate"] + + zone_id: str + """Zone ID is required only for zone-level resources""" + + +class ResourceTaggingTaggedResourceObjectCustomHostname(BaseModel): + """Response for custom_hostname resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["custom_hostname"] + + zone_id: str + """Zone ID is required only for zone-level resources""" + + +class ResourceTaggingTaggedResourceObjectD1Database(BaseModel): + """Response for d1_database resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["d1_database"] + + +class ResourceTaggingTaggedResourceObjectDNSRecord(BaseModel): + """Response for dns_record resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["dns_record"] + + zone_id: str + """Zone ID is required only for zone-level resources""" + + +class ResourceTaggingTaggedResourceObjectDurableObjectNamespace(BaseModel): + """Response for durable_object_namespace resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["durable_object_namespace"] + + +class ResourceTaggingTaggedResourceObjectGatewayList(BaseModel): + """Response for gateway_list resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["gateway_list"] + + +class ResourceTaggingTaggedResourceObjectGatewayRule(BaseModel): + """Response for gateway_rule resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["gateway_rule"] + + +class ResourceTaggingTaggedResourceObjectImage(BaseModel): + """Response for image resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["image"] + + +class ResourceTaggingTaggedResourceObjectKVNamespace(BaseModel): + """Response for kv_namespace resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["kv_namespace"] + + +class ResourceTaggingTaggedResourceObjectManagedClientCertificate(BaseModel): + """Response for managed_client_certificate resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["managed_client_certificate"] + + zone_id: str + """Zone ID is required only for zone-level resources""" + + +class ResourceTaggingTaggedResourceObjectQueue(BaseModel): + """Response for queue resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["queue"] + + +class ResourceTaggingTaggedResourceObjectR2Bucket(BaseModel): + """Response for r2_bucket resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["r2_bucket"] + + +class ResourceTaggingTaggedResourceObjectResourceShare(BaseModel): + """Response for resource_share resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["resource_share"] + + +class ResourceTaggingTaggedResourceObjectStreamLiveInput(BaseModel): + """Response for stream_live_input resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["stream_live_input"] + + +class ResourceTaggingTaggedResourceObjectStreamVideo(BaseModel): + """Response for stream_video resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["stream_video"] + + +class ResourceTaggingTaggedResourceObjectWorker(BaseModel): + """Response for worker resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["worker"] + + +class ResourceTaggingTaggedResourceObjectWorkerVersion(BaseModel): + """Response for worker_version resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["worker_version"] + + worker_id: str + """Worker ID is required only for worker_version resources""" + + +class ResourceTaggingTaggedResourceObjectZone(BaseModel): + """Response for zone resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["zone"] + + zone_id: str + """Zone ID is required only for zone-level resources""" + + +ResourceTaggingListResponse: TypeAlias = Annotated[ + Union[ + ResourceTaggingTaggedResourceObjectAccessApplication, + ResourceTaggingTaggedResourceObjectAccessApplicationPolicy, + ResourceTaggingTaggedResourceObjectAccessGroup, + ResourceTaggingTaggedResourceObjectAccount, + ResourceTaggingTaggedResourceObjectAIGateway, + ResourceTaggingTaggedResourceObjectAlertingPolicy, + ResourceTaggingTaggedResourceObjectAlertingWebhook, + ResourceTaggingTaggedResourceObjectAPIGatewayOperation, + ResourceTaggingTaggedResourceObjectCloudflaredTunnel, + ResourceTaggingTaggedResourceObjectCustomCertificate, + ResourceTaggingTaggedResourceObjectCustomHostname, + ResourceTaggingTaggedResourceObjectD1Database, + ResourceTaggingTaggedResourceObjectDNSRecord, + ResourceTaggingTaggedResourceObjectDurableObjectNamespace, + ResourceTaggingTaggedResourceObjectGatewayList, + ResourceTaggingTaggedResourceObjectGatewayRule, + ResourceTaggingTaggedResourceObjectImage, + ResourceTaggingTaggedResourceObjectKVNamespace, + ResourceTaggingTaggedResourceObjectManagedClientCertificate, + ResourceTaggingTaggedResourceObjectQueue, + ResourceTaggingTaggedResourceObjectR2Bucket, + ResourceTaggingTaggedResourceObjectResourceShare, + ResourceTaggingTaggedResourceObjectStreamLiveInput, + ResourceTaggingTaggedResourceObjectStreamVideo, + ResourceTaggingTaggedResourceObjectWorker, + ResourceTaggingTaggedResourceObjectWorkerVersion, + ResourceTaggingTaggedResourceObjectZone, + ], + PropertyInfo(discriminator="type"), +] diff --git a/src/cloudflare/types/resource_tagging/value_list_params.py b/src/cloudflare/types/resource_tagging/value_list_params.py new file mode 100644 index 00000000000..f154de3a39c --- /dev/null +++ b/src/cloudflare/types/resource_tagging/value_list_params.py @@ -0,0 +1,46 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["ValueListParams"] + + +class ValueListParams(TypedDict, total=False): + account_id: Required[str] + """Identifier.""" + + cursor: str + """Cursor for pagination.""" + + type: Literal[ + "access_application", + "access_application_policy", + "access_group", + "account", + "ai_gateway", + "alerting_policy", + "alerting_webhook", + "api_gateway_operation", + "cloudflared_tunnel", + "custom_certificate", + "custom_hostname", + "d1_database", + "dns_record", + "durable_object_namespace", + "gateway_list", + "gateway_rule", + "image", + "kv_namespace", + "managed_client_certificate", + "queue", + "r2_bucket", + "resource_share", + "stream_live_input", + "stream_video", + "worker", + "worker_version", + "zone", + ] + """Filter by resource type.""" diff --git a/src/cloudflare/types/resource_tagging/value_list_response.py b/src/cloudflare/types/resource_tagging/value_list_response.py new file mode 100644 index 00000000000..bd92eaf11e9 --- /dev/null +++ b/src/cloudflare/types/resource_tagging/value_list_response.py @@ -0,0 +1,7 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing_extensions import TypeAlias + +__all__ = ["ValueListResponse"] + +ValueListResponse: TypeAlias = str diff --git a/src/cloudflare/types/resource_tagging/zone_tag_get_params.py b/src/cloudflare/types/resource_tagging/zone_tag_get_params.py new file mode 100644 index 00000000000..41e8fbbbe22 --- /dev/null +++ b/src/cloudflare/types/resource_tagging/zone_tag_get_params.py @@ -0,0 +1,34 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["ZoneTagGetParams"] + + +class ZoneTagGetParams(TypedDict, total=False): + zone_id: Required[str] + """Zone ID is required only for zone-level resources""" + + resource_id: Required[str] + """The ID of the resource to retrieve tags for.""" + + resource_type: Required[ + Literal[ + "access_application_policy", + "api_gateway_operation", + "custom_certificate", + "custom_hostname", + "dns_record", + "managed_client_certificate", + "zone", + ] + ] + """The type of the resource.""" + + access_application_id: str + """Access application ID identifier. + + Required for access_application_policy resources. + """ diff --git a/src/cloudflare/types/resource_tagging/zone_tag_get_response.py b/src/cloudflare/types/resource_tagging/zone_tag_get_response.py new file mode 100644 index 00000000000..d43d1cd4589 --- /dev/null +++ b/src/cloudflare/types/resource_tagging/zone_tag_get_response.py @@ -0,0 +1,747 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, Union +from typing_extensions import Literal, Annotated, TypeAlias + +from ..._utils import PropertyInfo +from ..._models import BaseModel + +__all__ = [ + "ZoneTagGetResponse", + "ResourceTaggingTaggedResourceObjectAccessApplication", + "ResourceTaggingTaggedResourceObjectAccessApplicationPolicy", + "ResourceTaggingTaggedResourceObjectAccessGroup", + "ResourceTaggingTaggedResourceObjectAccount", + "ResourceTaggingTaggedResourceObjectAIGateway", + "ResourceTaggingTaggedResourceObjectAlertingPolicy", + "ResourceTaggingTaggedResourceObjectAlertingWebhook", + "ResourceTaggingTaggedResourceObjectAPIGatewayOperation", + "ResourceTaggingTaggedResourceObjectCloudflaredTunnel", + "ResourceTaggingTaggedResourceObjectCustomCertificate", + "ResourceTaggingTaggedResourceObjectCustomHostname", + "ResourceTaggingTaggedResourceObjectD1Database", + "ResourceTaggingTaggedResourceObjectDNSRecord", + "ResourceTaggingTaggedResourceObjectDurableObjectNamespace", + "ResourceTaggingTaggedResourceObjectGatewayList", + "ResourceTaggingTaggedResourceObjectGatewayRule", + "ResourceTaggingTaggedResourceObjectImage", + "ResourceTaggingTaggedResourceObjectKVNamespace", + "ResourceTaggingTaggedResourceObjectManagedClientCertificate", + "ResourceTaggingTaggedResourceObjectQueue", + "ResourceTaggingTaggedResourceObjectR2Bucket", + "ResourceTaggingTaggedResourceObjectResourceShare", + "ResourceTaggingTaggedResourceObjectStreamLiveInput", + "ResourceTaggingTaggedResourceObjectStreamVideo", + "ResourceTaggingTaggedResourceObjectWorker", + "ResourceTaggingTaggedResourceObjectWorkerVersion", + "ResourceTaggingTaggedResourceObjectZone", +] + + +class ResourceTaggingTaggedResourceObjectAccessApplication(BaseModel): + """Response for access_application resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["access_application"] + + +class ResourceTaggingTaggedResourceObjectAccessApplicationPolicy(BaseModel): + """Response for access_application_policy resources""" + + id: str + """Identifies the unique resource.""" + + access_application_id: str + """Access application ID is required only for access_application_policy resources""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["access_application_policy"] + + zone_id: str + """Zone ID is required only for zone-level resources""" + + +class ResourceTaggingTaggedResourceObjectAccessGroup(BaseModel): + """Response for access_group resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["access_group"] + + +class ResourceTaggingTaggedResourceObjectAccount(BaseModel): + """Response for account resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["account"] + + +class ResourceTaggingTaggedResourceObjectAIGateway(BaseModel): + """Response for ai_gateway resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["ai_gateway"] + + +class ResourceTaggingTaggedResourceObjectAlertingPolicy(BaseModel): + """Response for alerting_policy resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["alerting_policy"] + + +class ResourceTaggingTaggedResourceObjectAlertingWebhook(BaseModel): + """Response for alerting_webhook resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["alerting_webhook"] + + +class ResourceTaggingTaggedResourceObjectAPIGatewayOperation(BaseModel): + """Response for api_gateway_operation resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["api_gateway_operation"] + + zone_id: str + """Zone ID is required only for zone-level resources""" + + +class ResourceTaggingTaggedResourceObjectCloudflaredTunnel(BaseModel): + """Response for cloudflared_tunnel resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["cloudflared_tunnel"] + + +class ResourceTaggingTaggedResourceObjectCustomCertificate(BaseModel): + """Response for custom_certificate resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["custom_certificate"] + + zone_id: str + """Zone ID is required only for zone-level resources""" + + +class ResourceTaggingTaggedResourceObjectCustomHostname(BaseModel): + """Response for custom_hostname resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["custom_hostname"] + + zone_id: str + """Zone ID is required only for zone-level resources""" + + +class ResourceTaggingTaggedResourceObjectD1Database(BaseModel): + """Response for d1_database resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["d1_database"] + + +class ResourceTaggingTaggedResourceObjectDNSRecord(BaseModel): + """Response for dns_record resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["dns_record"] + + zone_id: str + """Zone ID is required only for zone-level resources""" + + +class ResourceTaggingTaggedResourceObjectDurableObjectNamespace(BaseModel): + """Response for durable_object_namespace resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["durable_object_namespace"] + + +class ResourceTaggingTaggedResourceObjectGatewayList(BaseModel): + """Response for gateway_list resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["gateway_list"] + + +class ResourceTaggingTaggedResourceObjectGatewayRule(BaseModel): + """Response for gateway_rule resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["gateway_rule"] + + +class ResourceTaggingTaggedResourceObjectImage(BaseModel): + """Response for image resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["image"] + + +class ResourceTaggingTaggedResourceObjectKVNamespace(BaseModel): + """Response for kv_namespace resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["kv_namespace"] + + +class ResourceTaggingTaggedResourceObjectManagedClientCertificate(BaseModel): + """Response for managed_client_certificate resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["managed_client_certificate"] + + zone_id: str + """Zone ID is required only for zone-level resources""" + + +class ResourceTaggingTaggedResourceObjectQueue(BaseModel): + """Response for queue resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["queue"] + + +class ResourceTaggingTaggedResourceObjectR2Bucket(BaseModel): + """Response for r2_bucket resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["r2_bucket"] + + +class ResourceTaggingTaggedResourceObjectResourceShare(BaseModel): + """Response for resource_share resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["resource_share"] + + +class ResourceTaggingTaggedResourceObjectStreamLiveInput(BaseModel): + """Response for stream_live_input resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["stream_live_input"] + + +class ResourceTaggingTaggedResourceObjectStreamVideo(BaseModel): + """Response for stream_video resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["stream_video"] + + +class ResourceTaggingTaggedResourceObjectWorker(BaseModel): + """Response for worker resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["worker"] + + +class ResourceTaggingTaggedResourceObjectWorkerVersion(BaseModel): + """Response for worker_version resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["worker_version"] + + worker_id: str + """Worker ID is required only for worker_version resources""" + + +class ResourceTaggingTaggedResourceObjectZone(BaseModel): + """Response for zone resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["zone"] + + zone_id: str + """Zone ID is required only for zone-level resources""" + + +ZoneTagGetResponse: TypeAlias = Annotated[ + Union[ + ResourceTaggingTaggedResourceObjectAccessApplication, + ResourceTaggingTaggedResourceObjectAccessApplicationPolicy, + ResourceTaggingTaggedResourceObjectAccessGroup, + ResourceTaggingTaggedResourceObjectAccount, + ResourceTaggingTaggedResourceObjectAIGateway, + ResourceTaggingTaggedResourceObjectAlertingPolicy, + ResourceTaggingTaggedResourceObjectAlertingWebhook, + ResourceTaggingTaggedResourceObjectAPIGatewayOperation, + ResourceTaggingTaggedResourceObjectCloudflaredTunnel, + ResourceTaggingTaggedResourceObjectCustomCertificate, + ResourceTaggingTaggedResourceObjectCustomHostname, + ResourceTaggingTaggedResourceObjectD1Database, + ResourceTaggingTaggedResourceObjectDNSRecord, + ResourceTaggingTaggedResourceObjectDurableObjectNamespace, + ResourceTaggingTaggedResourceObjectGatewayList, + ResourceTaggingTaggedResourceObjectGatewayRule, + ResourceTaggingTaggedResourceObjectImage, + ResourceTaggingTaggedResourceObjectKVNamespace, + ResourceTaggingTaggedResourceObjectManagedClientCertificate, + ResourceTaggingTaggedResourceObjectQueue, + ResourceTaggingTaggedResourceObjectR2Bucket, + ResourceTaggingTaggedResourceObjectResourceShare, + ResourceTaggingTaggedResourceObjectStreamLiveInput, + ResourceTaggingTaggedResourceObjectStreamVideo, + ResourceTaggingTaggedResourceObjectWorker, + ResourceTaggingTaggedResourceObjectWorkerVersion, + ResourceTaggingTaggedResourceObjectZone, + ], + PropertyInfo(discriminator="type"), +] diff --git a/src/cloudflare/types/resource_tagging/zone_tag_update_params.py b/src/cloudflare/types/resource_tagging/zone_tag_update_params.py new file mode 100644 index 00000000000..9b9fa8a54fa --- /dev/null +++ b/src/cloudflare/types/resource_tagging/zone_tag_update_params.py @@ -0,0 +1,73 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict, Union +from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict + +from ..._utils import PropertyInfo + +__all__ = [ + "ZoneTagUpdateParams", + "ResourceTaggingSetTagsRequestZoneLevelBase", + "ResourceTaggingSetTagsRequestZoneLevelAccessApplicationPolicy", +] + + +class ResourceTaggingSetTagsRequestZoneLevelBase(TypedDict, total=False): + zone_id: Required[str] + """Zone ID is required only for zone-level resources""" + + resource_id: Required[str] + """Identifies the unique resource.""" + + resource_type: Required[ + Literal[ + "api_gateway_operation", + "custom_certificate", + "custom_hostname", + "dns_record", + "managed_client_certificate", + "zone", + ] + ] + """Enum for base zone-level resource types (those with no extra required fields).""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + if_match: Annotated[str, PropertyInfo(alias="If-Match")] + + +class ResourceTaggingSetTagsRequestZoneLevelAccessApplicationPolicy(TypedDict, total=False): + zone_id: Required[str] + """Zone ID is required only for zone-level resources""" + + access_application_id: Required[str] + """Access application ID is required only for access_application_policy resources""" + + resource_id: Required[str] + """Identifies the unique resource.""" + + resource_type: Required[ + Literal[ + "api_gateway_operation", + "custom_certificate", + "custom_hostname", + "dns_record", + "managed_client_certificate", + "zone", + "access_application_policy", + ] + ] + """Enum for base zone-level resource types (those with no extra required fields).""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + if_match: Annotated[str, PropertyInfo(alias="If-Match")] + + +ZoneTagUpdateParams: TypeAlias = Union[ + ResourceTaggingSetTagsRequestZoneLevelBase, ResourceTaggingSetTagsRequestZoneLevelAccessApplicationPolicy +] diff --git a/src/cloudflare/types/resource_tagging/zone_tag_update_response.py b/src/cloudflare/types/resource_tagging/zone_tag_update_response.py new file mode 100644 index 00000000000..7981847d2f2 --- /dev/null +++ b/src/cloudflare/types/resource_tagging/zone_tag_update_response.py @@ -0,0 +1,747 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, Union +from typing_extensions import Literal, Annotated, TypeAlias + +from ..._utils import PropertyInfo +from ..._models import BaseModel + +__all__ = [ + "ZoneTagUpdateResponse", + "ResourceTaggingTaggedResourceObjectAccessApplication", + "ResourceTaggingTaggedResourceObjectAccessApplicationPolicy", + "ResourceTaggingTaggedResourceObjectAccessGroup", + "ResourceTaggingTaggedResourceObjectAccount", + "ResourceTaggingTaggedResourceObjectAIGateway", + "ResourceTaggingTaggedResourceObjectAlertingPolicy", + "ResourceTaggingTaggedResourceObjectAlertingWebhook", + "ResourceTaggingTaggedResourceObjectAPIGatewayOperation", + "ResourceTaggingTaggedResourceObjectCloudflaredTunnel", + "ResourceTaggingTaggedResourceObjectCustomCertificate", + "ResourceTaggingTaggedResourceObjectCustomHostname", + "ResourceTaggingTaggedResourceObjectD1Database", + "ResourceTaggingTaggedResourceObjectDNSRecord", + "ResourceTaggingTaggedResourceObjectDurableObjectNamespace", + "ResourceTaggingTaggedResourceObjectGatewayList", + "ResourceTaggingTaggedResourceObjectGatewayRule", + "ResourceTaggingTaggedResourceObjectImage", + "ResourceTaggingTaggedResourceObjectKVNamespace", + "ResourceTaggingTaggedResourceObjectManagedClientCertificate", + "ResourceTaggingTaggedResourceObjectQueue", + "ResourceTaggingTaggedResourceObjectR2Bucket", + "ResourceTaggingTaggedResourceObjectResourceShare", + "ResourceTaggingTaggedResourceObjectStreamLiveInput", + "ResourceTaggingTaggedResourceObjectStreamVideo", + "ResourceTaggingTaggedResourceObjectWorker", + "ResourceTaggingTaggedResourceObjectWorkerVersion", + "ResourceTaggingTaggedResourceObjectZone", +] + + +class ResourceTaggingTaggedResourceObjectAccessApplication(BaseModel): + """Response for access_application resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["access_application"] + + +class ResourceTaggingTaggedResourceObjectAccessApplicationPolicy(BaseModel): + """Response for access_application_policy resources""" + + id: str + """Identifies the unique resource.""" + + access_application_id: str + """Access application ID is required only for access_application_policy resources""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["access_application_policy"] + + zone_id: str + """Zone ID is required only for zone-level resources""" + + +class ResourceTaggingTaggedResourceObjectAccessGroup(BaseModel): + """Response for access_group resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["access_group"] + + +class ResourceTaggingTaggedResourceObjectAccount(BaseModel): + """Response for account resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["account"] + + +class ResourceTaggingTaggedResourceObjectAIGateway(BaseModel): + """Response for ai_gateway resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["ai_gateway"] + + +class ResourceTaggingTaggedResourceObjectAlertingPolicy(BaseModel): + """Response for alerting_policy resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["alerting_policy"] + + +class ResourceTaggingTaggedResourceObjectAlertingWebhook(BaseModel): + """Response for alerting_webhook resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["alerting_webhook"] + + +class ResourceTaggingTaggedResourceObjectAPIGatewayOperation(BaseModel): + """Response for api_gateway_operation resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["api_gateway_operation"] + + zone_id: str + """Zone ID is required only for zone-level resources""" + + +class ResourceTaggingTaggedResourceObjectCloudflaredTunnel(BaseModel): + """Response for cloudflared_tunnel resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["cloudflared_tunnel"] + + +class ResourceTaggingTaggedResourceObjectCustomCertificate(BaseModel): + """Response for custom_certificate resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["custom_certificate"] + + zone_id: str + """Zone ID is required only for zone-level resources""" + + +class ResourceTaggingTaggedResourceObjectCustomHostname(BaseModel): + """Response for custom_hostname resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["custom_hostname"] + + zone_id: str + """Zone ID is required only for zone-level resources""" + + +class ResourceTaggingTaggedResourceObjectD1Database(BaseModel): + """Response for d1_database resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["d1_database"] + + +class ResourceTaggingTaggedResourceObjectDNSRecord(BaseModel): + """Response for dns_record resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["dns_record"] + + zone_id: str + """Zone ID is required only for zone-level resources""" + + +class ResourceTaggingTaggedResourceObjectDurableObjectNamespace(BaseModel): + """Response for durable_object_namespace resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["durable_object_namespace"] + + +class ResourceTaggingTaggedResourceObjectGatewayList(BaseModel): + """Response for gateway_list resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["gateway_list"] + + +class ResourceTaggingTaggedResourceObjectGatewayRule(BaseModel): + """Response for gateway_rule resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["gateway_rule"] + + +class ResourceTaggingTaggedResourceObjectImage(BaseModel): + """Response for image resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["image"] + + +class ResourceTaggingTaggedResourceObjectKVNamespace(BaseModel): + """Response for kv_namespace resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["kv_namespace"] + + +class ResourceTaggingTaggedResourceObjectManagedClientCertificate(BaseModel): + """Response for managed_client_certificate resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["managed_client_certificate"] + + zone_id: str + """Zone ID is required only for zone-level resources""" + + +class ResourceTaggingTaggedResourceObjectQueue(BaseModel): + """Response for queue resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["queue"] + + +class ResourceTaggingTaggedResourceObjectR2Bucket(BaseModel): + """Response for r2_bucket resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["r2_bucket"] + + +class ResourceTaggingTaggedResourceObjectResourceShare(BaseModel): + """Response for resource_share resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["resource_share"] + + +class ResourceTaggingTaggedResourceObjectStreamLiveInput(BaseModel): + """Response for stream_live_input resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["stream_live_input"] + + +class ResourceTaggingTaggedResourceObjectStreamVideo(BaseModel): + """Response for stream_video resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["stream_video"] + + +class ResourceTaggingTaggedResourceObjectWorker(BaseModel): + """Response for worker resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["worker"] + + +class ResourceTaggingTaggedResourceObjectWorkerVersion(BaseModel): + """Response for worker_version resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["worker_version"] + + worker_id: str + """Worker ID is required only for worker_version resources""" + + +class ResourceTaggingTaggedResourceObjectZone(BaseModel): + """Response for zone resources""" + + id: str + """Identifies the unique resource.""" + + etag: str + """ETag identifier for optimistic concurrency control. + + Formatted as "v1:" where the hash is the base64url-encoded SHA-256 + (truncated to 128 bits) of the tags map canonicalized using RFC 8785 (JSON + Canonicalization Scheme). Clients should treat ETags as opaque strings and pass + them back via the If-Match header on write operations. + """ + + name: str + """Human-readable name of the resource.""" + + tags: Dict[str, str] + """Contains key-value pairs of tags.""" + + type: Literal["zone"] + + zone_id: str + """Zone ID is required only for zone-level resources""" + + +ZoneTagUpdateResponse: TypeAlias = Annotated[ + Union[ + ResourceTaggingTaggedResourceObjectAccessApplication, + ResourceTaggingTaggedResourceObjectAccessApplicationPolicy, + ResourceTaggingTaggedResourceObjectAccessGroup, + ResourceTaggingTaggedResourceObjectAccount, + ResourceTaggingTaggedResourceObjectAIGateway, + ResourceTaggingTaggedResourceObjectAlertingPolicy, + ResourceTaggingTaggedResourceObjectAlertingWebhook, + ResourceTaggingTaggedResourceObjectAPIGatewayOperation, + ResourceTaggingTaggedResourceObjectCloudflaredTunnel, + ResourceTaggingTaggedResourceObjectCustomCertificate, + ResourceTaggingTaggedResourceObjectCustomHostname, + ResourceTaggingTaggedResourceObjectD1Database, + ResourceTaggingTaggedResourceObjectDNSRecord, + ResourceTaggingTaggedResourceObjectDurableObjectNamespace, + ResourceTaggingTaggedResourceObjectGatewayList, + ResourceTaggingTaggedResourceObjectGatewayRule, + ResourceTaggingTaggedResourceObjectImage, + ResourceTaggingTaggedResourceObjectKVNamespace, + ResourceTaggingTaggedResourceObjectManagedClientCertificate, + ResourceTaggingTaggedResourceObjectQueue, + ResourceTaggingTaggedResourceObjectR2Bucket, + ResourceTaggingTaggedResourceObjectResourceShare, + ResourceTaggingTaggedResourceObjectStreamLiveInput, + ResourceTaggingTaggedResourceObjectStreamVideo, + ResourceTaggingTaggedResourceObjectWorker, + ResourceTaggingTaggedResourceObjectWorkerVersion, + ResourceTaggingTaggedResourceObjectZone, + ], + PropertyInfo(discriminator="type"), +] diff --git a/tests/api_resources/resource_tagging/__init__.py b/tests/api_resources/resource_tagging/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/resource_tagging/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/resource_tagging/test_account_tags.py b/tests/api_resources/resource_tagging/test_account_tags.py new file mode 100644 index 00000000000..9c91463df46 --- /dev/null +++ b/tests/api_resources/resource_tagging/test_account_tags.py @@ -0,0 +1,481 @@ +# 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.types.resource_tagging import ( + AccountTagGetResponse, + AccountTagUpdateResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestAccountTags: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_update_overload_1(self, client: Cloudflare) -> None: + account_tag = client.resource_tagging.account_tags.update( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="worker", + worker_id="3f72a691-44b3-4c11-8642-c18a88ddaa5e", + ) + assert_matches_type(Optional[AccountTagUpdateResponse], account_tag, path=["response"]) + + @parametrize + def test_method_update_with_all_params_overload_1(self, client: Cloudflare) -> None: + account_tag = client.resource_tagging.account_tags.update( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="worker", + worker_id="3f72a691-44b3-4c11-8642-c18a88ddaa5e", + tags={ + "environment": "production", + "team": "engineering", + }, + if_match='"v1:RBNvo1WzZ4oRRq0W9-hkng"', + ) + assert_matches_type(Optional[AccountTagUpdateResponse], account_tag, path=["response"]) + + @parametrize + def test_raw_response_update_overload_1(self, client: Cloudflare) -> None: + response = client.resource_tagging.account_tags.with_raw_response.update( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="worker", + worker_id="3f72a691-44b3-4c11-8642-c18a88ddaa5e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + account_tag = response.parse() + assert_matches_type(Optional[AccountTagUpdateResponse], account_tag, path=["response"]) + + @parametrize + def test_streaming_response_update_overload_1(self, client: Cloudflare) -> None: + with client.resource_tagging.account_tags.with_streaming_response.update( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="worker", + worker_id="3f72a691-44b3-4c11-8642-c18a88ddaa5e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + account_tag = response.parse() + assert_matches_type(Optional[AccountTagUpdateResponse], account_tag, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update_overload_1(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.resource_tagging.account_tags.with_raw_response.update( + account_id="", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="worker", + worker_id="3f72a691-44b3-4c11-8642-c18a88ddaa5e", + ) + + @parametrize + def test_method_update_overload_2(self, client: Cloudflare) -> None: + account_tag = client.resource_tagging.account_tags.update( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="worker", + ) + assert_matches_type(Optional[AccountTagUpdateResponse], account_tag, path=["response"]) + + @parametrize + def test_method_update_with_all_params_overload_2(self, client: Cloudflare) -> None: + account_tag = client.resource_tagging.account_tags.update( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="worker", + tags={ + "environment": "production", + "team": "engineering", + }, + if_match='"v1:RBNvo1WzZ4oRRq0W9-hkng"', + ) + assert_matches_type(Optional[AccountTagUpdateResponse], account_tag, path=["response"]) + + @parametrize + def test_raw_response_update_overload_2(self, client: Cloudflare) -> None: + response = client.resource_tagging.account_tags.with_raw_response.update( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="worker", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + account_tag = response.parse() + assert_matches_type(Optional[AccountTagUpdateResponse], account_tag, path=["response"]) + + @parametrize + def test_streaming_response_update_overload_2(self, client: Cloudflare) -> None: + with client.resource_tagging.account_tags.with_streaming_response.update( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="worker", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + account_tag = response.parse() + assert_matches_type(Optional[AccountTagUpdateResponse], account_tag, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update_overload_2(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.resource_tagging.account_tags.with_raw_response.update( + account_id="", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="worker", + ) + + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + account_tag = client.resource_tagging.account_tags.delete( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert account_tag is None + + @parametrize + def test_method_delete_with_all_params(self, client: Cloudflare) -> None: + account_tag = client.resource_tagging.account_tags.delete( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + if_match='"v1:RBNvo1WzZ4oRRq0W9-hkng"', + ) + assert account_tag is None + + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.resource_tagging.account_tags.with_raw_response.delete( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + account_tag = response.parse() + assert account_tag is None + + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.resource_tagging.account_tags.with_streaming_response.delete( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + account_tag = response.parse() + assert account_tag is None + + 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.resource_tagging.account_tags.with_raw_response.delete( + account_id="", + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + account_tag = client.resource_tagging.account_tags.get( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="worker", + ) + assert_matches_type(Optional[AccountTagGetResponse], account_tag, path=["response"]) + + @parametrize + def test_method_get_with_all_params(self, client: Cloudflare) -> None: + account_tag = client.resource_tagging.account_tags.get( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="worker", + worker_id="3f72a691-44b3-4c11-8642-c18a88ddaa5e", + ) + assert_matches_type(Optional[AccountTagGetResponse], account_tag, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.resource_tagging.account_tags.with_raw_response.get( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="worker", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + account_tag = response.parse() + assert_matches_type(Optional[AccountTagGetResponse], account_tag, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.resource_tagging.account_tags.with_streaming_response.get( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="worker", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + account_tag = response.parse() + assert_matches_type(Optional[AccountTagGetResponse], account_tag, 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.resource_tagging.account_tags.with_raw_response.get( + account_id="", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="worker", + ) + + +class TestAsyncAccountTags: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @parametrize + async def test_method_update_overload_1(self, async_client: AsyncCloudflare) -> None: + account_tag = await async_client.resource_tagging.account_tags.update( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="worker", + worker_id="3f72a691-44b3-4c11-8642-c18a88ddaa5e", + ) + assert_matches_type(Optional[AccountTagUpdateResponse], account_tag, path=["response"]) + + @parametrize + async def test_method_update_with_all_params_overload_1(self, async_client: AsyncCloudflare) -> None: + account_tag = await async_client.resource_tagging.account_tags.update( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="worker", + worker_id="3f72a691-44b3-4c11-8642-c18a88ddaa5e", + tags={ + "environment": "production", + "team": "engineering", + }, + if_match='"v1:RBNvo1WzZ4oRRq0W9-hkng"', + ) + assert_matches_type(Optional[AccountTagUpdateResponse], account_tag, path=["response"]) + + @parametrize + async def test_raw_response_update_overload_1(self, async_client: AsyncCloudflare) -> None: + response = await async_client.resource_tagging.account_tags.with_raw_response.update( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="worker", + worker_id="3f72a691-44b3-4c11-8642-c18a88ddaa5e", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + account_tag = await response.parse() + assert_matches_type(Optional[AccountTagUpdateResponse], account_tag, path=["response"]) + + @parametrize + async def test_streaming_response_update_overload_1(self, async_client: AsyncCloudflare) -> None: + async with async_client.resource_tagging.account_tags.with_streaming_response.update( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="worker", + worker_id="3f72a691-44b3-4c11-8642-c18a88ddaa5e", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + account_tag = await response.parse() + assert_matches_type(Optional[AccountTagUpdateResponse], account_tag, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update_overload_1(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.resource_tagging.account_tags.with_raw_response.update( + account_id="", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="worker", + worker_id="3f72a691-44b3-4c11-8642-c18a88ddaa5e", + ) + + @parametrize + async def test_method_update_overload_2(self, async_client: AsyncCloudflare) -> None: + account_tag = await async_client.resource_tagging.account_tags.update( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="worker", + ) + assert_matches_type(Optional[AccountTagUpdateResponse], account_tag, path=["response"]) + + @parametrize + async def test_method_update_with_all_params_overload_2(self, async_client: AsyncCloudflare) -> None: + account_tag = await async_client.resource_tagging.account_tags.update( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="worker", + tags={ + "environment": "production", + "team": "engineering", + }, + if_match='"v1:RBNvo1WzZ4oRRq0W9-hkng"', + ) + assert_matches_type(Optional[AccountTagUpdateResponse], account_tag, path=["response"]) + + @parametrize + async def test_raw_response_update_overload_2(self, async_client: AsyncCloudflare) -> None: + response = await async_client.resource_tagging.account_tags.with_raw_response.update( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="worker", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + account_tag = await response.parse() + assert_matches_type(Optional[AccountTagUpdateResponse], account_tag, path=["response"]) + + @parametrize + async def test_streaming_response_update_overload_2(self, async_client: AsyncCloudflare) -> None: + async with async_client.resource_tagging.account_tags.with_streaming_response.update( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="worker", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + account_tag = await response.parse() + assert_matches_type(Optional[AccountTagUpdateResponse], account_tag, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update_overload_2(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.resource_tagging.account_tags.with_raw_response.update( + account_id="", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="worker", + ) + + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + account_tag = await async_client.resource_tagging.account_tags.delete( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert account_tag is None + + @parametrize + async def test_method_delete_with_all_params(self, async_client: AsyncCloudflare) -> None: + account_tag = await async_client.resource_tagging.account_tags.delete( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + if_match='"v1:RBNvo1WzZ4oRRq0W9-hkng"', + ) + assert account_tag is None + + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.resource_tagging.account_tags.with_raw_response.delete( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + account_tag = await response.parse() + assert account_tag is None + + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.resource_tagging.account_tags.with_streaming_response.delete( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + account_tag = await response.parse() + assert account_tag is None + + 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.resource_tagging.account_tags.with_raw_response.delete( + account_id="", + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + account_tag = await async_client.resource_tagging.account_tags.get( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="worker", + ) + assert_matches_type(Optional[AccountTagGetResponse], account_tag, path=["response"]) + + @parametrize + async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: + account_tag = await async_client.resource_tagging.account_tags.get( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="worker", + worker_id="3f72a691-44b3-4c11-8642-c18a88ddaa5e", + ) + assert_matches_type(Optional[AccountTagGetResponse], account_tag, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.resource_tagging.account_tags.with_raw_response.get( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="worker", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + account_tag = await response.parse() + assert_matches_type(Optional[AccountTagGetResponse], account_tag, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.resource_tagging.account_tags.with_streaming_response.get( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="worker", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + account_tag = await response.parse() + assert_matches_type(Optional[AccountTagGetResponse], account_tag, 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.resource_tagging.account_tags.with_raw_response.get( + account_id="", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="worker", + ) diff --git a/tests/api_resources/resource_tagging/test_keys.py b/tests/api_resources/resource_tagging/test_keys.py new file mode 100644 index 00000000000..7a819478d39 --- /dev/null +++ b/tests/api_resources/resource_tagging/test_keys.py @@ -0,0 +1,117 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.pagination import SyncCursorPaginationAfter, AsyncCursorPaginationAfter +from cloudflare.types.resource_tagging import KeyListResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestKeys: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + key = client.resource_tagging.keys.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SyncCursorPaginationAfter[KeyListResponse], key, path=["response"]) + + @parametrize + def test_method_list_with_all_params(self, client: Cloudflare) -> None: + key = client.resource_tagging.keys.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cursor="eyJhY2NvdW50X2lkIjoxMjM0NTY3ODkwfQ", + ) + assert_matches_type(SyncCursorPaginationAfter[KeyListResponse], key, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.resource_tagging.keys.with_raw_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + key = response.parse() + assert_matches_type(SyncCursorPaginationAfter[KeyListResponse], key, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.resource_tagging.keys.with_streaming_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + key = response.parse() + assert_matches_type(SyncCursorPaginationAfter[KeyListResponse], key, 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.resource_tagging.keys.with_raw_response.list( + account_id="", + ) + + +class TestAsyncKeys: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + key = await async_client.resource_tagging.keys.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(AsyncCursorPaginationAfter[KeyListResponse], key, path=["response"]) + + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: + key = await async_client.resource_tagging.keys.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cursor="eyJhY2NvdW50X2lkIjoxMjM0NTY3ODkwfQ", + ) + assert_matches_type(AsyncCursorPaginationAfter[KeyListResponse], key, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.resource_tagging.keys.with_raw_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + key = await response.parse() + assert_matches_type(AsyncCursorPaginationAfter[KeyListResponse], key, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.resource_tagging.keys.with_streaming_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + key = await response.parse() + assert_matches_type(AsyncCursorPaginationAfter[KeyListResponse], key, 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.resource_tagging.keys.with_raw_response.list( + account_id="", + ) diff --git a/tests/api_resources/resource_tagging/test_values.py b/tests/api_resources/resource_tagging/test_values.py new file mode 100644 index 00000000000..0c4669121ec --- /dev/null +++ b/tests/api_resources/resource_tagging/test_values.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 +from cloudflare.pagination import SyncCursorPaginationAfter, AsyncCursorPaginationAfter +from cloudflare.types.resource_tagging import ValueListResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestValues: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + value = client.resource_tagging.values.list( + tag_key="environment", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SyncCursorPaginationAfter[ValueListResponse], value, path=["response"]) + + @parametrize + def test_method_list_with_all_params(self, client: Cloudflare) -> None: + value = client.resource_tagging.values.list( + tag_key="environment", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cursor="eyJhY2NvdW50X2lkIjoxMjM0NTY3ODkwfQ", + type="zone", + ) + assert_matches_type(SyncCursorPaginationAfter[ValueListResponse], value, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.resource_tagging.values.with_raw_response.list( + tag_key="environment", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + value = response.parse() + assert_matches_type(SyncCursorPaginationAfter[ValueListResponse], value, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.resource_tagging.values.with_streaming_response.list( + tag_key="environment", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + value = response.parse() + assert_matches_type(SyncCursorPaginationAfter[ValueListResponse], value, 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.resource_tagging.values.with_raw_response.list( + tag_key="environment", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `tag_key` but received ''"): + client.resource_tagging.values.with_raw_response.list( + tag_key="", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + +class TestAsyncValues: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + value = await async_client.resource_tagging.values.list( + tag_key="environment", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(AsyncCursorPaginationAfter[ValueListResponse], value, path=["response"]) + + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: + value = await async_client.resource_tagging.values.list( + tag_key="environment", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cursor="eyJhY2NvdW50X2lkIjoxMjM0NTY3ODkwfQ", + type="zone", + ) + assert_matches_type(AsyncCursorPaginationAfter[ValueListResponse], value, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.resource_tagging.values.with_raw_response.list( + tag_key="environment", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + value = await response.parse() + assert_matches_type(AsyncCursorPaginationAfter[ValueListResponse], value, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.resource_tagging.values.with_streaming_response.list( + tag_key="environment", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + value = await response.parse() + assert_matches_type(AsyncCursorPaginationAfter[ValueListResponse], value, 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.resource_tagging.values.with_raw_response.list( + tag_key="environment", + account_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `tag_key` but received ''"): + await async_client.resource_tagging.values.with_raw_response.list( + tag_key="", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) diff --git a/tests/api_resources/resource_tagging/test_zone_tags.py b/tests/api_resources/resource_tagging/test_zone_tags.py new file mode 100644 index 00000000000..d180a0f7005 --- /dev/null +++ b/tests/api_resources/resource_tagging/test_zone_tags.py @@ -0,0 +1,481 @@ +# 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.types.resource_tagging import ( + ZoneTagGetResponse, + ZoneTagUpdateResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestZoneTags: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_update_overload_1(self, client: Cloudflare) -> None: + zone_tag = client.resource_tagging.zone_tags.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="zone", + ) + assert_matches_type(Optional[ZoneTagUpdateResponse], zone_tag, path=["response"]) + + @parametrize + def test_method_update_with_all_params_overload_1(self, client: Cloudflare) -> None: + zone_tag = client.resource_tagging.zone_tags.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="zone", + tags={ + "environment": "production", + "team": "engineering", + }, + if_match='"v1:RBNvo1WzZ4oRRq0W9-hkng"', + ) + assert_matches_type(Optional[ZoneTagUpdateResponse], zone_tag, path=["response"]) + + @parametrize + def test_raw_response_update_overload_1(self, client: Cloudflare) -> None: + response = client.resource_tagging.zone_tags.with_raw_response.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="zone", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + zone_tag = response.parse() + assert_matches_type(Optional[ZoneTagUpdateResponse], zone_tag, path=["response"]) + + @parametrize + def test_streaming_response_update_overload_1(self, client: Cloudflare) -> None: + with client.resource_tagging.zone_tags.with_streaming_response.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="zone", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + zone_tag = response.parse() + assert_matches_type(Optional[ZoneTagUpdateResponse], zone_tag, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update_overload_1(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.resource_tagging.zone_tags.with_raw_response.update( + zone_id="", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="zone", + ) + + @parametrize + def test_method_update_overload_2(self, client: Cloudflare) -> None: + zone_tag = client.resource_tagging.zone_tags.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + access_application_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="zone", + ) + assert_matches_type(Optional[ZoneTagUpdateResponse], zone_tag, path=["response"]) + + @parametrize + def test_method_update_with_all_params_overload_2(self, client: Cloudflare) -> None: + zone_tag = client.resource_tagging.zone_tags.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + access_application_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="zone", + tags={ + "environment": "production", + "team": "engineering", + }, + if_match='"v1:RBNvo1WzZ4oRRq0W9-hkng"', + ) + assert_matches_type(Optional[ZoneTagUpdateResponse], zone_tag, path=["response"]) + + @parametrize + def test_raw_response_update_overload_2(self, client: Cloudflare) -> None: + response = client.resource_tagging.zone_tags.with_raw_response.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + access_application_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="zone", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + zone_tag = response.parse() + assert_matches_type(Optional[ZoneTagUpdateResponse], zone_tag, path=["response"]) + + @parametrize + def test_streaming_response_update_overload_2(self, client: Cloudflare) -> None: + with client.resource_tagging.zone_tags.with_streaming_response.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + access_application_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="zone", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + zone_tag = response.parse() + assert_matches_type(Optional[ZoneTagUpdateResponse], zone_tag, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update_overload_2(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.resource_tagging.zone_tags.with_raw_response.update( + zone_id="", + access_application_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="zone", + ) + + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + zone_tag = client.resource_tagging.zone_tags.delete( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert zone_tag is None + + @parametrize + def test_method_delete_with_all_params(self, client: Cloudflare) -> None: + zone_tag = client.resource_tagging.zone_tags.delete( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + if_match='"v1:RBNvo1WzZ4oRRq0W9-hkng"', + ) + assert zone_tag is None + + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.resource_tagging.zone_tags.with_raw_response.delete( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + zone_tag = response.parse() + assert zone_tag is None + + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.resource_tagging.zone_tags.with_streaming_response.delete( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + zone_tag = response.parse() + assert zone_tag is None + + 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 `zone_id` but received ''"): + client.resource_tagging.zone_tags.with_raw_response.delete( + zone_id="", + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + zone_tag = client.resource_tagging.zone_tags.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="zone", + ) + assert_matches_type(Optional[ZoneTagGetResponse], zone_tag, path=["response"]) + + @parametrize + def test_method_get_with_all_params(self, client: Cloudflare) -> None: + zone_tag = client.resource_tagging.zone_tags.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="zone", + access_application_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + ) + assert_matches_type(Optional[ZoneTagGetResponse], zone_tag, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.resource_tagging.zone_tags.with_raw_response.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="zone", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + zone_tag = response.parse() + assert_matches_type(Optional[ZoneTagGetResponse], zone_tag, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.resource_tagging.zone_tags.with_streaming_response.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="zone", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + zone_tag = response.parse() + assert_matches_type(Optional[ZoneTagGetResponse], zone_tag, 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 `zone_id` but received ''"): + client.resource_tagging.zone_tags.with_raw_response.get( + zone_id="", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="zone", + ) + + +class TestAsyncZoneTags: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @parametrize + async def test_method_update_overload_1(self, async_client: AsyncCloudflare) -> None: + zone_tag = await async_client.resource_tagging.zone_tags.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="zone", + ) + assert_matches_type(Optional[ZoneTagUpdateResponse], zone_tag, path=["response"]) + + @parametrize + async def test_method_update_with_all_params_overload_1(self, async_client: AsyncCloudflare) -> None: + zone_tag = await async_client.resource_tagging.zone_tags.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="zone", + tags={ + "environment": "production", + "team": "engineering", + }, + if_match='"v1:RBNvo1WzZ4oRRq0W9-hkng"', + ) + assert_matches_type(Optional[ZoneTagUpdateResponse], zone_tag, path=["response"]) + + @parametrize + async def test_raw_response_update_overload_1(self, async_client: AsyncCloudflare) -> None: + response = await async_client.resource_tagging.zone_tags.with_raw_response.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="zone", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + zone_tag = await response.parse() + assert_matches_type(Optional[ZoneTagUpdateResponse], zone_tag, path=["response"]) + + @parametrize + async def test_streaming_response_update_overload_1(self, async_client: AsyncCloudflare) -> None: + async with async_client.resource_tagging.zone_tags.with_streaming_response.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="zone", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + zone_tag = await response.parse() + assert_matches_type(Optional[ZoneTagUpdateResponse], zone_tag, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update_overload_1(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.resource_tagging.zone_tags.with_raw_response.update( + zone_id="", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="zone", + ) + + @parametrize + async def test_method_update_overload_2(self, async_client: AsyncCloudflare) -> None: + zone_tag = await async_client.resource_tagging.zone_tags.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + access_application_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="zone", + ) + assert_matches_type(Optional[ZoneTagUpdateResponse], zone_tag, path=["response"]) + + @parametrize + async def test_method_update_with_all_params_overload_2(self, async_client: AsyncCloudflare) -> None: + zone_tag = await async_client.resource_tagging.zone_tags.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + access_application_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="zone", + tags={ + "environment": "production", + "team": "engineering", + }, + if_match='"v1:RBNvo1WzZ4oRRq0W9-hkng"', + ) + assert_matches_type(Optional[ZoneTagUpdateResponse], zone_tag, path=["response"]) + + @parametrize + async def test_raw_response_update_overload_2(self, async_client: AsyncCloudflare) -> None: + response = await async_client.resource_tagging.zone_tags.with_raw_response.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + access_application_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="zone", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + zone_tag = await response.parse() + assert_matches_type(Optional[ZoneTagUpdateResponse], zone_tag, path=["response"]) + + @parametrize + async def test_streaming_response_update_overload_2(self, async_client: AsyncCloudflare) -> None: + async with async_client.resource_tagging.zone_tags.with_streaming_response.update( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + access_application_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="zone", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + zone_tag = await response.parse() + assert_matches_type(Optional[ZoneTagUpdateResponse], zone_tag, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update_overload_2(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.resource_tagging.zone_tags.with_raw_response.update( + zone_id="", + access_application_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="zone", + ) + + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + zone_tag = await async_client.resource_tagging.zone_tags.delete( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert zone_tag is None + + @parametrize + async def test_method_delete_with_all_params(self, async_client: AsyncCloudflare) -> None: + zone_tag = await async_client.resource_tagging.zone_tags.delete( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + if_match='"v1:RBNvo1WzZ4oRRq0W9-hkng"', + ) + assert zone_tag is None + + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.resource_tagging.zone_tags.with_raw_response.delete( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + zone_tag = await response.parse() + assert zone_tag is None + + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.resource_tagging.zone_tags.with_streaming_response.delete( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + zone_tag = await response.parse() + assert zone_tag is None + + 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 `zone_id` but received ''"): + await async_client.resource_tagging.zone_tags.with_raw_response.delete( + zone_id="", + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + zone_tag = await async_client.resource_tagging.zone_tags.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="zone", + ) + assert_matches_type(Optional[ZoneTagGetResponse], zone_tag, path=["response"]) + + @parametrize + async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: + zone_tag = await async_client.resource_tagging.zone_tags.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="zone", + access_application_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + ) + assert_matches_type(Optional[ZoneTagGetResponse], zone_tag, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.resource_tagging.zone_tags.with_raw_response.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="zone", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + zone_tag = await response.parse() + assert_matches_type(Optional[ZoneTagGetResponse], zone_tag, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.resource_tagging.zone_tags.with_streaming_response.get( + zone_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="zone", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + zone_tag = await response.parse() + assert_matches_type(Optional[ZoneTagGetResponse], zone_tag, 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 `zone_id` but received ''"): + await async_client.resource_tagging.zone_tags.with_raw_response.get( + zone_id="", + resource_id="023e105f4ecef8ad9ca31a8372d0c353", + resource_type="zone", + ) diff --git a/tests/api_resources/test_resource_tagging.py b/tests/api_resources/test_resource_tagging.py new file mode 100644 index 00000000000..99205e2eed2 --- /dev/null +++ b/tests/api_resources/test_resource_tagging.py @@ -0,0 +1,131 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.pagination import SyncCursorPaginationAfter, AsyncCursorPaginationAfter +from cloudflare.types.resource_tagging import ResourceTaggingListResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestResourceTagging: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_list(self, client: Cloudflare) -> None: + resource_tagging = client.resource_tagging.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SyncCursorPaginationAfter[ResourceTaggingListResponse], resource_tagging, path=["response"]) + + @parametrize + def test_method_list_with_all_params(self, client: Cloudflare) -> None: + resource_tagging = client.resource_tagging.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cursor="eyJhY2NvdW50X2lkIjoxMjM0NTY3ODkwfQ", + tag=["production", "env=prod", "env=prod,staging", "!archived", "region!=us-west-1"], + type=["zone"], + ) + assert_matches_type(SyncCursorPaginationAfter[ResourceTaggingListResponse], resource_tagging, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Cloudflare) -> None: + response = client.resource_tagging.with_raw_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + resource_tagging = response.parse() + assert_matches_type(SyncCursorPaginationAfter[ResourceTaggingListResponse], resource_tagging, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Cloudflare) -> None: + with client.resource_tagging.with_streaming_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + resource_tagging = response.parse() + assert_matches_type( + SyncCursorPaginationAfter[ResourceTaggingListResponse], resource_tagging, 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.resource_tagging.with_raw_response.list( + account_id="", + ) + + +class TestAsyncResourceTagging: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @parametrize + async def test_method_list(self, async_client: AsyncCloudflare) -> None: + resource_tagging = await async_client.resource_tagging.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type( + AsyncCursorPaginationAfter[ResourceTaggingListResponse], resource_tagging, path=["response"] + ) + + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: + resource_tagging = await async_client.resource_tagging.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + cursor="eyJhY2NvdW50X2lkIjoxMjM0NTY3ODkwfQ", + tag=["production", "env=prod", "env=prod,staging", "!archived", "region!=us-west-1"], + type=["zone"], + ) + assert_matches_type( + AsyncCursorPaginationAfter[ResourceTaggingListResponse], resource_tagging, path=["response"] + ) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: + response = await async_client.resource_tagging.with_raw_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + resource_tagging = await response.parse() + assert_matches_type( + AsyncCursorPaginationAfter[ResourceTaggingListResponse], resource_tagging, path=["response"] + ) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: + async with async_client.resource_tagging.with_streaming_response.list( + account_id="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + resource_tagging = await response.parse() + assert_matches_type( + AsyncCursorPaginationAfter[ResourceTaggingListResponse], resource_tagging, 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.resource_tagging.with_raw_response.list( + account_id="", + )