diff --git a/.stats.yml b/.stats.yml index f17384f70ce..87e06d29c87 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 1401 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1f3a5920b5590a1e7f4df129cc299fe3d4aaa7bf4ef6915b015dd898b1a1813c.yml +configured_endpoints: 1365 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-7f27b85aabb7545439eb5fc9cd71679bfac6746ed74a19f4de513eff8797f88d.yml diff --git a/api.md b/api.md index 4501b1b0e80..e00ed6f6ed5 100644 --- a/api.md +++ b/api.md @@ -1365,17 +1365,9 @@ Methods: Types: ```python -from cloudflare.types.filters import FirewallFilter, FilterCreateResponse +from cloudflare.types.filters import FirewallFilter ``` -Methods: - -- client.filters.create(\*, zone_id, \*\*params) -> Optional -- client.filters.update(filter_id, \*, zone_id, \*\*params) -> FirewallFilter -- client.filters.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[FirewallFilter] -- client.filters.delete(filter_id, \*, zone_id) -> FirewallFilter -- client.filters.get(filter_id, \*, zone_id) -> FirewallFilter - # Firewall ## Lockdowns @@ -1389,41 +1381,17 @@ from cloudflare.types.firewall import ( LockdownCIDRConfiguration, LockdownIPConfiguration, LockdownURL, - LockdownDeleteResponse, ) ``` -Methods: - -- client.firewall.lockdowns.create(\*, zone_id, \*\*params) -> Lockdown -- client.firewall.lockdowns.update(lock_downs_id, \*, zone_id, \*\*params) -> Lockdown -- client.firewall.lockdowns.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[Lockdown] -- client.firewall.lockdowns.delete(lock_downs_id, \*, zone_id) -> Optional -- client.firewall.lockdowns.get(lock_downs_id, \*, zone_id) -> Lockdown - ## Rules Types: ```python -from cloudflare.types.firewall import ( - FirewallRule, - Product, - DeletedFilter, - RuleCreateResponse, - RuleEditResponse, -) +from cloudflare.types.firewall import FirewallRule, Product, DeletedFilter ``` -Methods: - -- client.firewall.rules.create(\*, zone_id, \*\*params) -> Optional -- client.firewall.rules.update(rule_id, \*, zone_id, \*\*params) -> FirewallRule -- client.firewall.rules.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[FirewallRule] -- client.firewall.rules.delete(rule_id, \*, zone_id) -> FirewallRule -- client.firewall.rules.edit(rule_id, \*, zone_id) -> Optional -- client.firewall.rules.get(rule_id, \*, zone_id, \*\*params) -> FirewallRule - ## AccessRules Types: @@ -1437,41 +1405,13 @@ from cloudflare.types.firewall import ( IPV6Configuration, AccessRuleCreateResponse, AccessRuleListResponse, - AccessRuleDeleteResponse, - AccessRuleEditResponse, - AccessRuleGetResponse, ) ``` Methods: - client.firewall.access_rules.create(\*, account_id, zone_id, \*\*params) -> AccessRuleCreateResponse -- client.firewall.access_rules.list(\*, account_id, zone_id, \*\*params) -> SyncV4PagePaginationArray[AccessRuleListResponse] -- client.firewall.access_rules.delete(rule_id, \*, account_id, zone_id) -> Optional -- client.firewall.access_rules.edit(rule_id, \*, account_id, zone_id, \*\*params) -> AccessRuleEditResponse -- client.firewall.access_rules.get(rule_id, \*, account_id, zone_id) -> AccessRuleGetResponse - -## UARules - -Types: - -```python -from cloudflare.types.firewall import ( - UARuleCreateResponse, - UARuleUpdateResponse, - UARuleListResponse, - UARuleDeleteResponse, - UARuleGetResponse, -) -``` - -Methods: - -- client.firewall.ua_rules.create(\*, zone_id, \*\*params) -> UARuleCreateResponse -- client.firewall.ua_rules.update(ua_rule_id, \*, zone_id, \*\*params) -> UARuleUpdateResponse -- client.firewall.ua_rules.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[UARuleListResponse] -- client.firewall.ua_rules.delete(ua_rule_id, \*, zone_id) -> UARuleDeleteResponse -- client.firewall.ua_rules.get(ua_rule_id, \*, zone_id) -> UARuleGetResponse +- client.firewall.access_rules.list(\*, account_id, zone_id, \*\*params) -> SyncV4PagePaginationArray[object] ## WAF @@ -1480,36 +1420,11 @@ Methods: Types: ```python -from cloudflare.types.firewall.waf import ( - Override, - OverrideURL, - RewriteAction, - WAFRule, - OverrideDeleteResponse, -) +from cloudflare.types.firewall.waf import Override, OverrideURL, RewriteAction, WAFRule ``` -Methods: - -- client.firewall.waf.overrides.create(\*, zone_id, \*\*params) -> Override -- client.firewall.waf.overrides.update(overrides_id, \*, zone_id, \*\*params) -> Override -- client.firewall.waf.overrides.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[Override] -- client.firewall.waf.overrides.delete(overrides_id, \*, zone_id) -> Optional -- client.firewall.waf.overrides.get(overrides_id, \*, zone_id) -> Override - ### Packages -Types: - -```python -from cloudflare.types.firewall.waf import PackageListResponse, PackageGetResponse -``` - -Methods: - -- client.firewall.waf.packages.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[object] -- client.firewall.waf.packages.get(package_id, \*, zone_id) -> PackageGetResponse - #### Groups Types: @@ -1859,17 +1774,9 @@ Methods: Types: ```python -from cloudflare.types.rate_limits import Action, Methods, RateLimit, RateLimitDeleteResponse +from cloudflare.types.rate_limits import Action, Methods, RateLimit ``` -Methods: - -- client.rate_limits.create(\*, zone_id, \*\*params) -> RateLimit -- client.rate_limits.list(\*, zone_id, \*\*params) -> SyncV4PagePaginationArray[RateLimit] -- client.rate_limits.delete(rate_limit_id, \*, zone_id) -> RateLimitDeleteResponse -- client.rate_limits.edit(rate_limit_id, \*, zone_id, \*\*params) -> RateLimit -- client.rate_limits.get(rate_limit_id, \*, zone_id) -> RateLimit - # SecondaryDNS ## ForceAXFR diff --git a/src/cloudflare/_client.py b/src/cloudflare/_client.py index b14d401cd35..5bbf90722fa 100644 --- a/src/cloudflare/_client.py +++ b/src/cloudflare/_client.py @@ -62,7 +62,6 @@ queues, stream, billing, - filters, logpush, storage, workers, @@ -88,7 +87,6 @@ diagnostics, memberships, page_shield, - rate_limits, url_scanner, healthchecks, security_txt, @@ -328,12 +326,6 @@ def email_routing(self) -> email_routing.EmailRoutingResource: return EmailRoutingResource(self) - @cached_property - def filters(self) -> filters.FiltersResource: - from .resources.filters import FiltersResource - - return FiltersResource(self) - @cached_property def firewall(self) -> firewall.FirewallResource: from .resources.firewall import FirewallResource @@ -376,12 +368,6 @@ def pagerules(self) -> pagerules.PagerulesResource: return PagerulesResource(self) - @cached_property - def rate_limits(self) -> rate_limits.RateLimitsResource: - from .resources.rate_limits import RateLimitsResource - - return RateLimitsResource(self) - @cached_property def secondary_dns(self) -> secondary_dns.SecondaryDNSResource: from .resources.secondary_dns import SecondaryDNSResource @@ -1093,12 +1079,6 @@ def email_routing(self) -> email_routing.AsyncEmailRoutingResource: return AsyncEmailRoutingResource(self) - @cached_property - def filters(self) -> filters.AsyncFiltersResource: - from .resources.filters import AsyncFiltersResource - - return AsyncFiltersResource(self) - @cached_property def firewall(self) -> firewall.AsyncFirewallResource: from .resources.firewall import AsyncFirewallResource @@ -1141,12 +1121,6 @@ def pagerules(self) -> pagerules.AsyncPagerulesResource: return AsyncPagerulesResource(self) - @cached_property - def rate_limits(self) -> rate_limits.AsyncRateLimitsResource: - from .resources.rate_limits import AsyncRateLimitsResource - - return AsyncRateLimitsResource(self) - @cached_property def secondary_dns(self) -> secondary_dns.AsyncSecondaryDNSResource: from .resources.secondary_dns import AsyncSecondaryDNSResource @@ -1791,12 +1765,6 @@ def email_routing(self) -> email_routing.EmailRoutingResourceWithRawResponse: return EmailRoutingResourceWithRawResponse(self._client.email_routing) - @cached_property - def filters(self) -> filters.FiltersResourceWithRawResponse: - from .resources.filters import FiltersResourceWithRawResponse - - return FiltersResourceWithRawResponse(self._client.filters) - @cached_property def firewall(self) -> firewall.FirewallResourceWithRawResponse: from .resources.firewall import FirewallResourceWithRawResponse @@ -1839,12 +1807,6 @@ def pagerules(self) -> pagerules.PagerulesResourceWithRawResponse: return PagerulesResourceWithRawResponse(self._client.pagerules) - @cached_property - def rate_limits(self) -> rate_limits.RateLimitsResourceWithRawResponse: - from .resources.rate_limits import RateLimitsResourceWithRawResponse - - return RateLimitsResourceWithRawResponse(self._client.rate_limits) - @cached_property def secondary_dns(self) -> secondary_dns.SecondaryDNSResourceWithRawResponse: from .resources.secondary_dns import SecondaryDNSResourceWithRawResponse @@ -2310,12 +2272,6 @@ def email_routing(self) -> email_routing.AsyncEmailRoutingResourceWithRawRespons return AsyncEmailRoutingResourceWithRawResponse(self._client.email_routing) - @cached_property - def filters(self) -> filters.AsyncFiltersResourceWithRawResponse: - from .resources.filters import AsyncFiltersResourceWithRawResponse - - return AsyncFiltersResourceWithRawResponse(self._client.filters) - @cached_property def firewall(self) -> firewall.AsyncFirewallResourceWithRawResponse: from .resources.firewall import AsyncFirewallResourceWithRawResponse @@ -2358,12 +2314,6 @@ def pagerules(self) -> pagerules.AsyncPagerulesResourceWithRawResponse: return AsyncPagerulesResourceWithRawResponse(self._client.pagerules) - @cached_property - def rate_limits(self) -> rate_limits.AsyncRateLimitsResourceWithRawResponse: - from .resources.rate_limits import AsyncRateLimitsResourceWithRawResponse - - return AsyncRateLimitsResourceWithRawResponse(self._client.rate_limits) - @cached_property def secondary_dns(self) -> secondary_dns.AsyncSecondaryDNSResourceWithRawResponse: from .resources.secondary_dns import AsyncSecondaryDNSResourceWithRawResponse @@ -2829,12 +2779,6 @@ def email_routing(self) -> email_routing.EmailRoutingResourceWithStreamingRespon return EmailRoutingResourceWithStreamingResponse(self._client.email_routing) - @cached_property - def filters(self) -> filters.FiltersResourceWithStreamingResponse: - from .resources.filters import FiltersResourceWithStreamingResponse - - return FiltersResourceWithStreamingResponse(self._client.filters) - @cached_property def firewall(self) -> firewall.FirewallResourceWithStreamingResponse: from .resources.firewall import FirewallResourceWithStreamingResponse @@ -2877,12 +2821,6 @@ def pagerules(self) -> pagerules.PagerulesResourceWithStreamingResponse: return PagerulesResourceWithStreamingResponse(self._client.pagerules) - @cached_property - def rate_limits(self) -> rate_limits.RateLimitsResourceWithStreamingResponse: - from .resources.rate_limits import RateLimitsResourceWithStreamingResponse - - return RateLimitsResourceWithStreamingResponse(self._client.rate_limits) - @cached_property def secondary_dns(self) -> secondary_dns.SecondaryDNSResourceWithStreamingResponse: from .resources.secondary_dns import SecondaryDNSResourceWithStreamingResponse @@ -3350,12 +3288,6 @@ def email_routing(self) -> email_routing.AsyncEmailRoutingResourceWithStreamingR return AsyncEmailRoutingResourceWithStreamingResponse(self._client.email_routing) - @cached_property - def filters(self) -> filters.AsyncFiltersResourceWithStreamingResponse: - from .resources.filters import AsyncFiltersResourceWithStreamingResponse - - return AsyncFiltersResourceWithStreamingResponse(self._client.filters) - @cached_property def firewall(self) -> firewall.AsyncFirewallResourceWithStreamingResponse: from .resources.firewall import AsyncFirewallResourceWithStreamingResponse @@ -3398,12 +3330,6 @@ def pagerules(self) -> pagerules.AsyncPagerulesResourceWithStreamingResponse: return AsyncPagerulesResourceWithStreamingResponse(self._client.pagerules) - @cached_property - def rate_limits(self) -> rate_limits.AsyncRateLimitsResourceWithStreamingResponse: - from .resources.rate_limits import AsyncRateLimitsResourceWithStreamingResponse - - return AsyncRateLimitsResourceWithStreamingResponse(self._client.rate_limits) - @cached_property def secondary_dns(self) -> secondary_dns.AsyncSecondaryDNSResourceWithStreamingResponse: from .resources.secondary_dns import AsyncSecondaryDNSResourceWithStreamingResponse diff --git a/src/cloudflare/resources/filters.py b/src/cloudflare/resources/filters.py deleted file mode 100644 index 4e696d2c05f..00000000000 --- a/src/cloudflare/resources/filters.py +++ /dev/null @@ -1,730 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import typing_extensions -from typing import Type, Optional, cast - -import httpx - -from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from .._utils import ( - maybe_transform, - async_maybe_transform, -) -from .._compat import cached_property -from .._resource import SyncAPIResource, AsyncAPIResource -from .._response import ( - to_raw_response_wrapper, - to_streamed_response_wrapper, - async_to_raw_response_wrapper, - async_to_streamed_response_wrapper, -) -from .._wrappers import ResultWrapper -from ..pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray -from .._base_client import AsyncPaginator, make_request_options -from ..types.filters import filter_list_params, filter_create_params, filter_update_params -from ..types.filters.firewall_filter import FirewallFilter -from ..types.filters.filter_create_response import FilterCreateResponse - -__all__ = ["FiltersResource", "AsyncFiltersResource"] - - -class FiltersResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> FiltersResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return the - 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 FiltersResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> FiltersResourceWithStreamingResponse: - """ - 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 FiltersResourceWithStreamingResponse(self) - - @typing_extensions.deprecated( - "The Filters API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." - ) - def create( - self, - *, - zone_id: str, - expression: 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[FilterCreateResponse]: - """ - Creates one or more filters. - - Args: - zone_id: Identifier - - expression: The filter expression. For more information, refer to - [Expressions](https://developers.cloudflare.com/ruleset-engine/rules-language/expressions/). - - 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 self._post( - f"/zones/{zone_id}/filters", - body=maybe_transform({"expression": expression}, filter_create_params.FilterCreateParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[FilterCreateResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[FilterCreateResponse]], ResultWrapper[FilterCreateResponse]), - ) - - @typing_extensions.deprecated( - "The Filters API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." - ) - def update( - self, - filter_id: str, - *, - zone_id: str, - body: object, - # 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, - ) -> FirewallFilter: - """ - Updates an existing filter. - - Args: - zone_id: Identifier - - filter_id: The unique identifier of the filter. - - 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}") - if not filter_id: - raise ValueError(f"Expected a non-empty value for `filter_id` but received {filter_id!r}") - return self._put( - f"/zones/{zone_id}/filters/{filter_id}", - body=maybe_transform(body, filter_update_params.FilterUpdateParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[FirewallFilter]._unwrapper, - ), - cast_to=cast(Type[FirewallFilter], ResultWrapper[FirewallFilter]), - ) - - @typing_extensions.deprecated( - "The Filters API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." - ) - def list( - self, - *, - zone_id: str, - id: str | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - expression: str | NotGiven = NOT_GIVEN, - page: float | NotGiven = NOT_GIVEN, - paused: bool | NotGiven = NOT_GIVEN, - per_page: float | NotGiven = NOT_GIVEN, - ref: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncV4PagePaginationArray[FirewallFilter]: - """Fetches filters in a zone. - - You can filter the results using several optional - parameters. - - Args: - zone_id: Identifier - - id: The unique identifier of the filter. - - description: A case-insensitive string to find in the description. - - expression: A case-insensitive string to find in the expression. - - page: Page number of paginated results. - - paused: When true, indicates that the filter is currently paused. - - per_page: Number of filters per page. - - ref: The filter ref (a short reference tag) to search for. Must be an exact match. - - 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 self._get_api_list( - f"/zones/{zone_id}/filters", - page=SyncV4PagePaginationArray[FirewallFilter], - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "id": id, - "description": description, - "expression": expression, - "page": page, - "paused": paused, - "per_page": per_page, - "ref": ref, - }, - filter_list_params.FilterListParams, - ), - ), - model=FirewallFilter, - ) - - @typing_extensions.deprecated( - "The Filters API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." - ) - def delete( - self, - filter_id: str, - *, - zone_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, - ) -> FirewallFilter: - """ - Deletes an existing filter. - - Args: - zone_id: Identifier - - filter_id: The unique identifier of the filter. - - 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}") - if not filter_id: - raise ValueError(f"Expected a non-empty value for `filter_id` but received {filter_id!r}") - return self._delete( - f"/zones/{zone_id}/filters/{filter_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[FirewallFilter]._unwrapper, - ), - cast_to=cast(Type[FirewallFilter], ResultWrapper[FirewallFilter]), - ) - - @typing_extensions.deprecated( - "The Filters API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." - ) - def get( - self, - filter_id: str, - *, - zone_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, - ) -> FirewallFilter: - """ - Fetches the details of a filter. - - Args: - zone_id: Identifier - - filter_id: The unique identifier of the filter. - - 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}") - if not filter_id: - raise ValueError(f"Expected a non-empty value for `filter_id` but received {filter_id!r}") - return self._get( - f"/zones/{zone_id}/filters/{filter_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[FirewallFilter]._unwrapper, - ), - cast_to=cast(Type[FirewallFilter], ResultWrapper[FirewallFilter]), - ) - - -class AsyncFiltersResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncFiltersResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return the - 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 AsyncFiltersResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncFiltersResourceWithStreamingResponse: - """ - 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 AsyncFiltersResourceWithStreamingResponse(self) - - @typing_extensions.deprecated( - "The Filters API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." - ) - async def create( - self, - *, - zone_id: str, - expression: 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[FilterCreateResponse]: - """ - Creates one or more filters. - - Args: - zone_id: Identifier - - expression: The filter expression. For more information, refer to - [Expressions](https://developers.cloudflare.com/ruleset-engine/rules-language/expressions/). - - 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 await self._post( - f"/zones/{zone_id}/filters", - body=await async_maybe_transform({"expression": expression}, filter_create_params.FilterCreateParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[FilterCreateResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[FilterCreateResponse]], ResultWrapper[FilterCreateResponse]), - ) - - @typing_extensions.deprecated( - "The Filters API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." - ) - async def update( - self, - filter_id: str, - *, - zone_id: str, - body: object, - # 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, - ) -> FirewallFilter: - """ - Updates an existing filter. - - Args: - zone_id: Identifier - - filter_id: The unique identifier of the filter. - - 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}") - if not filter_id: - raise ValueError(f"Expected a non-empty value for `filter_id` but received {filter_id!r}") - return await self._put( - f"/zones/{zone_id}/filters/{filter_id}", - body=await async_maybe_transform(body, filter_update_params.FilterUpdateParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[FirewallFilter]._unwrapper, - ), - cast_to=cast(Type[FirewallFilter], ResultWrapper[FirewallFilter]), - ) - - @typing_extensions.deprecated( - "The Filters API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." - ) - def list( - self, - *, - zone_id: str, - id: str | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - expression: str | NotGiven = NOT_GIVEN, - page: float | NotGiven = NOT_GIVEN, - paused: bool | NotGiven = NOT_GIVEN, - per_page: float | NotGiven = NOT_GIVEN, - ref: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[FirewallFilter, AsyncV4PagePaginationArray[FirewallFilter]]: - """Fetches filters in a zone. - - You can filter the results using several optional - parameters. - - Args: - zone_id: Identifier - - id: The unique identifier of the filter. - - description: A case-insensitive string to find in the description. - - expression: A case-insensitive string to find in the expression. - - page: Page number of paginated results. - - paused: When true, indicates that the filter is currently paused. - - per_page: Number of filters per page. - - ref: The filter ref (a short reference tag) to search for. Must be an exact match. - - 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 self._get_api_list( - f"/zones/{zone_id}/filters", - page=AsyncV4PagePaginationArray[FirewallFilter], - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "id": id, - "description": description, - "expression": expression, - "page": page, - "paused": paused, - "per_page": per_page, - "ref": ref, - }, - filter_list_params.FilterListParams, - ), - ), - model=FirewallFilter, - ) - - @typing_extensions.deprecated( - "The Filters API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." - ) - async def delete( - self, - filter_id: str, - *, - zone_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, - ) -> FirewallFilter: - """ - Deletes an existing filter. - - Args: - zone_id: Identifier - - filter_id: The unique identifier of the filter. - - 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}") - if not filter_id: - raise ValueError(f"Expected a non-empty value for `filter_id` but received {filter_id!r}") - return await self._delete( - f"/zones/{zone_id}/filters/{filter_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[FirewallFilter]._unwrapper, - ), - cast_to=cast(Type[FirewallFilter], ResultWrapper[FirewallFilter]), - ) - - @typing_extensions.deprecated( - "The Filters API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." - ) - async def get( - self, - filter_id: str, - *, - zone_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, - ) -> FirewallFilter: - """ - Fetches the details of a filter. - - Args: - zone_id: Identifier - - filter_id: The unique identifier of the filter. - - 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}") - if not filter_id: - raise ValueError(f"Expected a non-empty value for `filter_id` but received {filter_id!r}") - return await self._get( - f"/zones/{zone_id}/filters/{filter_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[FirewallFilter]._unwrapper, - ), - cast_to=cast(Type[FirewallFilter], ResultWrapper[FirewallFilter]), - ) - - -class FiltersResourceWithRawResponse: - def __init__(self, filters: FiltersResource) -> None: - self._filters = filters - - self.create = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - filters.create # pyright: ignore[reportDeprecated], - ) - ) - self.update = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - filters.update # pyright: ignore[reportDeprecated], - ) - ) - self.list = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - filters.list # pyright: ignore[reportDeprecated], - ) - ) - self.delete = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - filters.delete # pyright: ignore[reportDeprecated], - ) - ) - self.get = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - filters.get # pyright: ignore[reportDeprecated], - ) - ) - - -class AsyncFiltersResourceWithRawResponse: - def __init__(self, filters: AsyncFiltersResource) -> None: - self._filters = filters - - self.create = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - filters.create # pyright: ignore[reportDeprecated], - ) - ) - self.update = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - filters.update # pyright: ignore[reportDeprecated], - ) - ) - self.list = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - filters.list # pyright: ignore[reportDeprecated], - ) - ) - self.delete = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - filters.delete # pyright: ignore[reportDeprecated], - ) - ) - self.get = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - filters.get # pyright: ignore[reportDeprecated], - ) - ) - - -class FiltersResourceWithStreamingResponse: - def __init__(self, filters: FiltersResource) -> None: - self._filters = filters - - self.create = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - filters.create # pyright: ignore[reportDeprecated], - ) - ) - self.update = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - filters.update # pyright: ignore[reportDeprecated], - ) - ) - self.list = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - filters.list # pyright: ignore[reportDeprecated], - ) - ) - self.delete = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - filters.delete # pyright: ignore[reportDeprecated], - ) - ) - self.get = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - filters.get # pyright: ignore[reportDeprecated], - ) - ) - - -class AsyncFiltersResourceWithStreamingResponse: - def __init__(self, filters: AsyncFiltersResource) -> None: - self._filters = filters - - self.create = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - filters.create # pyright: ignore[reportDeprecated], - ) - ) - self.update = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - filters.update # pyright: ignore[reportDeprecated], - ) - ) - self.list = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - filters.list # pyright: ignore[reportDeprecated], - ) - ) - self.delete = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - filters.delete # pyright: ignore[reportDeprecated], - ) - ) - self.get = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - filters.get # pyright: ignore[reportDeprecated], - ) - ) diff --git a/src/cloudflare/resources/firewall/__init__.py b/src/cloudflare/resources/firewall/__init__.py index cc405a6f65f..53adfca9ab6 100644 --- a/src/cloudflare/resources/firewall/__init__.py +++ b/src/cloudflare/resources/firewall/__init__.py @@ -8,14 +8,6 @@ WAFResourceWithStreamingResponse, AsyncWAFResourceWithStreamingResponse, ) -from .rules import ( - RulesResource, - AsyncRulesResource, - RulesResourceWithRawResponse, - AsyncRulesResourceWithRawResponse, - RulesResourceWithStreamingResponse, - AsyncRulesResourceWithStreamingResponse, -) from .firewall import ( FirewallResource, AsyncFirewallResource, @@ -24,22 +16,6 @@ FirewallResourceWithStreamingResponse, AsyncFirewallResourceWithStreamingResponse, ) -from .ua_rules import ( - UARulesResource, - AsyncUARulesResource, - UARulesResourceWithRawResponse, - AsyncUARulesResourceWithRawResponse, - UARulesResourceWithStreamingResponse, - AsyncUARulesResourceWithStreamingResponse, -) -from .lockdowns import ( - LockdownsResource, - AsyncLockdownsResource, - LockdownsResourceWithRawResponse, - AsyncLockdownsResourceWithRawResponse, - LockdownsResourceWithStreamingResponse, - AsyncLockdownsResourceWithStreamingResponse, -) from .access_rules import ( AccessRulesResource, AsyncAccessRulesResource, @@ -50,30 +26,12 @@ ) __all__ = [ - "LockdownsResource", - "AsyncLockdownsResource", - "LockdownsResourceWithRawResponse", - "AsyncLockdownsResourceWithRawResponse", - "LockdownsResourceWithStreamingResponse", - "AsyncLockdownsResourceWithStreamingResponse", - "RulesResource", - "AsyncRulesResource", - "RulesResourceWithRawResponse", - "AsyncRulesResourceWithRawResponse", - "RulesResourceWithStreamingResponse", - "AsyncRulesResourceWithStreamingResponse", "AccessRulesResource", "AsyncAccessRulesResource", "AccessRulesResourceWithRawResponse", "AsyncAccessRulesResourceWithRawResponse", "AccessRulesResourceWithStreamingResponse", "AsyncAccessRulesResourceWithStreamingResponse", - "UARulesResource", - "AsyncUARulesResource", - "UARulesResourceWithRawResponse", - "AsyncUARulesResourceWithRawResponse", - "UARulesResourceWithStreamingResponse", - "AsyncUARulesResourceWithStreamingResponse", "WAFResource", "AsyncWAFResource", "WAFResourceWithRawResponse", diff --git a/src/cloudflare/resources/firewall/access_rules.py b/src/cloudflare/resources/firewall/access_rules.py index 0cc4d0281e2..0d12de27913 100644 --- a/src/cloudflare/resources/firewall/access_rules.py +++ b/src/cloudflare/resources/firewall/access_rules.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Type, Optional, cast +from typing import Any, cast from typing_extensions import Literal import httpx @@ -23,12 +23,8 @@ from ..._wrappers import ResultWrapper from ...pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray from ..._base_client import AsyncPaginator, make_request_options -from ...types.firewall import access_rule_edit_params, access_rule_list_params, access_rule_create_params -from ...types.firewall.access_rule_get_response import AccessRuleGetResponse -from ...types.firewall.access_rule_edit_response import AccessRuleEditResponse -from ...types.firewall.access_rule_list_response import AccessRuleListResponse +from ...types.firewall import access_rule_list_params, access_rule_create_params from ...types.firewall.access_rule_create_response import AccessRuleCreateResponse -from ...types.firewall.access_rule_delete_response import AccessRuleDeleteResponse __all__ = ["AccessRulesResource", "AsyncAccessRulesResource"] @@ -107,24 +103,29 @@ def create( account_or_zone = "zones" account_or_zone_id = zone_id - return self._post( - f"/{account_or_zone}/{account_or_zone_id}/firewall/access_rules/rules", - body=maybe_transform( - { - "configuration": configuration, - "mode": mode, - "notes": notes, - }, - access_rule_create_params.AccessRuleCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[AccessRuleCreateResponse]._unwrapper, + return cast( + AccessRuleCreateResponse, + self._post( + f"/{account_or_zone}/{account_or_zone_id}/firewall/access_rules/rules", + body=maybe_transform( + { + "configuration": configuration, + "mode": mode, + "notes": notes, + }, + access_rule_create_params.AccessRuleCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[AccessRuleCreateResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[AccessRuleCreateResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=cast(Type[AccessRuleCreateResponse], ResultWrapper[AccessRuleCreateResponse]), ) def list( @@ -146,7 +147,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncV4PagePaginationArray[AccessRuleListResponse]: + ) -> SyncV4PagePaginationArray[object]: """Fetches IP Access rules of an account or zone. These rules apply to all the @@ -197,7 +198,7 @@ def list( account_or_zone_id = zone_id return self._get_api_list( f"/{account_or_zone}/{account_or_zone_id}/firewall/access_rules/rules", - page=SyncV4PagePaginationArray[AccessRuleListResponse], + page=SyncV4PagePaginationArray[object], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -217,199 +218,7 @@ def list( access_rule_list_params.AccessRuleListParams, ), ), - model=AccessRuleListResponse, - ) - - def delete( - self, - rule_id: str, - *, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[AccessRuleDeleteResponse]: - """ - Deletes an existing IP Access rule defined. - - Note: This operation will affect all zones in the account or zone. - - Args: - rule_id: Unique identifier for a 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. - - 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 rule_id: - raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return self._delete( - f"/{account_or_zone}/{account_or_zone_id}/firewall/access_rules/rules/{rule_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[AccessRuleDeleteResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[AccessRuleDeleteResponse]], ResultWrapper[AccessRuleDeleteResponse]), - ) - - def edit( - self, - rule_id: str, - *, - configuration: access_rule_edit_params.Configuration, - mode: Literal["block", "challenge", "whitelist", "js_challenge", "managed_challenge"], - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - notes: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AccessRuleEditResponse: - """ - Updates an IP Access rule defined. - - Note: This operation will affect all zones in the account or zone. - - Args: - rule_id: Unique identifier for a rule - - configuration: The rule configuration. - - mode: The action to apply to a matched request. - - 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. - - notes: An informative summary of the rule, typically used as a reminder or explanation. - - 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 rule_id: - raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return self._patch( - f"/{account_or_zone}/{account_or_zone_id}/firewall/access_rules/rules/{rule_id}", - body=maybe_transform( - { - "configuration": configuration, - "mode": mode, - "notes": notes, - }, - access_rule_edit_params.AccessRuleEditParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[AccessRuleEditResponse]._unwrapper, - ), - cast_to=cast(Type[AccessRuleEditResponse], ResultWrapper[AccessRuleEditResponse]), - ) - - def get( - self, - rule_id: str, - *, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AccessRuleGetResponse: - """ - Fetches the details of an IP Access rule defined. - - Args: - rule_id: Unique identifier for a 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. - - 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 rule_id: - raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return self._get( - f"/{account_or_zone}/{account_or_zone_id}/firewall/access_rules/rules/{rule_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[AccessRuleGetResponse]._unwrapper, - ), - cast_to=cast(Type[AccessRuleGetResponse], ResultWrapper[AccessRuleGetResponse]), + model=object, ) @@ -487,24 +296,29 @@ async def create( account_or_zone = "zones" account_or_zone_id = zone_id - return await self._post( - f"/{account_or_zone}/{account_or_zone_id}/firewall/access_rules/rules", - body=await async_maybe_transform( - { - "configuration": configuration, - "mode": mode, - "notes": notes, - }, - access_rule_create_params.AccessRuleCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[AccessRuleCreateResponse]._unwrapper, + return cast( + AccessRuleCreateResponse, + await self._post( + f"/{account_or_zone}/{account_or_zone_id}/firewall/access_rules/rules", + body=await async_maybe_transform( + { + "configuration": configuration, + "mode": mode, + "notes": notes, + }, + access_rule_create_params.AccessRuleCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[AccessRuleCreateResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[AccessRuleCreateResponse] + ), # Union types cannot be passed in as arguments in the type system ), - cast_to=cast(Type[AccessRuleCreateResponse], ResultWrapper[AccessRuleCreateResponse]), ) def list( @@ -526,7 +340,7 @@ def list( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[AccessRuleListResponse, AsyncV4PagePaginationArray[AccessRuleListResponse]]: + ) -> AsyncPaginator[object, AsyncV4PagePaginationArray[object]]: """Fetches IP Access rules of an account or zone. These rules apply to all the @@ -577,7 +391,7 @@ def list( account_or_zone_id = zone_id return self._get_api_list( f"/{account_or_zone}/{account_or_zone_id}/firewall/access_rules/rules", - page=AsyncV4PagePaginationArray[AccessRuleListResponse], + page=AsyncV4PagePaginationArray[object], options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -597,199 +411,7 @@ def list( access_rule_list_params.AccessRuleListParams, ), ), - model=AccessRuleListResponse, - ) - - async def delete( - self, - rule_id: str, - *, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[AccessRuleDeleteResponse]: - """ - Deletes an existing IP Access rule defined. - - Note: This operation will affect all zones in the account or zone. - - Args: - rule_id: Unique identifier for a 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. - - 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 rule_id: - raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return await self._delete( - f"/{account_or_zone}/{account_or_zone_id}/firewall/access_rules/rules/{rule_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[AccessRuleDeleteResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[AccessRuleDeleteResponse]], ResultWrapper[AccessRuleDeleteResponse]), - ) - - async def edit( - self, - rule_id: str, - *, - configuration: access_rule_edit_params.Configuration, - mode: Literal["block", "challenge", "whitelist", "js_challenge", "managed_challenge"], - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - notes: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AccessRuleEditResponse: - """ - Updates an IP Access rule defined. - - Note: This operation will affect all zones in the account or zone. - - Args: - rule_id: Unique identifier for a rule - - configuration: The rule configuration. - - mode: The action to apply to a matched request. - - 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. - - notes: An informative summary of the rule, typically used as a reminder or explanation. - - 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 rule_id: - raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return await self._patch( - f"/{account_or_zone}/{account_or_zone_id}/firewall/access_rules/rules/{rule_id}", - body=await async_maybe_transform( - { - "configuration": configuration, - "mode": mode, - "notes": notes, - }, - access_rule_edit_params.AccessRuleEditParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[AccessRuleEditResponse]._unwrapper, - ), - cast_to=cast(Type[AccessRuleEditResponse], ResultWrapper[AccessRuleEditResponse]), - ) - - async def get( - self, - rule_id: str, - *, - account_id: str | NotGiven = NOT_GIVEN, - zone_id: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AccessRuleGetResponse: - """ - Fetches the details of an IP Access rule defined. - - Args: - rule_id: Unique identifier for a 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. - - 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 rule_id: - raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - if not zone_id: - raise ValueError("You must provide either account_id or zone_id") - - account_or_zone = "zones" - account_or_zone_id = zone_id - return await self._get( - f"/{account_or_zone}/{account_or_zone_id}/firewall/access_rules/rules/{rule_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[AccessRuleGetResponse]._unwrapper, - ), - cast_to=cast(Type[AccessRuleGetResponse], ResultWrapper[AccessRuleGetResponse]), + model=object, ) @@ -803,15 +425,6 @@ def __init__(self, access_rules: AccessRulesResource) -> None: self.list = to_raw_response_wrapper( access_rules.list, ) - self.delete = to_raw_response_wrapper( - access_rules.delete, - ) - self.edit = to_raw_response_wrapper( - access_rules.edit, - ) - self.get = to_raw_response_wrapper( - access_rules.get, - ) class AsyncAccessRulesResourceWithRawResponse: @@ -824,15 +437,6 @@ def __init__(self, access_rules: AsyncAccessRulesResource) -> None: self.list = async_to_raw_response_wrapper( access_rules.list, ) - self.delete = async_to_raw_response_wrapper( - access_rules.delete, - ) - self.edit = async_to_raw_response_wrapper( - access_rules.edit, - ) - self.get = async_to_raw_response_wrapper( - access_rules.get, - ) class AccessRulesResourceWithStreamingResponse: @@ -845,15 +449,6 @@ def __init__(self, access_rules: AccessRulesResource) -> None: self.list = to_streamed_response_wrapper( access_rules.list, ) - self.delete = to_streamed_response_wrapper( - access_rules.delete, - ) - self.edit = to_streamed_response_wrapper( - access_rules.edit, - ) - self.get = to_streamed_response_wrapper( - access_rules.get, - ) class AsyncAccessRulesResourceWithStreamingResponse: @@ -866,12 +461,3 @@ def __init__(self, access_rules: AsyncAccessRulesResource) -> None: self.list = async_to_streamed_response_wrapper( access_rules.list, ) - self.delete = async_to_streamed_response_wrapper( - access_rules.delete, - ) - self.edit = async_to_streamed_response_wrapper( - access_rules.edit, - ) - self.get = async_to_streamed_response_wrapper( - access_rules.get, - ) diff --git a/src/cloudflare/resources/firewall/firewall.py b/src/cloudflare/resources/firewall/firewall.py index e5ff2fe9261..6cfa5c1d6da 100644 --- a/src/cloudflare/resources/firewall/firewall.py +++ b/src/cloudflare/resources/firewall/firewall.py @@ -10,32 +10,8 @@ WAFResourceWithStreamingResponse, AsyncWAFResourceWithStreamingResponse, ) -from .rules import ( - RulesResource, - AsyncRulesResource, - RulesResourceWithRawResponse, - AsyncRulesResourceWithRawResponse, - RulesResourceWithStreamingResponse, - AsyncRulesResourceWithStreamingResponse, -) from .waf.waf import WAFResource, AsyncWAFResource -from .ua_rules import ( - UARulesResource, - AsyncUARulesResource, - UARulesResourceWithRawResponse, - AsyncUARulesResourceWithRawResponse, - UARulesResourceWithStreamingResponse, - AsyncUARulesResourceWithStreamingResponse, -) from ..._compat import cached_property -from .lockdowns import ( - LockdownsResource, - AsyncLockdownsResource, - LockdownsResourceWithRawResponse, - AsyncLockdownsResourceWithRawResponse, - LockdownsResourceWithStreamingResponse, - AsyncLockdownsResourceWithStreamingResponse, -) from ..._resource import SyncAPIResource, AsyncAPIResource from .access_rules import ( AccessRulesResource, @@ -50,22 +26,10 @@ class FirewallResource(SyncAPIResource): - @cached_property - def lockdowns(self) -> LockdownsResource: - return LockdownsResource(self._client) - - @cached_property - def rules(self) -> RulesResource: - return RulesResource(self._client) - @cached_property def access_rules(self) -> AccessRulesResource: return AccessRulesResource(self._client) - @cached_property - def ua_rules(self) -> UARulesResource: - return UARulesResource(self._client) - @cached_property def waf(self) -> WAFResource: return WAFResource(self._client) @@ -91,22 +55,10 @@ def with_streaming_response(self) -> FirewallResourceWithStreamingResponse: class AsyncFirewallResource(AsyncAPIResource): - @cached_property - def lockdowns(self) -> AsyncLockdownsResource: - return AsyncLockdownsResource(self._client) - - @cached_property - def rules(self) -> AsyncRulesResource: - return AsyncRulesResource(self._client) - @cached_property def access_rules(self) -> AsyncAccessRulesResource: return AsyncAccessRulesResource(self._client) - @cached_property - def ua_rules(self) -> AsyncUARulesResource: - return AsyncUARulesResource(self._client) - @cached_property def waf(self) -> AsyncWAFResource: return AsyncWAFResource(self._client) @@ -135,22 +87,10 @@ class FirewallResourceWithRawResponse: def __init__(self, firewall: FirewallResource) -> None: self._firewall = firewall - @cached_property - def lockdowns(self) -> LockdownsResourceWithRawResponse: - return LockdownsResourceWithRawResponse(self._firewall.lockdowns) - - @cached_property - def rules(self) -> RulesResourceWithRawResponse: - return RulesResourceWithRawResponse(self._firewall.rules) - @cached_property def access_rules(self) -> AccessRulesResourceWithRawResponse: return AccessRulesResourceWithRawResponse(self._firewall.access_rules) - @cached_property - def ua_rules(self) -> UARulesResourceWithRawResponse: - return UARulesResourceWithRawResponse(self._firewall.ua_rules) - @cached_property def waf(self) -> WAFResourceWithRawResponse: return WAFResourceWithRawResponse(self._firewall.waf) @@ -160,22 +100,10 @@ class AsyncFirewallResourceWithRawResponse: def __init__(self, firewall: AsyncFirewallResource) -> None: self._firewall = firewall - @cached_property - def lockdowns(self) -> AsyncLockdownsResourceWithRawResponse: - return AsyncLockdownsResourceWithRawResponse(self._firewall.lockdowns) - - @cached_property - def rules(self) -> AsyncRulesResourceWithRawResponse: - return AsyncRulesResourceWithRawResponse(self._firewall.rules) - @cached_property def access_rules(self) -> AsyncAccessRulesResourceWithRawResponse: return AsyncAccessRulesResourceWithRawResponse(self._firewall.access_rules) - @cached_property - def ua_rules(self) -> AsyncUARulesResourceWithRawResponse: - return AsyncUARulesResourceWithRawResponse(self._firewall.ua_rules) - @cached_property def waf(self) -> AsyncWAFResourceWithRawResponse: return AsyncWAFResourceWithRawResponse(self._firewall.waf) @@ -185,22 +113,10 @@ class FirewallResourceWithStreamingResponse: def __init__(self, firewall: FirewallResource) -> None: self._firewall = firewall - @cached_property - def lockdowns(self) -> LockdownsResourceWithStreamingResponse: - return LockdownsResourceWithStreamingResponse(self._firewall.lockdowns) - - @cached_property - def rules(self) -> RulesResourceWithStreamingResponse: - return RulesResourceWithStreamingResponse(self._firewall.rules) - @cached_property def access_rules(self) -> AccessRulesResourceWithStreamingResponse: return AccessRulesResourceWithStreamingResponse(self._firewall.access_rules) - @cached_property - def ua_rules(self) -> UARulesResourceWithStreamingResponse: - return UARulesResourceWithStreamingResponse(self._firewall.ua_rules) - @cached_property def waf(self) -> WAFResourceWithStreamingResponse: return WAFResourceWithStreamingResponse(self._firewall.waf) @@ -210,22 +126,10 @@ class AsyncFirewallResourceWithStreamingResponse: def __init__(self, firewall: AsyncFirewallResource) -> None: self._firewall = firewall - @cached_property - def lockdowns(self) -> AsyncLockdownsResourceWithStreamingResponse: - return AsyncLockdownsResourceWithStreamingResponse(self._firewall.lockdowns) - - @cached_property - def rules(self) -> AsyncRulesResourceWithStreamingResponse: - return AsyncRulesResourceWithStreamingResponse(self._firewall.rules) - @cached_property def access_rules(self) -> AsyncAccessRulesResourceWithStreamingResponse: return AsyncAccessRulesResourceWithStreamingResponse(self._firewall.access_rules) - @cached_property - def ua_rules(self) -> AsyncUARulesResourceWithStreamingResponse: - return AsyncUARulesResourceWithStreamingResponse(self._firewall.ua_rules) - @cached_property def waf(self) -> AsyncWAFResourceWithStreamingResponse: return AsyncWAFResourceWithStreamingResponse(self._firewall.waf) diff --git a/src/cloudflare/resources/firewall/lockdowns.py b/src/cloudflare/resources/firewall/lockdowns.py deleted file mode 100644 index 94dd5f36c30..00000000000 --- a/src/cloudflare/resources/firewall/lockdowns.py +++ /dev/null @@ -1,754 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import List, Type, Union, Optional, cast -from datetime import datetime - -import httpx - -from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ..._utils import ( - maybe_transform, - async_maybe_transform, -) -from ..._compat import cached_property -from ..._resource import SyncAPIResource, AsyncAPIResource -from ..._response import ( - to_raw_response_wrapper, - to_streamed_response_wrapper, - async_to_raw_response_wrapper, - async_to_streamed_response_wrapper, -) -from ..._wrappers import ResultWrapper -from ...pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray -from ..._base_client import AsyncPaginator, make_request_options -from ...types.firewall import lockdown_list_params, lockdown_create_params, lockdown_update_params -from ...types.firewall.lockdown import Lockdown -from ...types.firewall.waf.override_url import OverrideURL -from ...types.firewall.configuration_param import ConfigurationParam -from ...types.firewall.lockdown_delete_response import LockdownDeleteResponse - -__all__ = ["LockdownsResource", "AsyncLockdownsResource"] - - -class LockdownsResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> LockdownsResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return the - 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 LockdownsResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> LockdownsResourceWithStreamingResponse: - """ - 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 LockdownsResourceWithStreamingResponse(self) - - def create( - self, - *, - zone_id: str, - configurations: ConfigurationParam, - urls: List[OverrideURL], - # 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, - ) -> Lockdown: - """ - Creates a new Zone Lockdown rule. - - Args: - zone_id: Identifier - - configurations: A list of IP addresses or CIDR ranges that will be allowed to access the URLs - specified in the Zone Lockdown rule. You can include any number of `ip` or - `ip_range` configurations. - - urls: The URLs to include in the current WAF override. You can use wildcards. Each - entered URL will be escaped before use, which means you can only use simple - wildcard patterns. - - 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 self._post( - f"/zones/{zone_id}/firewall/lockdowns", - body=maybe_transform( - { - "configurations": configurations, - "urls": urls, - }, - lockdown_create_params.LockdownCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Lockdown]._unwrapper, - ), - cast_to=cast(Type[Lockdown], ResultWrapper[Lockdown]), - ) - - def update( - self, - lock_downs_id: str, - *, - zone_id: str, - configurations: ConfigurationParam, - urls: List[OverrideURL], - # 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, - ) -> Lockdown: - """ - Updates an existing Zone Lockdown rule. - - Args: - zone_id: Identifier - - lock_downs_id: The unique identifier of the Zone Lockdown rule. - - configurations: A list of IP addresses or CIDR ranges that will be allowed to access the URLs - specified in the Zone Lockdown rule. You can include any number of `ip` or - `ip_range` configurations. - - urls: The URLs to include in the current WAF override. You can use wildcards. Each - entered URL will be escaped before use, which means you can only use simple - wildcard patterns. - - 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}") - if not lock_downs_id: - raise ValueError(f"Expected a non-empty value for `lock_downs_id` but received {lock_downs_id!r}") - return self._put( - f"/zones/{zone_id}/firewall/lockdowns/{lock_downs_id}", - body=maybe_transform( - { - "configurations": configurations, - "urls": urls, - }, - lockdown_update_params.LockdownUpdateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Lockdown]._unwrapper, - ), - cast_to=cast(Type[Lockdown], ResultWrapper[Lockdown]), - ) - - def list( - self, - *, - zone_id: str, - created_on: Union[str, datetime] | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - description_search: str | NotGiven = NOT_GIVEN, - ip: str | NotGiven = NOT_GIVEN, - ip_range_search: str | NotGiven = NOT_GIVEN, - ip_search: str | NotGiven = NOT_GIVEN, - modified_on: Union[str, datetime] | NotGiven = NOT_GIVEN, - page: float | NotGiven = NOT_GIVEN, - per_page: float | NotGiven = NOT_GIVEN, - priority: float | NotGiven = NOT_GIVEN, - uri_search: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncV4PagePaginationArray[Lockdown]: - """Fetches Zone Lockdown rules. - - You can filter the results using several optional - parameters. - - Args: - zone_id: Identifier - - created_on: The timestamp of when the rule was created. - - description: A string to search for in the description of existing rules. - - description_search: A string to search for in the description of existing rules. - - ip: A single IP address to search for in existing rules. - - ip_range_search: A single IP address range to search for in existing rules. - - ip_search: A single IP address to search for in existing rules. - - modified_on: The timestamp of when the rule was last modified. - - page: Page number of paginated results. - - per_page: The maximum number of results per page. You can only set the value to `1` or to - a multiple of 5 such as `5`, `10`, `15`, or `20`. - - priority: The priority of the rule to control the processing order. A lower number - indicates higher priority. If not provided, any rules with a configured priority - will be processed before rules without a priority. - - uri_search: A single URI to search for in the list of URLs of existing rules. - - 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 self._get_api_list( - f"/zones/{zone_id}/firewall/lockdowns", - page=SyncV4PagePaginationArray[Lockdown], - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "created_on": created_on, - "description": description, - "description_search": description_search, - "ip": ip, - "ip_range_search": ip_range_search, - "ip_search": ip_search, - "modified_on": modified_on, - "page": page, - "per_page": per_page, - "priority": priority, - "uri_search": uri_search, - }, - lockdown_list_params.LockdownListParams, - ), - ), - model=Lockdown, - ) - - def delete( - self, - lock_downs_id: str, - *, - zone_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[LockdownDeleteResponse]: - """ - Deletes an existing Zone Lockdown rule. - - Args: - zone_id: Identifier - - lock_downs_id: The unique identifier of the Zone Lockdown rule. - - 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}") - if not lock_downs_id: - raise ValueError(f"Expected a non-empty value for `lock_downs_id` but received {lock_downs_id!r}") - return self._delete( - f"/zones/{zone_id}/firewall/lockdowns/{lock_downs_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[LockdownDeleteResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[LockdownDeleteResponse]], ResultWrapper[LockdownDeleteResponse]), - ) - - def get( - self, - lock_downs_id: str, - *, - zone_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, - ) -> Lockdown: - """ - Fetches the details of a Zone Lockdown rule. - - Args: - zone_id: Identifier - - lock_downs_id: The unique identifier of the Zone Lockdown rule. - - 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}") - if not lock_downs_id: - raise ValueError(f"Expected a non-empty value for `lock_downs_id` but received {lock_downs_id!r}") - return self._get( - f"/zones/{zone_id}/firewall/lockdowns/{lock_downs_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Lockdown]._unwrapper, - ), - cast_to=cast(Type[Lockdown], ResultWrapper[Lockdown]), - ) - - -class AsyncLockdownsResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncLockdownsResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return the - 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 AsyncLockdownsResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncLockdownsResourceWithStreamingResponse: - """ - 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 AsyncLockdownsResourceWithStreamingResponse(self) - - async def create( - self, - *, - zone_id: str, - configurations: ConfigurationParam, - urls: List[OverrideURL], - # 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, - ) -> Lockdown: - """ - Creates a new Zone Lockdown rule. - - Args: - zone_id: Identifier - - configurations: A list of IP addresses or CIDR ranges that will be allowed to access the URLs - specified in the Zone Lockdown rule. You can include any number of `ip` or - `ip_range` configurations. - - urls: The URLs to include in the current WAF override. You can use wildcards. Each - entered URL will be escaped before use, which means you can only use simple - wildcard patterns. - - 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 await self._post( - f"/zones/{zone_id}/firewall/lockdowns", - body=await async_maybe_transform( - { - "configurations": configurations, - "urls": urls, - }, - lockdown_create_params.LockdownCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Lockdown]._unwrapper, - ), - cast_to=cast(Type[Lockdown], ResultWrapper[Lockdown]), - ) - - async def update( - self, - lock_downs_id: str, - *, - zone_id: str, - configurations: ConfigurationParam, - urls: List[OverrideURL], - # 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, - ) -> Lockdown: - """ - Updates an existing Zone Lockdown rule. - - Args: - zone_id: Identifier - - lock_downs_id: The unique identifier of the Zone Lockdown rule. - - configurations: A list of IP addresses or CIDR ranges that will be allowed to access the URLs - specified in the Zone Lockdown rule. You can include any number of `ip` or - `ip_range` configurations. - - urls: The URLs to include in the current WAF override. You can use wildcards. Each - entered URL will be escaped before use, which means you can only use simple - wildcard patterns. - - 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}") - if not lock_downs_id: - raise ValueError(f"Expected a non-empty value for `lock_downs_id` but received {lock_downs_id!r}") - return await self._put( - f"/zones/{zone_id}/firewall/lockdowns/{lock_downs_id}", - body=await async_maybe_transform( - { - "configurations": configurations, - "urls": urls, - }, - lockdown_update_params.LockdownUpdateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Lockdown]._unwrapper, - ), - cast_to=cast(Type[Lockdown], ResultWrapper[Lockdown]), - ) - - def list( - self, - *, - zone_id: str, - created_on: Union[str, datetime] | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - description_search: str | NotGiven = NOT_GIVEN, - ip: str | NotGiven = NOT_GIVEN, - ip_range_search: str | NotGiven = NOT_GIVEN, - ip_search: str | NotGiven = NOT_GIVEN, - modified_on: Union[str, datetime] | NotGiven = NOT_GIVEN, - page: float | NotGiven = NOT_GIVEN, - per_page: float | NotGiven = NOT_GIVEN, - priority: float | NotGiven = NOT_GIVEN, - uri_search: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[Lockdown, AsyncV4PagePaginationArray[Lockdown]]: - """Fetches Zone Lockdown rules. - - You can filter the results using several optional - parameters. - - Args: - zone_id: Identifier - - created_on: The timestamp of when the rule was created. - - description: A string to search for in the description of existing rules. - - description_search: A string to search for in the description of existing rules. - - ip: A single IP address to search for in existing rules. - - ip_range_search: A single IP address range to search for in existing rules. - - ip_search: A single IP address to search for in existing rules. - - modified_on: The timestamp of when the rule was last modified. - - page: Page number of paginated results. - - per_page: The maximum number of results per page. You can only set the value to `1` or to - a multiple of 5 such as `5`, `10`, `15`, or `20`. - - priority: The priority of the rule to control the processing order. A lower number - indicates higher priority. If not provided, any rules with a configured priority - will be processed before rules without a priority. - - uri_search: A single URI to search for in the list of URLs of existing rules. - - 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 self._get_api_list( - f"/zones/{zone_id}/firewall/lockdowns", - page=AsyncV4PagePaginationArray[Lockdown], - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "created_on": created_on, - "description": description, - "description_search": description_search, - "ip": ip, - "ip_range_search": ip_range_search, - "ip_search": ip_search, - "modified_on": modified_on, - "page": page, - "per_page": per_page, - "priority": priority, - "uri_search": uri_search, - }, - lockdown_list_params.LockdownListParams, - ), - ), - model=Lockdown, - ) - - async def delete( - self, - lock_downs_id: str, - *, - zone_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[LockdownDeleteResponse]: - """ - Deletes an existing Zone Lockdown rule. - - Args: - zone_id: Identifier - - lock_downs_id: The unique identifier of the Zone Lockdown rule. - - 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}") - if not lock_downs_id: - raise ValueError(f"Expected a non-empty value for `lock_downs_id` but received {lock_downs_id!r}") - return await self._delete( - f"/zones/{zone_id}/firewall/lockdowns/{lock_downs_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[LockdownDeleteResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[LockdownDeleteResponse]], ResultWrapper[LockdownDeleteResponse]), - ) - - async def get( - self, - lock_downs_id: str, - *, - zone_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, - ) -> Lockdown: - """ - Fetches the details of a Zone Lockdown rule. - - Args: - zone_id: Identifier - - lock_downs_id: The unique identifier of the Zone Lockdown rule. - - 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}") - if not lock_downs_id: - raise ValueError(f"Expected a non-empty value for `lock_downs_id` but received {lock_downs_id!r}") - return await self._get( - f"/zones/{zone_id}/firewall/lockdowns/{lock_downs_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Lockdown]._unwrapper, - ), - cast_to=cast(Type[Lockdown], ResultWrapper[Lockdown]), - ) - - -class LockdownsResourceWithRawResponse: - def __init__(self, lockdowns: LockdownsResource) -> None: - self._lockdowns = lockdowns - - self.create = to_raw_response_wrapper( - lockdowns.create, - ) - self.update = to_raw_response_wrapper( - lockdowns.update, - ) - self.list = to_raw_response_wrapper( - lockdowns.list, - ) - self.delete = to_raw_response_wrapper( - lockdowns.delete, - ) - self.get = to_raw_response_wrapper( - lockdowns.get, - ) - - -class AsyncLockdownsResourceWithRawResponse: - def __init__(self, lockdowns: AsyncLockdownsResource) -> None: - self._lockdowns = lockdowns - - self.create = async_to_raw_response_wrapper( - lockdowns.create, - ) - self.update = async_to_raw_response_wrapper( - lockdowns.update, - ) - self.list = async_to_raw_response_wrapper( - lockdowns.list, - ) - self.delete = async_to_raw_response_wrapper( - lockdowns.delete, - ) - self.get = async_to_raw_response_wrapper( - lockdowns.get, - ) - - -class LockdownsResourceWithStreamingResponse: - def __init__(self, lockdowns: LockdownsResource) -> None: - self._lockdowns = lockdowns - - self.create = to_streamed_response_wrapper( - lockdowns.create, - ) - self.update = to_streamed_response_wrapper( - lockdowns.update, - ) - self.list = to_streamed_response_wrapper( - lockdowns.list, - ) - self.delete = to_streamed_response_wrapper( - lockdowns.delete, - ) - self.get = to_streamed_response_wrapper( - lockdowns.get, - ) - - -class AsyncLockdownsResourceWithStreamingResponse: - def __init__(self, lockdowns: AsyncLockdownsResource) -> None: - self._lockdowns = lockdowns - - self.create = async_to_streamed_response_wrapper( - lockdowns.create, - ) - self.update = async_to_streamed_response_wrapper( - lockdowns.update, - ) - self.list = async_to_streamed_response_wrapper( - lockdowns.list, - ) - self.delete = async_to_streamed_response_wrapper( - lockdowns.delete, - ) - self.get = async_to_streamed_response_wrapper( - lockdowns.get, - ) diff --git a/src/cloudflare/resources/firewall/rules.py b/src/cloudflare/resources/firewall/rules.py deleted file mode 100644 index b760b0f9128..00000000000 --- a/src/cloudflare/resources/firewall/rules.py +++ /dev/null @@ -1,880 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import typing_extensions -from typing import Type, Optional, cast - -import httpx - -from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ..._utils import ( - maybe_transform, - async_maybe_transform, -) -from ..._compat import cached_property -from ..._resource import SyncAPIResource, AsyncAPIResource -from ..._response import ( - to_raw_response_wrapper, - to_streamed_response_wrapper, - async_to_raw_response_wrapper, - async_to_streamed_response_wrapper, -) -from ..._wrappers import ResultWrapper -from ...pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray -from ..._base_client import AsyncPaginator, make_request_options -from ...types.firewall import rule_get_params, rule_list_params, rule_create_params, rule_update_params -from ...types.firewall.firewall_rule import FirewallRule -from ...types.firewall.rule_edit_response import RuleEditResponse -from ...types.filters.firewall_filter_param import FirewallFilterParam -from ...types.firewall.rule_create_response import RuleCreateResponse - -__all__ = ["RulesResource", "AsyncRulesResource"] - - -class RulesResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> RulesResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return the - 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 RulesResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> RulesResourceWithStreamingResponse: - """ - 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 RulesResourceWithStreamingResponse(self) - - @typing_extensions.deprecated( - "The Firewall Rules API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." - ) - def create( - self, - *, - zone_id: str, - action: rule_create_params.Action, - filter: FirewallFilterParam, - # 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[RuleCreateResponse]: - """ - Create one or more firewall rules. - - Args: - zone_id: Identifier - - action: The action to perform when the threshold of matched traffic within the - configured period is exceeded. - - 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 self._post( - f"/zones/{zone_id}/firewall/rules", - body=maybe_transform( - { - "action": action, - "filter": filter, - }, - rule_create_params.RuleCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[RuleCreateResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[RuleCreateResponse]], ResultWrapper[RuleCreateResponse]), - ) - - @typing_extensions.deprecated( - "The Firewall Rules API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." - ) - def update( - self, - rule_id: str, - *, - zone_id: str, - action: rule_update_params.Action, - filter: FirewallFilterParam, - # 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, - ) -> FirewallRule: - """ - Updates an existing firewall rule. - - Args: - zone_id: Identifier - - rule_id: The unique identifier of the firewall rule. - - action: The action to perform when the threshold of matched traffic within the - configured period is exceeded. - - 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}") - if not rule_id: - raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") - return self._put( - f"/zones/{zone_id}/firewall/rules/{rule_id}", - body=maybe_transform( - { - "action": action, - "filter": filter, - }, - rule_update_params.RuleUpdateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[FirewallRule]._unwrapper, - ), - cast_to=cast(Type[FirewallRule], ResultWrapper[FirewallRule]), - ) - - @typing_extensions.deprecated( - "The Firewall Rules API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." - ) - def list( - self, - *, - zone_id: str, - id: str | NotGiven = NOT_GIVEN, - action: str | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - page: float | NotGiven = NOT_GIVEN, - paused: bool | NotGiven = NOT_GIVEN, - per_page: float | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncV4PagePaginationArray[FirewallRule]: - """Fetches firewall rules in a zone. - - You can filter the results using several - optional parameters. - - Args: - zone_id: Identifier - - id: The unique identifier of the firewall rule. - - action: The action to search for. Must be an exact match. - - description: A case-insensitive string to find in the description. - - page: Page number of paginated results. - - paused: When true, indicates that the firewall rule is currently paused. - - per_page: Number of firewall rules 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 zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - return self._get_api_list( - f"/zones/{zone_id}/firewall/rules", - page=SyncV4PagePaginationArray[FirewallRule], - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "id": id, - "action": action, - "description": description, - "page": page, - "paused": paused, - "per_page": per_page, - }, - rule_list_params.RuleListParams, - ), - ), - model=FirewallRule, - ) - - @typing_extensions.deprecated( - "The Firewall Rules API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." - ) - def delete( - self, - rule_id: str, - *, - zone_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, - ) -> FirewallRule: - """ - Deletes an existing firewall rule. - - Args: - zone_id: Identifier - - rule_id: The unique identifier of the firewall rule. - - 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}") - if not rule_id: - raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") - return self._delete( - f"/zones/{zone_id}/firewall/rules/{rule_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[FirewallRule]._unwrapper, - ), - cast_to=cast(Type[FirewallRule], ResultWrapper[FirewallRule]), - ) - - @typing_extensions.deprecated( - "The Firewall Rules API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." - ) - def edit( - self, - rule_id: str, - *, - zone_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[RuleEditResponse]: - """ - Updates the priority of an existing firewall rule. - - Args: - zone_id: Identifier - - rule_id: The unique identifier of the firewall rule. - - 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}") - if not rule_id: - raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") - return self._patch( - f"/zones/{zone_id}/firewall/rules/{rule_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[RuleEditResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[RuleEditResponse]], ResultWrapper[RuleEditResponse]), - ) - - @typing_extensions.deprecated( - "The Firewall Rules API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." - ) - def get( - self, - rule_id: str, - *, - zone_id: str, - id: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> FirewallRule: - """ - Fetches the details of a firewall rule. - - Args: - zone_id: Identifier - - rule_id: The unique identifier of the firewall rule. - - id: The unique identifier of the firewall rule. - - 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}") - if not rule_id: - raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") - return self._get( - f"/zones/{zone_id}/firewall/rules/{rule_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform({"id": id}, rule_get_params.RuleGetParams), - post_parser=ResultWrapper[FirewallRule]._unwrapper, - ), - cast_to=cast(Type[FirewallRule], ResultWrapper[FirewallRule]), - ) - - -class AsyncRulesResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncRulesResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return the - 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 AsyncRulesResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncRulesResourceWithStreamingResponse: - """ - 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 AsyncRulesResourceWithStreamingResponse(self) - - @typing_extensions.deprecated( - "The Firewall Rules API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." - ) - async def create( - self, - *, - zone_id: str, - action: rule_create_params.Action, - filter: FirewallFilterParam, - # 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[RuleCreateResponse]: - """ - Create one or more firewall rules. - - Args: - zone_id: Identifier - - action: The action to perform when the threshold of matched traffic within the - configured period is exceeded. - - 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 await self._post( - f"/zones/{zone_id}/firewall/rules", - body=await async_maybe_transform( - { - "action": action, - "filter": filter, - }, - rule_create_params.RuleCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[RuleCreateResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[RuleCreateResponse]], ResultWrapper[RuleCreateResponse]), - ) - - @typing_extensions.deprecated( - "The Firewall Rules API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." - ) - async def update( - self, - rule_id: str, - *, - zone_id: str, - action: rule_update_params.Action, - filter: FirewallFilterParam, - # 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, - ) -> FirewallRule: - """ - Updates an existing firewall rule. - - Args: - zone_id: Identifier - - rule_id: The unique identifier of the firewall rule. - - action: The action to perform when the threshold of matched traffic within the - configured period is exceeded. - - 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}") - if not rule_id: - raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") - return await self._put( - f"/zones/{zone_id}/firewall/rules/{rule_id}", - body=await async_maybe_transform( - { - "action": action, - "filter": filter, - }, - rule_update_params.RuleUpdateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[FirewallRule]._unwrapper, - ), - cast_to=cast(Type[FirewallRule], ResultWrapper[FirewallRule]), - ) - - @typing_extensions.deprecated( - "The Firewall Rules API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." - ) - def list( - self, - *, - zone_id: str, - id: str | NotGiven = NOT_GIVEN, - action: str | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - page: float | NotGiven = NOT_GIVEN, - paused: bool | NotGiven = NOT_GIVEN, - per_page: float | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[FirewallRule, AsyncV4PagePaginationArray[FirewallRule]]: - """Fetches firewall rules in a zone. - - You can filter the results using several - optional parameters. - - Args: - zone_id: Identifier - - id: The unique identifier of the firewall rule. - - action: The action to search for. Must be an exact match. - - description: A case-insensitive string to find in the description. - - page: Page number of paginated results. - - paused: When true, indicates that the firewall rule is currently paused. - - per_page: Number of firewall rules 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 zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - return self._get_api_list( - f"/zones/{zone_id}/firewall/rules", - page=AsyncV4PagePaginationArray[FirewallRule], - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "id": id, - "action": action, - "description": description, - "page": page, - "paused": paused, - "per_page": per_page, - }, - rule_list_params.RuleListParams, - ), - ), - model=FirewallRule, - ) - - @typing_extensions.deprecated( - "The Firewall Rules API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." - ) - async def delete( - self, - rule_id: str, - *, - zone_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, - ) -> FirewallRule: - """ - Deletes an existing firewall rule. - - Args: - zone_id: Identifier - - rule_id: The unique identifier of the firewall rule. - - 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}") - if not rule_id: - raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") - return await self._delete( - f"/zones/{zone_id}/firewall/rules/{rule_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[FirewallRule]._unwrapper, - ), - cast_to=cast(Type[FirewallRule], ResultWrapper[FirewallRule]), - ) - - @typing_extensions.deprecated( - "The Firewall Rules API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." - ) - async def edit( - self, - rule_id: str, - *, - zone_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[RuleEditResponse]: - """ - Updates the priority of an existing firewall rule. - - Args: - zone_id: Identifier - - rule_id: The unique identifier of the firewall rule. - - 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}") - if not rule_id: - raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") - return await self._patch( - f"/zones/{zone_id}/firewall/rules/{rule_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[RuleEditResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[RuleEditResponse]], ResultWrapper[RuleEditResponse]), - ) - - @typing_extensions.deprecated( - "The Firewall Rules API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details." - ) - async def get( - self, - rule_id: str, - *, - zone_id: str, - id: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> FirewallRule: - """ - Fetches the details of a firewall rule. - - Args: - zone_id: Identifier - - rule_id: The unique identifier of the firewall rule. - - id: The unique identifier of the firewall rule. - - 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}") - if not rule_id: - raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") - return await self._get( - f"/zones/{zone_id}/firewall/rules/{rule_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=await async_maybe_transform({"id": id}, rule_get_params.RuleGetParams), - post_parser=ResultWrapper[FirewallRule]._unwrapper, - ), - cast_to=cast(Type[FirewallRule], ResultWrapper[FirewallRule]), - ) - - -class RulesResourceWithRawResponse: - def __init__(self, rules: RulesResource) -> None: - self._rules = rules - - self.create = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - rules.create # pyright: ignore[reportDeprecated], - ) - ) - self.update = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - rules.update # pyright: ignore[reportDeprecated], - ) - ) - self.list = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - rules.list # pyright: ignore[reportDeprecated], - ) - ) - self.delete = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - rules.delete # pyright: ignore[reportDeprecated], - ) - ) - self.edit = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - rules.edit # pyright: ignore[reportDeprecated], - ) - ) - self.get = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - rules.get # pyright: ignore[reportDeprecated], - ) - ) - - -class AsyncRulesResourceWithRawResponse: - def __init__(self, rules: AsyncRulesResource) -> None: - self._rules = rules - - self.create = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - rules.create # pyright: ignore[reportDeprecated], - ) - ) - self.update = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - rules.update # pyright: ignore[reportDeprecated], - ) - ) - self.list = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - rules.list # pyright: ignore[reportDeprecated], - ) - ) - self.delete = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - rules.delete # pyright: ignore[reportDeprecated], - ) - ) - self.edit = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - rules.edit # pyright: ignore[reportDeprecated], - ) - ) - self.get = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - rules.get # pyright: ignore[reportDeprecated], - ) - ) - - -class RulesResourceWithStreamingResponse: - def __init__(self, rules: RulesResource) -> None: - self._rules = rules - - self.create = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - rules.create # pyright: ignore[reportDeprecated], - ) - ) - self.update = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - rules.update # pyright: ignore[reportDeprecated], - ) - ) - self.list = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - rules.list # pyright: ignore[reportDeprecated], - ) - ) - self.delete = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - rules.delete # pyright: ignore[reportDeprecated], - ) - ) - self.edit = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - rules.edit # pyright: ignore[reportDeprecated], - ) - ) - self.get = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - rules.get # pyright: ignore[reportDeprecated], - ) - ) - - -class AsyncRulesResourceWithStreamingResponse: - def __init__(self, rules: AsyncRulesResource) -> None: - self._rules = rules - - self.create = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - rules.create # pyright: ignore[reportDeprecated], - ) - ) - self.update = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - rules.update # pyright: ignore[reportDeprecated], - ) - ) - self.list = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - rules.list # pyright: ignore[reportDeprecated], - ) - ) - self.delete = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - rules.delete # pyright: ignore[reportDeprecated], - ) - ) - self.edit = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - rules.edit # pyright: ignore[reportDeprecated], - ) - ) - self.get = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - rules.get # pyright: ignore[reportDeprecated], - ) - ) diff --git a/src/cloudflare/resources/firewall/ua_rules.py b/src/cloudflare/resources/firewall/ua_rules.py deleted file mode 100644 index 479799dc555..00000000000 --- a/src/cloudflare/resources/firewall/ua_rules.py +++ /dev/null @@ -1,717 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Any, Type, cast -from typing_extensions import Literal - -import httpx - -from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ..._utils import ( - maybe_transform, - async_maybe_transform, -) -from ..._compat import cached_property -from ..._resource import SyncAPIResource, AsyncAPIResource -from ..._response import ( - to_raw_response_wrapper, - to_streamed_response_wrapper, - async_to_raw_response_wrapper, - async_to_streamed_response_wrapper, -) -from ..._wrappers import ResultWrapper -from ...pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray -from ..._base_client import AsyncPaginator, make_request_options -from ...types.firewall import ua_rule_list_params, ua_rule_create_params, ua_rule_update_params -from ...types.firewall.ua_rule_get_response import UARuleGetResponse -from ...types.firewall.ua_rule_list_response import UARuleListResponse -from ...types.firewall.ua_rule_create_response import UARuleCreateResponse -from ...types.firewall.ua_rule_delete_response import UARuleDeleteResponse -from ...types.firewall.ua_rule_update_response import UARuleUpdateResponse - -__all__ = ["UARulesResource", "AsyncUARulesResource"] - - -class UARulesResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> UARulesResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return the - 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 UARulesResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> UARulesResourceWithStreamingResponse: - """ - 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 UARulesResourceWithStreamingResponse(self) - - def create( - self, - *, - zone_id: str, - configuration: ua_rule_create_params.Configuration, - mode: Literal["block", "challenge", "whitelist", "js_challenge", "managed_challenge"], - # 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, - ) -> UARuleCreateResponse: - """ - Creates a new User Agent Blocking rule in a zone. - - Args: - zone_id: Identifier - - configuration: The rule configuration. - - mode: The action to apply to a matched request. - - 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( - UARuleCreateResponse, - self._post( - f"/zones/{zone_id}/firewall/ua_rules", - body=maybe_transform( - { - "configuration": configuration, - "mode": mode, - }, - ua_rule_create_params.UARuleCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[UARuleCreateResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[UARuleCreateResponse] - ), # Union types cannot be passed in as arguments in the type system - ), - ) - - def update( - self, - ua_rule_id: str, - *, - zone_id: str, - configuration: ua_rule_update_params.Configuration, - mode: Literal["block", "challenge", "whitelist", "js_challenge", "managed_challenge"], - # 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, - ) -> UARuleUpdateResponse: - """ - Updates an existing User Agent Blocking rule. - - Args: - zone_id: Identifier - - ua_rule_id: The unique identifier of the User Agent Blocking rule. - - configuration: The rule configuration. - - mode: The action to apply to a matched request. - - 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}") - if not ua_rule_id: - raise ValueError(f"Expected a non-empty value for `ua_rule_id` but received {ua_rule_id!r}") - return cast( - UARuleUpdateResponse, - self._put( - f"/zones/{zone_id}/firewall/ua_rules/{ua_rule_id}", - body=maybe_transform( - { - "configuration": configuration, - "mode": mode, - }, - ua_rule_update_params.UARuleUpdateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[UARuleUpdateResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[UARuleUpdateResponse] - ), # Union types cannot be passed in as arguments in the type system - ), - ) - - def list( - self, - *, - zone_id: str, - description: str | NotGiven = NOT_GIVEN, - description_search: str | NotGiven = NOT_GIVEN, - page: float | NotGiven = NOT_GIVEN, - per_page: float | NotGiven = NOT_GIVEN, - ua_search: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncV4PagePaginationArray[UARuleListResponse]: - """Fetches User Agent Blocking rules in a zone. - - You can filter the results using - several optional parameters. - - Args: - zone_id: Identifier - - description: A string to search for in the description of existing rules. - - description_search: A string to search for in the description of existing rules. - - page: Page number of paginated results. - - per_page: The maximum number of results per page. You can only set the value to `1` or to - a multiple of 5 such as `5`, `10`, `15`, or `20`. - - ua_search: A string to search for in the user agent values of existing rules. - - 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 self._get_api_list( - f"/zones/{zone_id}/firewall/ua_rules", - page=SyncV4PagePaginationArray[UARuleListResponse], - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "description": description, - "description_search": description_search, - "page": page, - "per_page": per_page, - "ua_search": ua_search, - }, - ua_rule_list_params.UARuleListParams, - ), - ), - model=UARuleListResponse, - ) - - def delete( - self, - ua_rule_id: str, - *, - zone_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, - ) -> UARuleDeleteResponse: - """ - Deletes an existing User Agent Blocking rule. - - Args: - zone_id: Identifier - - ua_rule_id: The unique identifier of the User Agent Blocking rule. - - 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}") - if not ua_rule_id: - raise ValueError(f"Expected a non-empty value for `ua_rule_id` but received {ua_rule_id!r}") - return self._delete( - f"/zones/{zone_id}/firewall/ua_rules/{ua_rule_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[UARuleDeleteResponse]._unwrapper, - ), - cast_to=cast(Type[UARuleDeleteResponse], ResultWrapper[UARuleDeleteResponse]), - ) - - def get( - self, - ua_rule_id: str, - *, - zone_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, - ) -> UARuleGetResponse: - """ - Fetches the details of a User Agent Blocking rule. - - Args: - zone_id: Identifier - - ua_rule_id: The unique identifier of the User Agent Blocking rule. - - 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}") - if not ua_rule_id: - raise ValueError(f"Expected a non-empty value for `ua_rule_id` but received {ua_rule_id!r}") - return cast( - UARuleGetResponse, - self._get( - f"/zones/{zone_id}/firewall/ua_rules/{ua_rule_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[UARuleGetResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[UARuleGetResponse] - ), # Union types cannot be passed in as arguments in the type system - ), - ) - - -class AsyncUARulesResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncUARulesResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return the - 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 AsyncUARulesResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncUARulesResourceWithStreamingResponse: - """ - 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 AsyncUARulesResourceWithStreamingResponse(self) - - async def create( - self, - *, - zone_id: str, - configuration: ua_rule_create_params.Configuration, - mode: Literal["block", "challenge", "whitelist", "js_challenge", "managed_challenge"], - # 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, - ) -> UARuleCreateResponse: - """ - Creates a new User Agent Blocking rule in a zone. - - Args: - zone_id: Identifier - - configuration: The rule configuration. - - mode: The action to apply to a matched request. - - 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( - UARuleCreateResponse, - await self._post( - f"/zones/{zone_id}/firewall/ua_rules", - body=await async_maybe_transform( - { - "configuration": configuration, - "mode": mode, - }, - ua_rule_create_params.UARuleCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[UARuleCreateResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[UARuleCreateResponse] - ), # Union types cannot be passed in as arguments in the type system - ), - ) - - async def update( - self, - ua_rule_id: str, - *, - zone_id: str, - configuration: ua_rule_update_params.Configuration, - mode: Literal["block", "challenge", "whitelist", "js_challenge", "managed_challenge"], - # 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, - ) -> UARuleUpdateResponse: - """ - Updates an existing User Agent Blocking rule. - - Args: - zone_id: Identifier - - ua_rule_id: The unique identifier of the User Agent Blocking rule. - - configuration: The rule configuration. - - mode: The action to apply to a matched request. - - 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}") - if not ua_rule_id: - raise ValueError(f"Expected a non-empty value for `ua_rule_id` but received {ua_rule_id!r}") - return cast( - UARuleUpdateResponse, - await self._put( - f"/zones/{zone_id}/firewall/ua_rules/{ua_rule_id}", - body=await async_maybe_transform( - { - "configuration": configuration, - "mode": mode, - }, - ua_rule_update_params.UARuleUpdateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[UARuleUpdateResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[UARuleUpdateResponse] - ), # Union types cannot be passed in as arguments in the type system - ), - ) - - def list( - self, - *, - zone_id: str, - description: str | NotGiven = NOT_GIVEN, - description_search: str | NotGiven = NOT_GIVEN, - page: float | NotGiven = NOT_GIVEN, - per_page: float | NotGiven = NOT_GIVEN, - ua_search: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[UARuleListResponse, AsyncV4PagePaginationArray[UARuleListResponse]]: - """Fetches User Agent Blocking rules in a zone. - - You can filter the results using - several optional parameters. - - Args: - zone_id: Identifier - - description: A string to search for in the description of existing rules. - - description_search: A string to search for in the description of existing rules. - - page: Page number of paginated results. - - per_page: The maximum number of results per page. You can only set the value to `1` or to - a multiple of 5 such as `5`, `10`, `15`, or `20`. - - ua_search: A string to search for in the user agent values of existing rules. - - 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 self._get_api_list( - f"/zones/{zone_id}/firewall/ua_rules", - page=AsyncV4PagePaginationArray[UARuleListResponse], - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "description": description, - "description_search": description_search, - "page": page, - "per_page": per_page, - "ua_search": ua_search, - }, - ua_rule_list_params.UARuleListParams, - ), - ), - model=UARuleListResponse, - ) - - async def delete( - self, - ua_rule_id: str, - *, - zone_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, - ) -> UARuleDeleteResponse: - """ - Deletes an existing User Agent Blocking rule. - - Args: - zone_id: Identifier - - ua_rule_id: The unique identifier of the User Agent Blocking rule. - - 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}") - if not ua_rule_id: - raise ValueError(f"Expected a non-empty value for `ua_rule_id` but received {ua_rule_id!r}") - return await self._delete( - f"/zones/{zone_id}/firewall/ua_rules/{ua_rule_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[UARuleDeleteResponse]._unwrapper, - ), - cast_to=cast(Type[UARuleDeleteResponse], ResultWrapper[UARuleDeleteResponse]), - ) - - async def get( - self, - ua_rule_id: str, - *, - zone_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, - ) -> UARuleGetResponse: - """ - Fetches the details of a User Agent Blocking rule. - - Args: - zone_id: Identifier - - ua_rule_id: The unique identifier of the User Agent Blocking rule. - - 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}") - if not ua_rule_id: - raise ValueError(f"Expected a non-empty value for `ua_rule_id` but received {ua_rule_id!r}") - return cast( - UARuleGetResponse, - await self._get( - f"/zones/{zone_id}/firewall/ua_rules/{ua_rule_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[UARuleGetResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[UARuleGetResponse] - ), # Union types cannot be passed in as arguments in the type system - ), - ) - - -class UARulesResourceWithRawResponse: - def __init__(self, ua_rules: UARulesResource) -> None: - self._ua_rules = ua_rules - - self.create = to_raw_response_wrapper( - ua_rules.create, - ) - self.update = to_raw_response_wrapper( - ua_rules.update, - ) - self.list = to_raw_response_wrapper( - ua_rules.list, - ) - self.delete = to_raw_response_wrapper( - ua_rules.delete, - ) - self.get = to_raw_response_wrapper( - ua_rules.get, - ) - - -class AsyncUARulesResourceWithRawResponse: - def __init__(self, ua_rules: AsyncUARulesResource) -> None: - self._ua_rules = ua_rules - - self.create = async_to_raw_response_wrapper( - ua_rules.create, - ) - self.update = async_to_raw_response_wrapper( - ua_rules.update, - ) - self.list = async_to_raw_response_wrapper( - ua_rules.list, - ) - self.delete = async_to_raw_response_wrapper( - ua_rules.delete, - ) - self.get = async_to_raw_response_wrapper( - ua_rules.get, - ) - - -class UARulesResourceWithStreamingResponse: - def __init__(self, ua_rules: UARulesResource) -> None: - self._ua_rules = ua_rules - - self.create = to_streamed_response_wrapper( - ua_rules.create, - ) - self.update = to_streamed_response_wrapper( - ua_rules.update, - ) - self.list = to_streamed_response_wrapper( - ua_rules.list, - ) - self.delete = to_streamed_response_wrapper( - ua_rules.delete, - ) - self.get = to_streamed_response_wrapper( - ua_rules.get, - ) - - -class AsyncUARulesResourceWithStreamingResponse: - def __init__(self, ua_rules: AsyncUARulesResource) -> None: - self._ua_rules = ua_rules - - self.create = async_to_streamed_response_wrapper( - ua_rules.create, - ) - self.update = async_to_streamed_response_wrapper( - ua_rules.update, - ) - self.list = async_to_streamed_response_wrapper( - ua_rules.list, - ) - self.delete = async_to_streamed_response_wrapper( - ua_rules.delete, - ) - self.get = async_to_streamed_response_wrapper( - ua_rules.get, - ) diff --git a/src/cloudflare/resources/firewall/waf/__init__.py b/src/cloudflare/resources/firewall/waf/__init__.py index 03886bfc2c7..0a8c544fa65 100644 --- a/src/cloudflare/resources/firewall/waf/__init__.py +++ b/src/cloudflare/resources/firewall/waf/__init__.py @@ -16,22 +16,8 @@ PackagesResourceWithStreamingResponse, AsyncPackagesResourceWithStreamingResponse, ) -from .overrides import ( - OverridesResource, - AsyncOverridesResource, - OverridesResourceWithRawResponse, - AsyncOverridesResourceWithRawResponse, - OverridesResourceWithStreamingResponse, - AsyncOverridesResourceWithStreamingResponse, -) __all__ = [ - "OverridesResource", - "AsyncOverridesResource", - "OverridesResourceWithRawResponse", - "AsyncOverridesResourceWithRawResponse", - "OverridesResourceWithStreamingResponse", - "AsyncOverridesResourceWithStreamingResponse", "PackagesResource", "AsyncPackagesResource", "PackagesResourceWithRawResponse", diff --git a/src/cloudflare/resources/firewall/waf/overrides.py b/src/cloudflare/resources/firewall/waf/overrides.py deleted file mode 100644 index b7c1fb54be7..00000000000 --- a/src/cloudflare/resources/firewall/waf/overrides.py +++ /dev/null @@ -1,706 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import List, Type, Optional, cast - -import httpx - -from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ...._utils import ( - maybe_transform, - async_maybe_transform, -) -from ...._compat import cached_property -from ...._resource import SyncAPIResource, AsyncAPIResource -from ...._response import ( - to_raw_response_wrapper, - to_streamed_response_wrapper, - async_to_raw_response_wrapper, - async_to_streamed_response_wrapper, -) -from ...._wrappers import ResultWrapper -from ....pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray -from ...._base_client import AsyncPaginator, make_request_options -from ....types.firewall.waf import ( - override_list_params, - override_create_params, - override_update_params, -) -from ....types.firewall.waf.override import Override -from ....types.firewall.waf.override_url import OverrideURL -from ....types.firewall.waf.waf_rule_param import WAFRuleParam -from ....types.firewall.waf.rewrite_action_param import RewriteActionParam -from ....types.firewall.waf.override_delete_response import OverrideDeleteResponse - -__all__ = ["OverridesResource", "AsyncOverridesResource"] - - -class OverridesResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> OverridesResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return the - 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 OverridesResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> OverridesResourceWithStreamingResponse: - """ - 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 OverridesResourceWithStreamingResponse(self) - - def create( - self, - *, - zone_id: str, - urls: List[OverrideURL], - # 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, - ) -> Override: - """ - Creates a URI-based WAF override for a zone. - - **Note:** Applies only to the - [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). - - Args: - zone_id: Identifier - - urls: The URLs to include in the current WAF override. You can use wildcards. Each - entered URL will be escaped before use, which means you can only use simple - wildcard patterns. - - 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 self._post( - f"/zones/{zone_id}/firewall/waf/overrides", - body=maybe_transform({"urls": urls}, override_create_params.OverrideCreateParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Override]._unwrapper, - ), - cast_to=cast(Type[Override], ResultWrapper[Override]), - ) - - def update( - self, - overrides_id: str, - *, - zone_id: str, - id: str, - rewrite_action: RewriteActionParam, - rules: WAFRuleParam, - urls: List[OverrideURL], - # 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, - ) -> Override: - """ - Updates an existing URI-based WAF override. - - **Note:** Applies only to the - [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). - - Args: - zone_id: Identifier - - overrides_id: The unique identifier of the WAF override. - - id: Identifier - - rewrite_action: Specifies that, when a WAF rule matches, its configured action will be replaced - by the action configured in this object. - - rules: An object that allows you to override the action of specific WAF rules. Each key - of this object must be the ID of a WAF rule, and each value must be a valid WAF - action. Unless you are disabling a rule, ensure that you also enable the rule - group that this WAF rule belongs to. When creating a new URI-based WAF override, - you must provide a `groups` object or a `rules` object. - - urls: The URLs to include in the current WAF override. You can use wildcards. Each - entered URL will be escaped before use, which means you can only use simple - wildcard patterns. - - 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}") - if not overrides_id: - raise ValueError(f"Expected a non-empty value for `overrides_id` but received {overrides_id!r}") - return self._put( - f"/zones/{zone_id}/firewall/waf/overrides/{overrides_id}", - body=maybe_transform( - { - "id": id, - "rewrite_action": rewrite_action, - "rules": rules, - "urls": urls, - }, - override_update_params.OverrideUpdateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Override]._unwrapper, - ), - cast_to=cast(Type[Override], ResultWrapper[Override]), - ) - - def list( - self, - *, - zone_id: str, - page: float | NotGiven = NOT_GIVEN, - per_page: float | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncV4PagePaginationArray[Override]: - """ - Fetches the URI-based WAF overrides in a zone. - - **Note:** Applies only to the - [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). - - Args: - zone_id: Identifier - - page: The page number of paginated results. - - per_page: The number of WAF overrides 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 zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - return self._get_api_list( - f"/zones/{zone_id}/firewall/waf/overrides", - page=SyncV4PagePaginationArray[Override], - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "page": page, - "per_page": per_page, - }, - override_list_params.OverrideListParams, - ), - ), - model=Override, - ) - - def delete( - self, - overrides_id: str, - *, - zone_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[OverrideDeleteResponse]: - """ - Deletes an existing URI-based WAF override. - - **Note:** Applies only to the - [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). - - Args: - zone_id: Identifier - - overrides_id: The unique identifier of the WAF override. - - 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}") - if not overrides_id: - raise ValueError(f"Expected a non-empty value for `overrides_id` but received {overrides_id!r}") - return self._delete( - f"/zones/{zone_id}/firewall/waf/overrides/{overrides_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[OverrideDeleteResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[OverrideDeleteResponse]], ResultWrapper[OverrideDeleteResponse]), - ) - - def get( - self, - overrides_id: str, - *, - zone_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, - ) -> Override: - """ - Fetches the details of a URI-based WAF override. - - **Note:** Applies only to the - [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). - - Args: - zone_id: Identifier - - overrides_id: The unique identifier of the WAF override. - - 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}") - if not overrides_id: - raise ValueError(f"Expected a non-empty value for `overrides_id` but received {overrides_id!r}") - return self._get( - f"/zones/{zone_id}/firewall/waf/overrides/{overrides_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Override]._unwrapper, - ), - cast_to=cast(Type[Override], ResultWrapper[Override]), - ) - - -class AsyncOverridesResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncOverridesResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return the - 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 AsyncOverridesResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncOverridesResourceWithStreamingResponse: - """ - 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 AsyncOverridesResourceWithStreamingResponse(self) - - async def create( - self, - *, - zone_id: str, - urls: List[OverrideURL], - # 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, - ) -> Override: - """ - Creates a URI-based WAF override for a zone. - - **Note:** Applies only to the - [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). - - Args: - zone_id: Identifier - - urls: The URLs to include in the current WAF override. You can use wildcards. Each - entered URL will be escaped before use, which means you can only use simple - wildcard patterns. - - 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 await self._post( - f"/zones/{zone_id}/firewall/waf/overrides", - body=await async_maybe_transform({"urls": urls}, override_create_params.OverrideCreateParams), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Override]._unwrapper, - ), - cast_to=cast(Type[Override], ResultWrapper[Override]), - ) - - async def update( - self, - overrides_id: str, - *, - zone_id: str, - id: str, - rewrite_action: RewriteActionParam, - rules: WAFRuleParam, - urls: List[OverrideURL], - # 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, - ) -> Override: - """ - Updates an existing URI-based WAF override. - - **Note:** Applies only to the - [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). - - Args: - zone_id: Identifier - - overrides_id: The unique identifier of the WAF override. - - id: Identifier - - rewrite_action: Specifies that, when a WAF rule matches, its configured action will be replaced - by the action configured in this object. - - rules: An object that allows you to override the action of specific WAF rules. Each key - of this object must be the ID of a WAF rule, and each value must be a valid WAF - action. Unless you are disabling a rule, ensure that you also enable the rule - group that this WAF rule belongs to. When creating a new URI-based WAF override, - you must provide a `groups` object or a `rules` object. - - urls: The URLs to include in the current WAF override. You can use wildcards. Each - entered URL will be escaped before use, which means you can only use simple - wildcard patterns. - - 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}") - if not overrides_id: - raise ValueError(f"Expected a non-empty value for `overrides_id` but received {overrides_id!r}") - return await self._put( - f"/zones/{zone_id}/firewall/waf/overrides/{overrides_id}", - body=await async_maybe_transform( - { - "id": id, - "rewrite_action": rewrite_action, - "rules": rules, - "urls": urls, - }, - override_update_params.OverrideUpdateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Override]._unwrapper, - ), - cast_to=cast(Type[Override], ResultWrapper[Override]), - ) - - def list( - self, - *, - zone_id: str, - page: float | NotGiven = NOT_GIVEN, - per_page: float | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[Override, AsyncV4PagePaginationArray[Override]]: - """ - Fetches the URI-based WAF overrides in a zone. - - **Note:** Applies only to the - [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). - - Args: - zone_id: Identifier - - page: The page number of paginated results. - - per_page: The number of WAF overrides 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 zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - return self._get_api_list( - f"/zones/{zone_id}/firewall/waf/overrides", - page=AsyncV4PagePaginationArray[Override], - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "page": page, - "per_page": per_page, - }, - override_list_params.OverrideListParams, - ), - ), - model=Override, - ) - - async def delete( - self, - overrides_id: str, - *, - zone_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[OverrideDeleteResponse]: - """ - Deletes an existing URI-based WAF override. - - **Note:** Applies only to the - [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). - - Args: - zone_id: Identifier - - overrides_id: The unique identifier of the WAF override. - - 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}") - if not overrides_id: - raise ValueError(f"Expected a non-empty value for `overrides_id` but received {overrides_id!r}") - return await self._delete( - f"/zones/{zone_id}/firewall/waf/overrides/{overrides_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[OverrideDeleteResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[OverrideDeleteResponse]], ResultWrapper[OverrideDeleteResponse]), - ) - - async def get( - self, - overrides_id: str, - *, - zone_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, - ) -> Override: - """ - Fetches the details of a URI-based WAF override. - - **Note:** Applies only to the - [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). - - Args: - zone_id: Identifier - - overrides_id: The unique identifier of the WAF override. - - 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}") - if not overrides_id: - raise ValueError(f"Expected a non-empty value for `overrides_id` but received {overrides_id!r}") - return await self._get( - f"/zones/{zone_id}/firewall/waf/overrides/{overrides_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Override]._unwrapper, - ), - cast_to=cast(Type[Override], ResultWrapper[Override]), - ) - - -class OverridesResourceWithRawResponse: - def __init__(self, overrides: OverridesResource) -> None: - self._overrides = overrides - - self.create = to_raw_response_wrapper( - overrides.create, - ) - self.update = to_raw_response_wrapper( - overrides.update, - ) - self.list = to_raw_response_wrapper( - overrides.list, - ) - self.delete = to_raw_response_wrapper( - overrides.delete, - ) - self.get = to_raw_response_wrapper( - overrides.get, - ) - - -class AsyncOverridesResourceWithRawResponse: - def __init__(self, overrides: AsyncOverridesResource) -> None: - self._overrides = overrides - - self.create = async_to_raw_response_wrapper( - overrides.create, - ) - self.update = async_to_raw_response_wrapper( - overrides.update, - ) - self.list = async_to_raw_response_wrapper( - overrides.list, - ) - self.delete = async_to_raw_response_wrapper( - overrides.delete, - ) - self.get = async_to_raw_response_wrapper( - overrides.get, - ) - - -class OverridesResourceWithStreamingResponse: - def __init__(self, overrides: OverridesResource) -> None: - self._overrides = overrides - - self.create = to_streamed_response_wrapper( - overrides.create, - ) - self.update = to_streamed_response_wrapper( - overrides.update, - ) - self.list = to_streamed_response_wrapper( - overrides.list, - ) - self.delete = to_streamed_response_wrapper( - overrides.delete, - ) - self.get = to_streamed_response_wrapper( - overrides.get, - ) - - -class AsyncOverridesResourceWithStreamingResponse: - def __init__(self, overrides: AsyncOverridesResource) -> None: - self._overrides = overrides - - self.create = async_to_streamed_response_wrapper( - overrides.create, - ) - self.update = async_to_streamed_response_wrapper( - overrides.update, - ) - self.list = async_to_streamed_response_wrapper( - overrides.list, - ) - self.delete = async_to_streamed_response_wrapper( - overrides.delete, - ) - self.get = async_to_streamed_response_wrapper( - overrides.get, - ) diff --git a/src/cloudflare/resources/firewall/waf/packages/packages.py b/src/cloudflare/resources/firewall/waf/packages/packages.py index fcbc3cbbba8..fc04985529c 100644 --- a/src/cloudflare/resources/firewall/waf/packages/packages.py +++ b/src/cloudflare/resources/firewall/waf/packages/packages.py @@ -2,11 +2,6 @@ from __future__ import annotations -from typing import Any, cast -from typing_extensions import Literal - -import httpx - from .rules import ( RulesResource, AsyncRulesResource, @@ -23,20 +18,8 @@ GroupsResourceWithStreamingResponse, AsyncGroupsResourceWithStreamingResponse, ) -from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ....._utils import maybe_transform from ....._compat import cached_property from ....._resource import SyncAPIResource, AsyncAPIResource -from ....._response import ( - to_raw_response_wrapper, - to_streamed_response_wrapper, - async_to_raw_response_wrapper, - async_to_streamed_response_wrapper, -) -from .....pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray -from ....._base_client import AsyncPaginator, make_request_options -from .....types.firewall.waf import package_list_params -from .....types.firewall.waf.package_get_response import PackageGetResponse __all__ = ["PackagesResource", "AsyncPackagesResource"] @@ -69,126 +52,6 @@ def with_streaming_response(self) -> PackagesResourceWithStreamingResponse: """ return PackagesResourceWithStreamingResponse(self) - def list( - self, - *, - zone_id: str, - direction: Literal["asc", "desc"] | NotGiven = NOT_GIVEN, - match: Literal["any", "all"] | NotGiven = NOT_GIVEN, - name: str | NotGiven = NOT_GIVEN, - order: Literal["name"] | NotGiven = NOT_GIVEN, - page: float | NotGiven = NOT_GIVEN, - per_page: float | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncV4PagePaginationArray[object]: - """ - Fetches WAF packages for a zone. - - **Note:** Applies only to the - [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). - - Args: - zone_id: Identifier - - direction: The direction used to sort returned packages. - - match: When set to `all`, all the search requirements must match. When set to `any`, - only one of the search requirements has to match. - - name: The name of the WAF package. - - order: The field used to sort returned packages. - - page: The page number of paginated results. - - per_page: The number of packages 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 zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - return self._get_api_list( - f"/zones/{zone_id}/firewall/waf/packages", - page=SyncV4PagePaginationArray[object], - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "direction": direction, - "match": match, - "name": name, - "order": order, - "page": page, - "per_page": per_page, - }, - package_list_params.PackageListParams, - ), - ), - model=object, - ) - - def get( - self, - package_id: str, - *, - zone_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, - ) -> PackageGetResponse: - """ - Fetches the details of a WAF package. - - **Note:** Applies only to the - [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). - - Args: - zone_id: Identifier - - package_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 zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not package_id: - raise ValueError(f"Expected a non-empty value for `package_id` but received {package_id!r}") - return cast( - PackageGetResponse, - self._get( - f"/zones/{zone_id}/firewall/waf/packages/{package_id}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=cast( - Any, PackageGetResponse - ), # Union types cannot be passed in as arguments in the type system - ), - ) - class AsyncPackagesResource(AsyncAPIResource): @cached_property @@ -218,138 +81,11 @@ def with_streaming_response(self) -> AsyncPackagesResourceWithStreamingResponse: """ return AsyncPackagesResourceWithStreamingResponse(self) - def list( - self, - *, - zone_id: str, - direction: Literal["asc", "desc"] | NotGiven = NOT_GIVEN, - match: Literal["any", "all"] | NotGiven = NOT_GIVEN, - name: str | NotGiven = NOT_GIVEN, - order: Literal["name"] | NotGiven = NOT_GIVEN, - page: float | NotGiven = NOT_GIVEN, - per_page: float | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[object, AsyncV4PagePaginationArray[object]]: - """ - Fetches WAF packages for a zone. - - **Note:** Applies only to the - [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). - - Args: - zone_id: Identifier - - direction: The direction used to sort returned packages. - - match: When set to `all`, all the search requirements must match. When set to `any`, - only one of the search requirements has to match. - - name: The name of the WAF package. - - order: The field used to sort returned packages. - - page: The page number of paginated results. - - per_page: The number of packages 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 zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - return self._get_api_list( - f"/zones/{zone_id}/firewall/waf/packages", - page=AsyncV4PagePaginationArray[object], - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "direction": direction, - "match": match, - "name": name, - "order": order, - "page": page, - "per_page": per_page, - }, - package_list_params.PackageListParams, - ), - ), - model=object, - ) - - async def get( - self, - package_id: str, - *, - zone_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, - ) -> PackageGetResponse: - """ - Fetches the details of a WAF package. - - **Note:** Applies only to the - [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). - - Args: - zone_id: Identifier - - package_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 zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not package_id: - raise ValueError(f"Expected a non-empty value for `package_id` but received {package_id!r}") - return cast( - PackageGetResponse, - await self._get( - f"/zones/{zone_id}/firewall/waf/packages/{package_id}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=cast( - Any, PackageGetResponse - ), # Union types cannot be passed in as arguments in the type system - ), - ) - class PackagesResourceWithRawResponse: def __init__(self, packages: PackagesResource) -> None: self._packages = packages - self.list = to_raw_response_wrapper( - packages.list, - ) - self.get = to_raw_response_wrapper( - packages.get, - ) - @cached_property def groups(self) -> GroupsResourceWithRawResponse: return GroupsResourceWithRawResponse(self._packages.groups) @@ -363,13 +99,6 @@ class AsyncPackagesResourceWithRawResponse: def __init__(self, packages: AsyncPackagesResource) -> None: self._packages = packages - self.list = async_to_raw_response_wrapper( - packages.list, - ) - self.get = async_to_raw_response_wrapper( - packages.get, - ) - @cached_property def groups(self) -> AsyncGroupsResourceWithRawResponse: return AsyncGroupsResourceWithRawResponse(self._packages.groups) @@ -383,13 +112,6 @@ class PackagesResourceWithStreamingResponse: def __init__(self, packages: PackagesResource) -> None: self._packages = packages - self.list = to_streamed_response_wrapper( - packages.list, - ) - self.get = to_streamed_response_wrapper( - packages.get, - ) - @cached_property def groups(self) -> GroupsResourceWithStreamingResponse: return GroupsResourceWithStreamingResponse(self._packages.groups) @@ -403,13 +125,6 @@ class AsyncPackagesResourceWithStreamingResponse: def __init__(self, packages: AsyncPackagesResource) -> None: self._packages = packages - self.list = async_to_streamed_response_wrapper( - packages.list, - ) - self.get = async_to_streamed_response_wrapper( - packages.get, - ) - @cached_property def groups(self) -> AsyncGroupsResourceWithStreamingResponse: return AsyncGroupsResourceWithStreamingResponse(self._packages.groups) diff --git a/src/cloudflare/resources/firewall/waf/waf.py b/src/cloudflare/resources/firewall/waf/waf.py index 12d89bef38b..42778b033ee 100644 --- a/src/cloudflare/resources/firewall/waf/waf.py +++ b/src/cloudflare/resources/firewall/waf/waf.py @@ -10,14 +10,6 @@ PackagesResourceWithStreamingResponse, AsyncPackagesResourceWithStreamingResponse, ) -from .overrides import ( - OverridesResource, - AsyncOverridesResource, - OverridesResourceWithRawResponse, - AsyncOverridesResourceWithRawResponse, - OverridesResourceWithStreamingResponse, - AsyncOverridesResourceWithStreamingResponse, -) from ...._compat import cached_property from ...._resource import SyncAPIResource, AsyncAPIResource from .packages.packages import PackagesResource, AsyncPackagesResource @@ -26,10 +18,6 @@ class WAFResource(SyncAPIResource): - @cached_property - def overrides(self) -> OverridesResource: - return OverridesResource(self._client) - @cached_property def packages(self) -> PackagesResource: return PackagesResource(self._client) @@ -55,10 +43,6 @@ def with_streaming_response(self) -> WAFResourceWithStreamingResponse: class AsyncWAFResource(AsyncAPIResource): - @cached_property - def overrides(self) -> AsyncOverridesResource: - return AsyncOverridesResource(self._client) - @cached_property def packages(self) -> AsyncPackagesResource: return AsyncPackagesResource(self._client) @@ -87,10 +71,6 @@ class WAFResourceWithRawResponse: def __init__(self, waf: WAFResource) -> None: self._waf = waf - @cached_property - def overrides(self) -> OverridesResourceWithRawResponse: - return OverridesResourceWithRawResponse(self._waf.overrides) - @cached_property def packages(self) -> PackagesResourceWithRawResponse: return PackagesResourceWithRawResponse(self._waf.packages) @@ -100,10 +80,6 @@ class AsyncWAFResourceWithRawResponse: def __init__(self, waf: AsyncWAFResource) -> None: self._waf = waf - @cached_property - def overrides(self) -> AsyncOverridesResourceWithRawResponse: - return AsyncOverridesResourceWithRawResponse(self._waf.overrides) - @cached_property def packages(self) -> AsyncPackagesResourceWithRawResponse: return AsyncPackagesResourceWithRawResponse(self._waf.packages) @@ -113,10 +89,6 @@ class WAFResourceWithStreamingResponse: def __init__(self, waf: WAFResource) -> None: self._waf = waf - @cached_property - def overrides(self) -> OverridesResourceWithStreamingResponse: - return OverridesResourceWithStreamingResponse(self._waf.overrides) - @cached_property def packages(self) -> PackagesResourceWithStreamingResponse: return PackagesResourceWithStreamingResponse(self._waf.packages) @@ -126,10 +98,6 @@ class AsyncWAFResourceWithStreamingResponse: def __init__(self, waf: AsyncWAFResource) -> None: self._waf = waf - @cached_property - def overrides(self) -> AsyncOverridesResourceWithStreamingResponse: - return AsyncOverridesResourceWithStreamingResponse(self._waf.overrides) - @cached_property def packages(self) -> AsyncPackagesResourceWithStreamingResponse: return AsyncPackagesResourceWithStreamingResponse(self._waf.packages) diff --git a/src/cloudflare/resources/rate_limits.py b/src/cloudflare/resources/rate_limits.py deleted file mode 100644 index 131285b95af..00000000000 --- a/src/cloudflare/resources/rate_limits.py +++ /dev/null @@ -1,778 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import typing_extensions -from typing import Type, cast - -import httpx - -from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from .._utils import ( - maybe_transform, - async_maybe_transform, -) -from .._compat import cached_property -from .._resource import SyncAPIResource, AsyncAPIResource -from .._response import ( - to_raw_response_wrapper, - to_streamed_response_wrapper, - async_to_raw_response_wrapper, - async_to_streamed_response_wrapper, -) -from .._wrappers import ResultWrapper -from ..pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray -from .._base_client import AsyncPaginator, make_request_options -from ..types.rate_limits import rate_limit_edit_params, rate_limit_list_params, rate_limit_create_params -from ..types.rate_limits.rate_limit import RateLimit -from ..types.rate_limits.rate_limit_delete_response import RateLimitDeleteResponse - -__all__ = ["RateLimitsResource", "AsyncRateLimitsResource"] - - -class RateLimitsResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> RateLimitsResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return the - 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 RateLimitsResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> RateLimitsResourceWithStreamingResponse: - """ - 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 RateLimitsResourceWithStreamingResponse(self) - - @typing_extensions.deprecated( - "Rate limiting API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#rate-limiting-api-previous-version for full details." - ) - def create( - self, - *, - zone_id: str, - action: rate_limit_create_params.Action, - match: rate_limit_create_params.Match, - period: float, - threshold: float, - # 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, - ) -> RateLimit: - """Creates a new rate limit for a zone. - - Refer to the object definition for a list - of required attributes. - - Args: - zone_id: Identifier - - action: The action to perform when the threshold of matched traffic within the - configured period is exceeded. - - match: Determines which traffic the rate limit counts towards the threshold. - - period: The time in seconds (an integer value) to count matching traffic. If the count - exceeds the configured threshold within this period, Cloudflare will perform the - configured action. - - threshold: The threshold that will trigger the configured mitigation action. Configure this - value along with the `period` property to establish a threshold per period. - - 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 self._post( - f"/zones/{zone_id}/rate_limits", - body=maybe_transform( - { - "action": action, - "match": match, - "period": period, - "threshold": threshold, - }, - rate_limit_create_params.RateLimitCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RateLimit]._unwrapper, - ), - cast_to=cast(Type[RateLimit], ResultWrapper[RateLimit]), - ) - - @typing_extensions.deprecated( - "Rate limiting API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#rate-limiting-api-previous-version for full details." - ) - def list( - self, - *, - zone_id: str, - page: float | NotGiven = NOT_GIVEN, - per_page: float | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncV4PagePaginationArray[RateLimit]: - """ - Fetches the rate limits for a zone. - - Args: - zone_id: Identifier - - page: The page number of paginated results. - - per_page: The maximum number of results per page. You can only set the value to `1` or to - a multiple of 5 such as `5`, `10`, `15`, or `20`. - - 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 self._get_api_list( - f"/zones/{zone_id}/rate_limits", - page=SyncV4PagePaginationArray[RateLimit], - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "page": page, - "per_page": per_page, - }, - rate_limit_list_params.RateLimitListParams, - ), - ), - model=RateLimit, - ) - - @typing_extensions.deprecated( - "Rate limiting API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#rate-limiting-api-previous-version for full details." - ) - def delete( - self, - rate_limit_id: str, - *, - zone_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, - ) -> RateLimitDeleteResponse: - """ - Deletes an existing rate limit. - - Args: - zone_id: Identifier - - rate_limit_id: The unique identifier of the rate limit. - - 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}") - if not rate_limit_id: - raise ValueError(f"Expected a non-empty value for `rate_limit_id` but received {rate_limit_id!r}") - return self._delete( - f"/zones/{zone_id}/rate_limits/{rate_limit_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RateLimitDeleteResponse]._unwrapper, - ), - cast_to=cast(Type[RateLimitDeleteResponse], ResultWrapper[RateLimitDeleteResponse]), - ) - - @typing_extensions.deprecated( - "Rate limiting API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#rate-limiting-api-previous-version for full details." - ) - def edit( - self, - rate_limit_id: str, - *, - zone_id: str, - action: rate_limit_edit_params.Action, - match: rate_limit_edit_params.Match, - period: float, - threshold: float, - # 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, - ) -> RateLimit: - """ - Updates an existing rate limit. - - Args: - zone_id: Identifier - - rate_limit_id: The unique identifier of the rate limit. - - action: The action to perform when the threshold of matched traffic within the - configured period is exceeded. - - match: Determines which traffic the rate limit counts towards the threshold. - - period: The time in seconds (an integer value) to count matching traffic. If the count - exceeds the configured threshold within this period, Cloudflare will perform the - configured action. - - threshold: The threshold that will trigger the configured mitigation action. Configure this - value along with the `period` property to establish a threshold per period. - - 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}") - if not rate_limit_id: - raise ValueError(f"Expected a non-empty value for `rate_limit_id` but received {rate_limit_id!r}") - return self._put( - f"/zones/{zone_id}/rate_limits/{rate_limit_id}", - body=maybe_transform( - { - "action": action, - "match": match, - "period": period, - "threshold": threshold, - }, - rate_limit_edit_params.RateLimitEditParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RateLimit]._unwrapper, - ), - cast_to=cast(Type[RateLimit], ResultWrapper[RateLimit]), - ) - - @typing_extensions.deprecated( - "Rate limiting API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#rate-limiting-api-previous-version for full details." - ) - def get( - self, - rate_limit_id: str, - *, - zone_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, - ) -> RateLimit: - """ - Fetches the details of a rate limit. - - Args: - zone_id: Identifier - - rate_limit_id: The unique identifier of the rate limit. - - 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}") - if not rate_limit_id: - raise ValueError(f"Expected a non-empty value for `rate_limit_id` but received {rate_limit_id!r}") - return self._get( - f"/zones/{zone_id}/rate_limits/{rate_limit_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RateLimit]._unwrapper, - ), - cast_to=cast(Type[RateLimit], ResultWrapper[RateLimit]), - ) - - -class AsyncRateLimitsResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncRateLimitsResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return the - 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 AsyncRateLimitsResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncRateLimitsResourceWithStreamingResponse: - """ - 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 AsyncRateLimitsResourceWithStreamingResponse(self) - - @typing_extensions.deprecated( - "Rate limiting API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#rate-limiting-api-previous-version for full details." - ) - async def create( - self, - *, - zone_id: str, - action: rate_limit_create_params.Action, - match: rate_limit_create_params.Match, - period: float, - threshold: float, - # 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, - ) -> RateLimit: - """Creates a new rate limit for a zone. - - Refer to the object definition for a list - of required attributes. - - Args: - zone_id: Identifier - - action: The action to perform when the threshold of matched traffic within the - configured period is exceeded. - - match: Determines which traffic the rate limit counts towards the threshold. - - period: The time in seconds (an integer value) to count matching traffic. If the count - exceeds the configured threshold within this period, Cloudflare will perform the - configured action. - - threshold: The threshold that will trigger the configured mitigation action. Configure this - value along with the `period` property to establish a threshold per period. - - 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 await self._post( - f"/zones/{zone_id}/rate_limits", - body=await async_maybe_transform( - { - "action": action, - "match": match, - "period": period, - "threshold": threshold, - }, - rate_limit_create_params.RateLimitCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RateLimit]._unwrapper, - ), - cast_to=cast(Type[RateLimit], ResultWrapper[RateLimit]), - ) - - @typing_extensions.deprecated( - "Rate limiting API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#rate-limiting-api-previous-version for full details." - ) - def list( - self, - *, - zone_id: str, - page: float | NotGiven = NOT_GIVEN, - per_page: float | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[RateLimit, AsyncV4PagePaginationArray[RateLimit]]: - """ - Fetches the rate limits for a zone. - - Args: - zone_id: Identifier - - page: The page number of paginated results. - - per_page: The maximum number of results per page. You can only set the value to `1` or to - a multiple of 5 such as `5`, `10`, `15`, or `20`. - - 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 self._get_api_list( - f"/zones/{zone_id}/rate_limits", - page=AsyncV4PagePaginationArray[RateLimit], - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "page": page, - "per_page": per_page, - }, - rate_limit_list_params.RateLimitListParams, - ), - ), - model=RateLimit, - ) - - @typing_extensions.deprecated( - "Rate limiting API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#rate-limiting-api-previous-version for full details." - ) - async def delete( - self, - rate_limit_id: str, - *, - zone_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, - ) -> RateLimitDeleteResponse: - """ - Deletes an existing rate limit. - - Args: - zone_id: Identifier - - rate_limit_id: The unique identifier of the rate limit. - - 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}") - if not rate_limit_id: - raise ValueError(f"Expected a non-empty value for `rate_limit_id` but received {rate_limit_id!r}") - return await self._delete( - f"/zones/{zone_id}/rate_limits/{rate_limit_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RateLimitDeleteResponse]._unwrapper, - ), - cast_to=cast(Type[RateLimitDeleteResponse], ResultWrapper[RateLimitDeleteResponse]), - ) - - @typing_extensions.deprecated( - "Rate limiting API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#rate-limiting-api-previous-version for full details." - ) - async def edit( - self, - rate_limit_id: str, - *, - zone_id: str, - action: rate_limit_edit_params.Action, - match: rate_limit_edit_params.Match, - period: float, - threshold: float, - # 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, - ) -> RateLimit: - """ - Updates an existing rate limit. - - Args: - zone_id: Identifier - - rate_limit_id: The unique identifier of the rate limit. - - action: The action to perform when the threshold of matched traffic within the - configured period is exceeded. - - match: Determines which traffic the rate limit counts towards the threshold. - - period: The time in seconds (an integer value) to count matching traffic. If the count - exceeds the configured threshold within this period, Cloudflare will perform the - configured action. - - threshold: The threshold that will trigger the configured mitigation action. Configure this - value along with the `period` property to establish a threshold per period. - - 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}") - if not rate_limit_id: - raise ValueError(f"Expected a non-empty value for `rate_limit_id` but received {rate_limit_id!r}") - return await self._put( - f"/zones/{zone_id}/rate_limits/{rate_limit_id}", - body=await async_maybe_transform( - { - "action": action, - "match": match, - "period": period, - "threshold": threshold, - }, - rate_limit_edit_params.RateLimitEditParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RateLimit]._unwrapper, - ), - cast_to=cast(Type[RateLimit], ResultWrapper[RateLimit]), - ) - - @typing_extensions.deprecated( - "Rate limiting API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#rate-limiting-api-previous-version for full details." - ) - async def get( - self, - rate_limit_id: str, - *, - zone_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, - ) -> RateLimit: - """ - Fetches the details of a rate limit. - - Args: - zone_id: Identifier - - rate_limit_id: The unique identifier of the rate limit. - - 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}") - if not rate_limit_id: - raise ValueError(f"Expected a non-empty value for `rate_limit_id` but received {rate_limit_id!r}") - return await self._get( - f"/zones/{zone_id}/rate_limits/{rate_limit_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[RateLimit]._unwrapper, - ), - cast_to=cast(Type[RateLimit], ResultWrapper[RateLimit]), - ) - - -class RateLimitsResourceWithRawResponse: - def __init__(self, rate_limits: RateLimitsResource) -> None: - self._rate_limits = rate_limits - - self.create = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - rate_limits.create # pyright: ignore[reportDeprecated], - ) - ) - self.list = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - rate_limits.list # pyright: ignore[reportDeprecated], - ) - ) - self.delete = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - rate_limits.delete # pyright: ignore[reportDeprecated], - ) - ) - self.edit = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - rate_limits.edit # pyright: ignore[reportDeprecated], - ) - ) - self.get = ( # pyright: ignore[reportDeprecated] - to_raw_response_wrapper( - rate_limits.get # pyright: ignore[reportDeprecated], - ) - ) - - -class AsyncRateLimitsResourceWithRawResponse: - def __init__(self, rate_limits: AsyncRateLimitsResource) -> None: - self._rate_limits = rate_limits - - self.create = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - rate_limits.create # pyright: ignore[reportDeprecated], - ) - ) - self.list = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - rate_limits.list # pyright: ignore[reportDeprecated], - ) - ) - self.delete = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - rate_limits.delete # pyright: ignore[reportDeprecated], - ) - ) - self.edit = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - rate_limits.edit # pyright: ignore[reportDeprecated], - ) - ) - self.get = ( # pyright: ignore[reportDeprecated] - async_to_raw_response_wrapper( - rate_limits.get # pyright: ignore[reportDeprecated], - ) - ) - - -class RateLimitsResourceWithStreamingResponse: - def __init__(self, rate_limits: RateLimitsResource) -> None: - self._rate_limits = rate_limits - - self.create = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - rate_limits.create # pyright: ignore[reportDeprecated], - ) - ) - self.list = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - rate_limits.list # pyright: ignore[reportDeprecated], - ) - ) - self.delete = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - rate_limits.delete # pyright: ignore[reportDeprecated], - ) - ) - self.edit = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - rate_limits.edit # pyright: ignore[reportDeprecated], - ) - ) - self.get = ( # pyright: ignore[reportDeprecated] - to_streamed_response_wrapper( - rate_limits.get # pyright: ignore[reportDeprecated], - ) - ) - - -class AsyncRateLimitsResourceWithStreamingResponse: - def __init__(self, rate_limits: AsyncRateLimitsResource) -> None: - self._rate_limits = rate_limits - - self.create = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - rate_limits.create # pyright: ignore[reportDeprecated], - ) - ) - self.list = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - rate_limits.list # pyright: ignore[reportDeprecated], - ) - ) - self.delete = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - rate_limits.delete # pyright: ignore[reportDeprecated], - ) - ) - self.edit = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - rate_limits.edit # pyright: ignore[reportDeprecated], - ) - ) - self.get = ( # pyright: ignore[reportDeprecated] - async_to_streamed_response_wrapper( - rate_limits.get # pyright: ignore[reportDeprecated], - ) - ) diff --git a/src/cloudflare/types/filters/__init__.py b/src/cloudflare/types/filters/__init__.py index 84b9f911178..f8ee8b14b1c 100644 --- a/src/cloudflare/types/filters/__init__.py +++ b/src/cloudflare/types/filters/__init__.py @@ -1,10 +1,3 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations - -from .firewall_filter import FirewallFilter as FirewallFilter -from .filter_list_params import FilterListParams as FilterListParams -from .filter_create_params import FilterCreateParams as FilterCreateParams -from .filter_update_params import FilterUpdateParams as FilterUpdateParams -from .firewall_filter_param import FirewallFilterParam as FirewallFilterParam -from .filter_create_response import FilterCreateResponse as FilterCreateResponse diff --git a/src/cloudflare/types/filters/filter_create_params.py b/src/cloudflare/types/filters/filter_create_params.py deleted file mode 100644 index 4c4284bb786..00000000000 --- a/src/cloudflare/types/filters/filter_create_params.py +++ /dev/null @@ -1,19 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import Required, TypedDict - -__all__ = ["FilterCreateParams"] - - -class FilterCreateParams(TypedDict, total=False): - zone_id: Required[str] - """Identifier""" - - expression: Required[str] - """The filter expression. - - For more information, refer to - [Expressions](https://developers.cloudflare.com/ruleset-engine/rules-language/expressions/). - """ diff --git a/src/cloudflare/types/filters/filter_create_response.py b/src/cloudflare/types/filters/filter_create_response.py deleted file mode 100644 index 1c979aae822..00000000000 --- a/src/cloudflare/types/filters/filter_create_response.py +++ /dev/null @@ -1,10 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import List -from typing_extensions import TypeAlias - -from .firewall_filter import FirewallFilter - -__all__ = ["FilterCreateResponse"] - -FilterCreateResponse: TypeAlias = List[FirewallFilter] diff --git a/src/cloudflare/types/filters/filter_list_params.py b/src/cloudflare/types/filters/filter_list_params.py deleted file mode 100644 index d90e1171696..00000000000 --- a/src/cloudflare/types/filters/filter_list_params.py +++ /dev/null @@ -1,33 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import Required, TypedDict - -__all__ = ["FilterListParams"] - - -class FilterListParams(TypedDict, total=False): - zone_id: Required[str] - """Identifier""" - - id: str - """The unique identifier of the filter.""" - - description: str - """A case-insensitive string to find in the description.""" - - expression: str - """A case-insensitive string to find in the expression.""" - - page: float - """Page number of paginated results.""" - - paused: bool - """When true, indicates that the filter is currently paused.""" - - per_page: float - """Number of filters per page.""" - - ref: str - """The filter ref (a short reference tag) to search for. Must be an exact match.""" diff --git a/src/cloudflare/types/filters/filter_update_params.py b/src/cloudflare/types/filters/filter_update_params.py deleted file mode 100644 index 257141354eb..00000000000 --- a/src/cloudflare/types/filters/filter_update_params.py +++ /dev/null @@ -1,14 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import Required, TypedDict - -__all__ = ["FilterUpdateParams"] - - -class FilterUpdateParams(TypedDict, total=False): - zone_id: Required[str] - """Identifier""" - - body: Required[object] diff --git a/src/cloudflare/types/filters/firewall_filter.py b/src/cloudflare/types/filters/firewall_filter.py deleted file mode 100644 index 03fdc13a222..00000000000 --- a/src/cloudflare/types/filters/firewall_filter.py +++ /dev/null @@ -1,28 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional - -from ..._models import BaseModel - -__all__ = ["FirewallFilter"] - - -class FirewallFilter(BaseModel): - id: Optional[str] = None - """The unique identifier of the filter.""" - - description: Optional[str] = None - """An informative summary of the filter.""" - - expression: Optional[str] = None - """The filter expression. - - For more information, refer to - [Expressions](https://developers.cloudflare.com/ruleset-engine/rules-language/expressions/). - """ - - paused: Optional[bool] = None - """When true, indicates that the filter is currently paused.""" - - ref: Optional[str] = None - """A short reference tag. Allows you to select related filters.""" diff --git a/src/cloudflare/types/filters/firewall_filter_param.py b/src/cloudflare/types/filters/firewall_filter_param.py deleted file mode 100644 index 39b4c9b9620..00000000000 --- a/src/cloudflare/types/filters/firewall_filter_param.py +++ /dev/null @@ -1,25 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import TypedDict - -__all__ = ["FirewallFilterParam"] - - -class FirewallFilterParam(TypedDict, total=False): - description: str - """An informative summary of the filter.""" - - expression: str - """The filter expression. - - For more information, refer to - [Expressions](https://developers.cloudflare.com/ruleset-engine/rules-language/expressions/). - """ - - paused: bool - """When true, indicates that the filter is currently paused.""" - - ref: str - """A short reference tag. Allows you to select related filters.""" diff --git a/src/cloudflare/types/firewall/__init__.py b/src/cloudflare/types/firewall/__init__.py index 9e3458a7b6d..24b2000c494 100644 --- a/src/cloudflare/types/firewall/__init__.py +++ b/src/cloudflare/types/firewall/__init__.py @@ -3,49 +3,12 @@ from __future__ import annotations from .product import Product as Product -from .lockdown import Lockdown as Lockdown from .lockdown_url import LockdownURL as LockdownURL -from .configuration import Configuration as Configuration -from .firewall_rule import FirewallRule as FirewallRule -from .deleted_filter import DeletedFilter as DeletedFilter -from .rule_get_params import RuleGetParams as RuleGetParams -from .rule_list_params import RuleListParams as RuleListParams -from .asn_configuration import ASNConfiguration as ASNConfiguration -from .ipv6_configuration import IPV6Configuration as IPV6Configuration -from .rule_create_params import RuleCreateParams as RuleCreateParams -from .rule_edit_response import RuleEditResponse as RuleEditResponse -from .rule_update_params import RuleUpdateParams as RuleUpdateParams -from .configuration_param import ConfigurationParam as ConfigurationParam -from .ua_rule_list_params import UARuleListParams as UARuleListParams -from .lockdown_list_params import LockdownListParams as LockdownListParams -from .rule_create_response import RuleCreateResponse as RuleCreateResponse -from .ua_rule_get_response import UARuleGetResponse as UARuleGetResponse -from .country_configuration import CountryConfiguration as CountryConfiguration -from .ua_rule_create_params import UARuleCreateParams as UARuleCreateParams -from .ua_rule_list_response import UARuleListResponse as UARuleListResponse -from .ua_rule_update_params import UARuleUpdateParams as UARuleUpdateParams -from .lockdown_create_params import LockdownCreateParams as LockdownCreateParams -from .lockdown_update_params import LockdownUpdateParams as LockdownUpdateParams -from .access_rule_edit_params import AccessRuleEditParams as AccessRuleEditParams from .access_rule_list_params import AccessRuleListParams as AccessRuleListParams from .asn_configuration_param import ASNConfigurationParam as ASNConfigurationParam -from .ua_rule_create_response import UARuleCreateResponse as UARuleCreateResponse -from .ua_rule_delete_response import UARuleDeleteResponse as UARuleDeleteResponse -from .ua_rule_update_response import UARuleUpdateResponse as UARuleUpdateResponse -from .access_rule_get_response import AccessRuleGetResponse as AccessRuleGetResponse from .ipv6_configuration_param import IPV6ConfigurationParam as IPV6ConfigurationParam -from .lockdown_delete_response import LockdownDeleteResponse as LockdownDeleteResponse from .access_rule_create_params import AccessRuleCreateParams as AccessRuleCreateParams -from .access_rule_edit_response import AccessRuleEditResponse as AccessRuleEditResponse -from .access_rule_list_response import AccessRuleListResponse as AccessRuleListResponse -from .lockdown_ip_configuration import LockdownIPConfiguration as LockdownIPConfiguration from .access_rule_create_response import AccessRuleCreateResponse as AccessRuleCreateResponse -from .access_rule_delete_response import AccessRuleDeleteResponse as AccessRuleDeleteResponse from .country_configuration_param import CountryConfigurationParam as CountryConfigurationParam -from .lockdown_cidr_configuration import LockdownCIDRConfiguration as LockdownCIDRConfiguration -from .access_rule_ip_configuration import AccessRuleIPConfiguration as AccessRuleIPConfiguration -from .access_rule_cidr_configuration import AccessRuleCIDRConfiguration as AccessRuleCIDRConfiguration -from .lockdown_ip_configuration_param import LockdownIPConfigurationParam as LockdownIPConfigurationParam -from .lockdown_cidr_configuration_param import LockdownCIDRConfigurationParam as LockdownCIDRConfigurationParam from .access_rule_ip_configuration_param import AccessRuleIPConfigurationParam as AccessRuleIPConfigurationParam from .access_rule_cidr_configuration_param import AccessRuleCIDRConfigurationParam as AccessRuleCIDRConfigurationParam diff --git a/src/cloudflare/types/firewall/access_rule_cidr_configuration.py b/src/cloudflare/types/firewall/access_rule_cidr_configuration.py deleted file mode 100644 index 7a88829b272..00000000000 --- a/src/cloudflare/types/firewall/access_rule_cidr_configuration.py +++ /dev/null @@ -1,24 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional -from typing_extensions import Literal - -from ..._models import BaseModel - -__all__ = ["AccessRuleCIDRConfiguration"] - - -class AccessRuleCIDRConfiguration(BaseModel): - target: Optional[Literal["ip_range"]] = None - """The configuration target. - - You must set the target to `ip_range` when specifying an IP address range in the - rule. - """ - - value: Optional[str] = None - """The IP address range to match. - - You can only use prefix lengths `/16` and `/24` for IPv4 ranges, and prefix - lengths `/32`, `/48`, and `/64` for IPv6 ranges. - """ diff --git a/src/cloudflare/types/firewall/access_rule_create_response.py b/src/cloudflare/types/firewall/access_rule_create_response.py index c7096d8a635..cf90fa66c02 100644 --- a/src/cloudflare/types/firewall/access_rule_create_response.py +++ b/src/cloudflare/types/firewall/access_rule_create_response.py @@ -1,57 +1,8 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union, Optional -from datetime import datetime -from typing_extensions import Literal, TypeAlias +from typing import Union, Optional +from typing_extensions import TypeAlias -from ..._models import BaseModel -from .asn_configuration import ASNConfiguration -from .ipv6_configuration import IPV6Configuration -from .country_configuration import CountryConfiguration -from .access_rule_ip_configuration import AccessRuleIPConfiguration -from .access_rule_cidr_configuration import AccessRuleCIDRConfiguration +__all__ = ["AccessRuleCreateResponse"] -__all__ = ["AccessRuleCreateResponse", "Configuration", "Scope"] - -Configuration: TypeAlias = Union[ - AccessRuleIPConfiguration, IPV6Configuration, AccessRuleCIDRConfiguration, ASNConfiguration, CountryConfiguration -] - - -class Scope(BaseModel): - id: Optional[str] = None - """Identifier""" - - email: Optional[str] = None - """The contact email address of the user.""" - - type: Optional[Literal["user", "organization"]] = None - """The scope of the rule.""" - - -class AccessRuleCreateResponse(BaseModel): - id: str - """The unique identifier of the IP Access rule.""" - - allowed_modes: List[Literal["block", "challenge", "whitelist", "js_challenge", "managed_challenge"]] - """The available actions that a rule can apply to a matched request.""" - - configuration: Configuration - """The rule configuration.""" - - mode: Literal["block", "challenge", "whitelist", "js_challenge", "managed_challenge"] - """The action to apply to a matched request.""" - - created_on: Optional[datetime] = None - """The timestamp of when the rule was created.""" - - modified_on: Optional[datetime] = None - """The timestamp of when the rule was last modified.""" - - notes: Optional[str] = None - """ - An informative summary of the rule, typically used as a reminder or explanation. - """ - - scope: Optional[Scope] = None - """All zones owned by the user will have the rule applied.""" +AccessRuleCreateResponse: TypeAlias = Union[Optional[str], Optional[object]] diff --git a/src/cloudflare/types/firewall/access_rule_delete_response.py b/src/cloudflare/types/firewall/access_rule_delete_response.py deleted file mode 100644 index 3e76fc0182b..00000000000 --- a/src/cloudflare/types/firewall/access_rule_delete_response.py +++ /dev/null @@ -1,11 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - - -from ..._models import BaseModel - -__all__ = ["AccessRuleDeleteResponse"] - - -class AccessRuleDeleteResponse(BaseModel): - id: str - """Identifier""" diff --git a/src/cloudflare/types/firewall/access_rule_edit_params.py b/src/cloudflare/types/firewall/access_rule_edit_params.py deleted file mode 100644 index 0b00f853493..00000000000 --- a/src/cloudflare/types/firewall/access_rule_edit_params.py +++ /dev/null @@ -1,42 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Union -from typing_extensions import Literal, Required, TypeAlias, TypedDict - -from .asn_configuration_param import ASNConfigurationParam -from .ipv6_configuration_param import IPV6ConfigurationParam -from .country_configuration_param import CountryConfigurationParam -from .access_rule_ip_configuration_param import AccessRuleIPConfigurationParam -from .access_rule_cidr_configuration_param import AccessRuleCIDRConfigurationParam - -__all__ = ["AccessRuleEditParams", "Configuration"] - - -class AccessRuleEditParams(TypedDict, total=False): - configuration: Required[Configuration] - """The rule configuration.""" - - mode: Required[Literal["block", "challenge", "whitelist", "js_challenge", "managed_challenge"]] - """The action to apply to a matched request.""" - - 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.""" - - notes: str - """ - An informative summary of the rule, typically used as a reminder or explanation. - """ - - -Configuration: TypeAlias = Union[ - AccessRuleIPConfigurationParam, - IPV6ConfigurationParam, - AccessRuleCIDRConfigurationParam, - ASNConfigurationParam, - CountryConfigurationParam, -] diff --git a/src/cloudflare/types/firewall/access_rule_edit_response.py b/src/cloudflare/types/firewall/access_rule_edit_response.py deleted file mode 100644 index 96aef6a378f..00000000000 --- a/src/cloudflare/types/firewall/access_rule_edit_response.py +++ /dev/null @@ -1,57 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import List, Union, Optional -from datetime import datetime -from typing_extensions import Literal, TypeAlias - -from ..._models import BaseModel -from .asn_configuration import ASNConfiguration -from .ipv6_configuration import IPV6Configuration -from .country_configuration import CountryConfiguration -from .access_rule_ip_configuration import AccessRuleIPConfiguration -from .access_rule_cidr_configuration import AccessRuleCIDRConfiguration - -__all__ = ["AccessRuleEditResponse", "Configuration", "Scope"] - -Configuration: TypeAlias = Union[ - AccessRuleIPConfiguration, IPV6Configuration, AccessRuleCIDRConfiguration, ASNConfiguration, CountryConfiguration -] - - -class Scope(BaseModel): - id: Optional[str] = None - """Identifier""" - - email: Optional[str] = None - """The contact email address of the user.""" - - type: Optional[Literal["user", "organization"]] = None - """The scope of the rule.""" - - -class AccessRuleEditResponse(BaseModel): - id: str - """The unique identifier of the IP Access rule.""" - - allowed_modes: List[Literal["block", "challenge", "whitelist", "js_challenge", "managed_challenge"]] - """The available actions that a rule can apply to a matched request.""" - - configuration: Configuration - """The rule configuration.""" - - mode: Literal["block", "challenge", "whitelist", "js_challenge", "managed_challenge"] - """The action to apply to a matched request.""" - - created_on: Optional[datetime] = None - """The timestamp of when the rule was created.""" - - modified_on: Optional[datetime] = None - """The timestamp of when the rule was last modified.""" - - notes: Optional[str] = None - """ - An informative summary of the rule, typically used as a reminder or explanation. - """ - - scope: Optional[Scope] = None - """All zones owned by the user will have the rule applied.""" diff --git a/src/cloudflare/types/firewall/access_rule_get_response.py b/src/cloudflare/types/firewall/access_rule_get_response.py deleted file mode 100644 index 3aa8177e619..00000000000 --- a/src/cloudflare/types/firewall/access_rule_get_response.py +++ /dev/null @@ -1,57 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import List, Union, Optional -from datetime import datetime -from typing_extensions import Literal, TypeAlias - -from ..._models import BaseModel -from .asn_configuration import ASNConfiguration -from .ipv6_configuration import IPV6Configuration -from .country_configuration import CountryConfiguration -from .access_rule_ip_configuration import AccessRuleIPConfiguration -from .access_rule_cidr_configuration import AccessRuleCIDRConfiguration - -__all__ = ["AccessRuleGetResponse", "Configuration", "Scope"] - -Configuration: TypeAlias = Union[ - AccessRuleIPConfiguration, IPV6Configuration, AccessRuleCIDRConfiguration, ASNConfiguration, CountryConfiguration -] - - -class Scope(BaseModel): - id: Optional[str] = None - """Identifier""" - - email: Optional[str] = None - """The contact email address of the user.""" - - type: Optional[Literal["user", "organization"]] = None - """The scope of the rule.""" - - -class AccessRuleGetResponse(BaseModel): - id: str - """The unique identifier of the IP Access rule.""" - - allowed_modes: List[Literal["block", "challenge", "whitelist", "js_challenge", "managed_challenge"]] - """The available actions that a rule can apply to a matched request.""" - - configuration: Configuration - """The rule configuration.""" - - mode: Literal["block", "challenge", "whitelist", "js_challenge", "managed_challenge"] - """The action to apply to a matched request.""" - - created_on: Optional[datetime] = None - """The timestamp of when the rule was created.""" - - modified_on: Optional[datetime] = None - """The timestamp of when the rule was last modified.""" - - notes: Optional[str] = None - """ - An informative summary of the rule, typically used as a reminder or explanation. - """ - - scope: Optional[Scope] = None - """All zones owned by the user will have the rule applied.""" diff --git a/src/cloudflare/types/firewall/access_rule_ip_configuration.py b/src/cloudflare/types/firewall/access_rule_ip_configuration.py deleted file mode 100644 index bb5ced460e5..00000000000 --- a/src/cloudflare/types/firewall/access_rule_ip_configuration.py +++ /dev/null @@ -1,22 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional -from typing_extensions import Literal - -from ..._models import BaseModel - -__all__ = ["AccessRuleIPConfiguration"] - - -class AccessRuleIPConfiguration(BaseModel): - target: Optional[Literal["ip"]] = None - """The configuration target. - - You must set the target to `ip` when specifying an IP address in the rule. - """ - - value: Optional[str] = None - """The IP address to match. - - This address will be compared to the IP address of incoming requests. - """ diff --git a/src/cloudflare/types/firewall/access_rule_list_response.py b/src/cloudflare/types/firewall/access_rule_list_response.py deleted file mode 100644 index 1f36fc9f8aa..00000000000 --- a/src/cloudflare/types/firewall/access_rule_list_response.py +++ /dev/null @@ -1,57 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import List, Union, Optional -from datetime import datetime -from typing_extensions import Literal, TypeAlias - -from ..._models import BaseModel -from .asn_configuration import ASNConfiguration -from .ipv6_configuration import IPV6Configuration -from .country_configuration import CountryConfiguration -from .access_rule_ip_configuration import AccessRuleIPConfiguration -from .access_rule_cidr_configuration import AccessRuleCIDRConfiguration - -__all__ = ["AccessRuleListResponse", "Configuration", "Scope"] - -Configuration: TypeAlias = Union[ - AccessRuleIPConfiguration, IPV6Configuration, AccessRuleCIDRConfiguration, ASNConfiguration, CountryConfiguration -] - - -class Scope(BaseModel): - id: Optional[str] = None - """Identifier""" - - email: Optional[str] = None - """The contact email address of the user.""" - - type: Optional[Literal["user", "organization"]] = None - """The scope of the rule.""" - - -class AccessRuleListResponse(BaseModel): - id: str - """The unique identifier of the IP Access rule.""" - - allowed_modes: List[Literal["block", "challenge", "whitelist", "js_challenge", "managed_challenge"]] - """The available actions that a rule can apply to a matched request.""" - - configuration: Configuration - """The rule configuration.""" - - mode: Literal["block", "challenge", "whitelist", "js_challenge", "managed_challenge"] - """The action to apply to a matched request.""" - - created_on: Optional[datetime] = None - """The timestamp of when the rule was created.""" - - modified_on: Optional[datetime] = None - """The timestamp of when the rule was last modified.""" - - notes: Optional[str] = None - """ - An informative summary of the rule, typically used as a reminder or explanation. - """ - - scope: Optional[Scope] = None - """All zones owned by the user will have the rule applied.""" diff --git a/src/cloudflare/types/firewall/asn_configuration.py b/src/cloudflare/types/firewall/asn_configuration.py deleted file mode 100644 index 6681a67e6b1..00000000000 --- a/src/cloudflare/types/firewall/asn_configuration.py +++ /dev/null @@ -1,20 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional -from typing_extensions import Literal - -from ..._models import BaseModel - -__all__ = ["ASNConfiguration"] - - -class ASNConfiguration(BaseModel): - target: Optional[Literal["asn"]] = None - """The configuration target. - - You must set the target to `asn` when specifying an Autonomous System Number - (ASN) in the rule. - """ - - value: Optional[str] = None - """The AS number to match.""" diff --git a/src/cloudflare/types/firewall/configuration.py b/src/cloudflare/types/firewall/configuration.py deleted file mode 100644 index 74e6fe404d4..00000000000 --- a/src/cloudflare/types/firewall/configuration.py +++ /dev/null @@ -1,13 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import List, Union -from typing_extensions import TypeAlias - -from .lockdown_ip_configuration import LockdownIPConfiguration -from .lockdown_cidr_configuration import LockdownCIDRConfiguration - -__all__ = ["Configuration", "ConfigurationItem"] - -ConfigurationItem: TypeAlias = Union[LockdownIPConfiguration, LockdownCIDRConfiguration] - -Configuration: TypeAlias = List[ConfigurationItem] diff --git a/src/cloudflare/types/firewall/configuration_param.py b/src/cloudflare/types/firewall/configuration_param.py deleted file mode 100644 index ba136e9f291..00000000000 --- a/src/cloudflare/types/firewall/configuration_param.py +++ /dev/null @@ -1,15 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import List, Union -from typing_extensions import TypeAlias - -from .lockdown_ip_configuration_param import LockdownIPConfigurationParam -from .lockdown_cidr_configuration_param import LockdownCIDRConfigurationParam - -__all__ = ["ConfigurationParam", "ConfigurationParamItem"] - -ConfigurationParamItem: TypeAlias = Union[LockdownIPConfigurationParam, LockdownCIDRConfigurationParam] - -ConfigurationParam: TypeAlias = List[ConfigurationParamItem] diff --git a/src/cloudflare/types/firewall/country_configuration.py b/src/cloudflare/types/firewall/country_configuration.py deleted file mode 100644 index 6fa7ec43fac..00000000000 --- a/src/cloudflare/types/firewall/country_configuration.py +++ /dev/null @@ -1,23 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional -from typing_extensions import Literal - -from ..._models import BaseModel - -__all__ = ["CountryConfiguration"] - - -class CountryConfiguration(BaseModel): - target: Optional[Literal["country"]] = None - """The configuration target. - - You must set the target to `country` when specifying a country code in the rule. - """ - - value: Optional[str] = None - """The two-letter ISO-3166-1 alpha-2 code to match. - - For more information, refer to - [IP Access rules: Parameters](https://developers.cloudflare.com/waf/tools/ip-access-rules/parameters/#country). - """ diff --git a/src/cloudflare/types/firewall/deleted_filter.py b/src/cloudflare/types/firewall/deleted_filter.py deleted file mode 100644 index 2f81710d06b..00000000000 --- a/src/cloudflare/types/firewall/deleted_filter.py +++ /dev/null @@ -1,14 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - - -from ..._models import BaseModel - -__all__ = ["DeletedFilter"] - - -class DeletedFilter(BaseModel): - id: str - """The unique identifier of the filter.""" - - deleted: bool - """When true, indicates that the firewall rule was deleted.""" diff --git a/src/cloudflare/types/firewall/firewall_rule.py b/src/cloudflare/types/firewall/firewall_rule.py deleted file mode 100644 index 1cf88c79af3..00000000000 --- a/src/cloudflare/types/firewall/firewall_rule.py +++ /dev/null @@ -1,46 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import List, Union, Optional -from typing_extensions import TypeAlias - -from .product import Product -from ..._models import BaseModel -from .deleted_filter import DeletedFilter -from ..rate_limits.action import Action -from ..filters.firewall_filter import FirewallFilter - -__all__ = ["FirewallRule", "Filter"] - -Filter: TypeAlias = Union[FirewallFilter, DeletedFilter] - - -class FirewallRule(BaseModel): - id: Optional[str] = None - """The unique identifier of the firewall rule.""" - - action: Optional[Action] = None - """The action to apply to a matched request. - - The `log` action is only available on an Enterprise plan. - """ - - description: Optional[str] = None - """An informative summary of the firewall rule.""" - - filter: Optional[Filter] = None - - paused: Optional[bool] = None - """When true, indicates that the firewall rule is currently paused.""" - - priority: Optional[float] = None - """The priority of the rule. - - Optional value used to define the processing order. A lower number indicates a - higher priority. If not provided, rules with a defined priority will be - processed before rules without a priority. - """ - - products: Optional[List[Product]] = None - - ref: Optional[str] = None - """A short reference tag. Allows you to select related firewall rules.""" diff --git a/src/cloudflare/types/firewall/ipv6_configuration.py b/src/cloudflare/types/firewall/ipv6_configuration.py deleted file mode 100644 index 3bf40ed6bc2..00000000000 --- a/src/cloudflare/types/firewall/ipv6_configuration.py +++ /dev/null @@ -1,19 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional -from typing_extensions import Literal - -from ..._models import BaseModel - -__all__ = ["IPV6Configuration"] - - -class IPV6Configuration(BaseModel): - target: Optional[Literal["ip6"]] = None - """The configuration target. - - You must set the target to `ip6` when specifying an IPv6 address in the rule. - """ - - value: Optional[str] = None - """The IPv6 address to match.""" diff --git a/src/cloudflare/types/firewall/lockdown.py b/src/cloudflare/types/firewall/lockdown.py deleted file mode 100644 index 7a1ea7038b5..00000000000 --- a/src/cloudflare/types/firewall/lockdown.py +++ /dev/null @@ -1,41 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import List -from datetime import datetime - -from ..._models import BaseModel -from .lockdown_url import LockdownURL -from .configuration import Configuration - -__all__ = ["Lockdown"] - - -class Lockdown(BaseModel): - id: str - """The unique identifier of the Zone Lockdown rule.""" - - configurations: Configuration - """ - A list of IP addresses or CIDR ranges that will be allowed to access the URLs - specified in the Zone Lockdown rule. You can include any number of `ip` or - `ip_range` configurations. - """ - - created_on: datetime - """The timestamp of when the rule was created.""" - - description: str - """An informative summary of the rule.""" - - modified_on: datetime - """The timestamp of when the rule was last modified.""" - - paused: bool - """When true, indicates that the rule is currently paused.""" - - urls: List[LockdownURL] - """The URLs to include in the rule definition. - - You can use wildcards. Each entered URL will be escaped before use, which means - you can only use simple wildcard patterns. - """ diff --git a/src/cloudflare/types/firewall/lockdown_cidr_configuration.py b/src/cloudflare/types/firewall/lockdown_cidr_configuration.py deleted file mode 100644 index 0380319616c..00000000000 --- a/src/cloudflare/types/firewall/lockdown_cidr_configuration.py +++ /dev/null @@ -1,20 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional -from typing_extensions import Literal - -from ..._models import BaseModel - -__all__ = ["LockdownCIDRConfiguration"] - - -class LockdownCIDRConfiguration(BaseModel): - target: Optional[Literal["ip_range"]] = None - """The configuration target. - - You must set the target to `ip_range` when specifying an IP address range in the - Zone Lockdown rule. - """ - - value: Optional[str] = None - """The IP address range to match. You can only use prefix lengths `/16` and `/24`.""" diff --git a/src/cloudflare/types/firewall/lockdown_cidr_configuration_param.py b/src/cloudflare/types/firewall/lockdown_cidr_configuration_param.py deleted file mode 100644 index 2748218d297..00000000000 --- a/src/cloudflare/types/firewall/lockdown_cidr_configuration_param.py +++ /dev/null @@ -1,19 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import Literal, TypedDict - -__all__ = ["LockdownCIDRConfigurationParam"] - - -class LockdownCIDRConfigurationParam(TypedDict, total=False): - target: Literal["ip_range"] - """The configuration target. - - You must set the target to `ip_range` when specifying an IP address range in the - Zone Lockdown rule. - """ - - value: str - """The IP address range to match. You can only use prefix lengths `/16` and `/24`.""" diff --git a/src/cloudflare/types/firewall/lockdown_create_params.py b/src/cloudflare/types/firewall/lockdown_create_params.py deleted file mode 100644 index 6b9c5e01839..00000000000 --- a/src/cloudflare/types/firewall/lockdown_create_params.py +++ /dev/null @@ -1,30 +0,0 @@ -# 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 Required, TypedDict - -from .waf.override_url import OverrideURL -from .configuration_param import ConfigurationParam - -__all__ = ["LockdownCreateParams"] - - -class LockdownCreateParams(TypedDict, total=False): - zone_id: Required[str] - """Identifier""" - - configurations: Required[ConfigurationParam] - """ - A list of IP addresses or CIDR ranges that will be allowed to access the URLs - specified in the Zone Lockdown rule. You can include any number of `ip` or - `ip_range` configurations. - """ - - urls: Required[List[OverrideURL]] - """The URLs to include in the current WAF override. - - You can use wildcards. Each entered URL will be escaped before use, which means - you can only use simple wildcard patterns. - """ diff --git a/src/cloudflare/types/firewall/lockdown_delete_response.py b/src/cloudflare/types/firewall/lockdown_delete_response.py deleted file mode 100644 index 6938edb1610..00000000000 --- a/src/cloudflare/types/firewall/lockdown_delete_response.py +++ /dev/null @@ -1,12 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional - -from ..._models import BaseModel - -__all__ = ["LockdownDeleteResponse"] - - -class LockdownDeleteResponse(BaseModel): - id: Optional[str] = None - """The unique identifier of the Zone Lockdown rule.""" diff --git a/src/cloudflare/types/firewall/lockdown_ip_configuration.py b/src/cloudflare/types/firewall/lockdown_ip_configuration.py deleted file mode 100644 index 5961692c88f..00000000000 --- a/src/cloudflare/types/firewall/lockdown_ip_configuration.py +++ /dev/null @@ -1,23 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional -from typing_extensions import Literal - -from ..._models import BaseModel - -__all__ = ["LockdownIPConfiguration"] - - -class LockdownIPConfiguration(BaseModel): - target: Optional[Literal["ip"]] = None - """The configuration target. - - You must set the target to `ip` when specifying an IP address in the Zone - Lockdown rule. - """ - - value: Optional[str] = None - """The IP address to match. - - This address will be compared to the IP address of incoming requests. - """ diff --git a/src/cloudflare/types/firewall/lockdown_ip_configuration_param.py b/src/cloudflare/types/firewall/lockdown_ip_configuration_param.py deleted file mode 100644 index 8c3b3322596..00000000000 --- a/src/cloudflare/types/firewall/lockdown_ip_configuration_param.py +++ /dev/null @@ -1,22 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import Literal, TypedDict - -__all__ = ["LockdownIPConfigurationParam"] - - -class LockdownIPConfigurationParam(TypedDict, total=False): - target: Literal["ip"] - """The configuration target. - - You must set the target to `ip` when specifying an IP address in the Zone - Lockdown rule. - """ - - value: str - """The IP address to match. - - This address will be compared to the IP address of incoming requests. - """ diff --git a/src/cloudflare/types/firewall/lockdown_list_params.py b/src/cloudflare/types/firewall/lockdown_list_params.py deleted file mode 100644 index 81df31e16fe..00000000000 --- a/src/cloudflare/types/firewall/lockdown_list_params.py +++ /dev/null @@ -1,57 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Union -from datetime import datetime -from typing_extensions import Required, Annotated, TypedDict - -from ..._utils import PropertyInfo - -__all__ = ["LockdownListParams"] - - -class LockdownListParams(TypedDict, total=False): - zone_id: Required[str] - """Identifier""" - - created_on: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")] - """The timestamp of when the rule was created.""" - - description: str - """A string to search for in the description of existing rules.""" - - description_search: str - """A string to search for in the description of existing rules.""" - - ip: str - """A single IP address to search for in existing rules.""" - - ip_range_search: str - """A single IP address range to search for in existing rules.""" - - ip_search: str - """A single IP address to search for in existing rules.""" - - modified_on: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")] - """The timestamp of when the rule was last modified.""" - - page: float - """Page number of paginated results.""" - - per_page: float - """The maximum number of results per page. - - You can only set the value to `1` or to a multiple of 5 such as `5`, `10`, `15`, - or `20`. - """ - - priority: float - """The priority of the rule to control the processing order. - - A lower number indicates higher priority. If not provided, any rules with a - configured priority will be processed before rules without a priority. - """ - - uri_search: str - """A single URI to search for in the list of URLs of existing rules.""" diff --git a/src/cloudflare/types/firewall/lockdown_update_params.py b/src/cloudflare/types/firewall/lockdown_update_params.py deleted file mode 100644 index c194e1e4904..00000000000 --- a/src/cloudflare/types/firewall/lockdown_update_params.py +++ /dev/null @@ -1,30 +0,0 @@ -# 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 Required, TypedDict - -from .waf.override_url import OverrideURL -from .configuration_param import ConfigurationParam - -__all__ = ["LockdownUpdateParams"] - - -class LockdownUpdateParams(TypedDict, total=False): - zone_id: Required[str] - """Identifier""" - - configurations: Required[ConfigurationParam] - """ - A list of IP addresses or CIDR ranges that will be allowed to access the URLs - specified in the Zone Lockdown rule. You can include any number of `ip` or - `ip_range` configurations. - """ - - urls: Required[List[OverrideURL]] - """The URLs to include in the current WAF override. - - You can use wildcards. Each entered URL will be escaped before use, which means - you can only use simple wildcard patterns. - """ diff --git a/src/cloudflare/types/firewall/rule_create_params.py b/src/cloudflare/types/firewall/rule_create_params.py deleted file mode 100644 index 32aa378e63e..00000000000 --- a/src/cloudflare/types/firewall/rule_create_params.py +++ /dev/null @@ -1,59 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import Literal, Required, TypedDict - -from ..filters.firewall_filter_param import FirewallFilterParam - -__all__ = ["RuleCreateParams", "Action", "ActionResponse"] - - -class RuleCreateParams(TypedDict, total=False): - zone_id: Required[str] - """Identifier""" - - action: Required[Action] - """ - The action to perform when the threshold of matched traffic within the - configured period is exceeded. - """ - - filter: Required[FirewallFilterParam] - - -class ActionResponse(TypedDict, total=False): - body: str - """The response body to return. - - The value must conform to the configured content type. - """ - - content_type: str - """The content type of the body. - - Must be one of the following: `text/plain`, `text/xml`, or `application/json`. - """ - - -class Action(TypedDict, total=False): - mode: Literal["simulate", "ban", "challenge", "js_challenge", "managed_challenge"] - """The action to perform.""" - - response: ActionResponse - """A custom content type and reponse to return when the threshold is exceeded. - - The custom response configured in this object will override the custom error for - the zone. This object is optional. Notes: If you omit this object, Cloudflare - will use the default HTML error page. If "mode" is "challenge", - "managed_challenge", or "js_challenge", Cloudflare will use the zone challenge - pages and you should not provide the "response" object. - """ - - timeout: float - """The time in seconds during which Cloudflare will perform the mitigation action. - - Must be an integer value greater than or equal to the period. Notes: If "mode" - is "challenge", "managed_challenge", or "js_challenge", Cloudflare will use the - zone's Challenge Passage time and you should not provide this value. - """ diff --git a/src/cloudflare/types/firewall/rule_create_response.py b/src/cloudflare/types/firewall/rule_create_response.py deleted file mode 100644 index 78ca0455e97..00000000000 --- a/src/cloudflare/types/firewall/rule_create_response.py +++ /dev/null @@ -1,10 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import List -from typing_extensions import TypeAlias - -from .firewall_rule import FirewallRule - -__all__ = ["RuleCreateResponse"] - -RuleCreateResponse: TypeAlias = List[FirewallRule] diff --git a/src/cloudflare/types/firewall/rule_edit_response.py b/src/cloudflare/types/firewall/rule_edit_response.py deleted file mode 100644 index 078cb92e0e8..00000000000 --- a/src/cloudflare/types/firewall/rule_edit_response.py +++ /dev/null @@ -1,10 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import List -from typing_extensions import TypeAlias - -from .firewall_rule import FirewallRule - -__all__ = ["RuleEditResponse"] - -RuleEditResponse: TypeAlias = List[FirewallRule] diff --git a/src/cloudflare/types/firewall/rule_get_params.py b/src/cloudflare/types/firewall/rule_get_params.py deleted file mode 100644 index 6dff4946cc7..00000000000 --- a/src/cloudflare/types/firewall/rule_get_params.py +++ /dev/null @@ -1,15 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import Required, TypedDict - -__all__ = ["RuleGetParams"] - - -class RuleGetParams(TypedDict, total=False): - zone_id: Required[str] - """Identifier""" - - id: str - """The unique identifier of the firewall rule.""" diff --git a/src/cloudflare/types/firewall/rule_list_params.py b/src/cloudflare/types/firewall/rule_list_params.py deleted file mode 100644 index b01c0dd4fc7..00000000000 --- a/src/cloudflare/types/firewall/rule_list_params.py +++ /dev/null @@ -1,30 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import Required, TypedDict - -__all__ = ["RuleListParams"] - - -class RuleListParams(TypedDict, total=False): - zone_id: Required[str] - """Identifier""" - - id: str - """The unique identifier of the firewall rule.""" - - action: str - """The action to search for. Must be an exact match.""" - - description: str - """A case-insensitive string to find in the description.""" - - page: float - """Page number of paginated results.""" - - paused: bool - """When true, indicates that the firewall rule is currently paused.""" - - per_page: float - """Number of firewall rules per page.""" diff --git a/src/cloudflare/types/firewall/rule_update_params.py b/src/cloudflare/types/firewall/rule_update_params.py deleted file mode 100644 index 0e9c27e89b5..00000000000 --- a/src/cloudflare/types/firewall/rule_update_params.py +++ /dev/null @@ -1,59 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import Literal, Required, TypedDict - -from ..filters.firewall_filter_param import FirewallFilterParam - -__all__ = ["RuleUpdateParams", "Action", "ActionResponse"] - - -class RuleUpdateParams(TypedDict, total=False): - zone_id: Required[str] - """Identifier""" - - action: Required[Action] - """ - The action to perform when the threshold of matched traffic within the - configured period is exceeded. - """ - - filter: Required[FirewallFilterParam] - - -class ActionResponse(TypedDict, total=False): - body: str - """The response body to return. - - The value must conform to the configured content type. - """ - - content_type: str - """The content type of the body. - - Must be one of the following: `text/plain`, `text/xml`, or `application/json`. - """ - - -class Action(TypedDict, total=False): - mode: Literal["simulate", "ban", "challenge", "js_challenge", "managed_challenge"] - """The action to perform.""" - - response: ActionResponse - """A custom content type and reponse to return when the threshold is exceeded. - - The custom response configured in this object will override the custom error for - the zone. This object is optional. Notes: If you omit this object, Cloudflare - will use the default HTML error page. If "mode" is "challenge", - "managed_challenge", or "js_challenge", Cloudflare will use the zone challenge - pages and you should not provide the "response" object. - """ - - timeout: float - """The time in seconds during which Cloudflare will perform the mitigation action. - - Must be an integer value greater than or equal to the period. Notes: If "mode" - is "challenge", "managed_challenge", or "js_challenge", Cloudflare will use the - zone's Challenge Passage time and you should not provide this value. - """ diff --git a/src/cloudflare/types/firewall/ua_rule_create_params.py b/src/cloudflare/types/firewall/ua_rule_create_params.py deleted file mode 100644 index 7c56210bb79..00000000000 --- a/src/cloudflare/types/firewall/ua_rule_create_params.py +++ /dev/null @@ -1,34 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Union -from typing_extensions import Literal, Required, TypeAlias, TypedDict - -from .asn_configuration_param import ASNConfigurationParam -from .ipv6_configuration_param import IPV6ConfigurationParam -from .country_configuration_param import CountryConfigurationParam -from .access_rule_ip_configuration_param import AccessRuleIPConfigurationParam -from .access_rule_cidr_configuration_param import AccessRuleCIDRConfigurationParam - -__all__ = ["UARuleCreateParams", "Configuration"] - - -class UARuleCreateParams(TypedDict, total=False): - zone_id: Required[str] - """Identifier""" - - configuration: Required[Configuration] - """The rule configuration.""" - - mode: Required[Literal["block", "challenge", "whitelist", "js_challenge", "managed_challenge"]] - """The action to apply to a matched request.""" - - -Configuration: TypeAlias = Union[ - AccessRuleIPConfigurationParam, - IPV6ConfigurationParam, - AccessRuleCIDRConfigurationParam, - ASNConfigurationParam, - CountryConfigurationParam, -] diff --git a/src/cloudflare/types/firewall/ua_rule_create_response.py b/src/cloudflare/types/firewall/ua_rule_create_response.py deleted file mode 100644 index bb2d6671967..00000000000 --- a/src/cloudflare/types/firewall/ua_rule_create_response.py +++ /dev/null @@ -1,8 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Union, Optional -from typing_extensions import TypeAlias - -__all__ = ["UARuleCreateResponse"] - -UARuleCreateResponse: TypeAlias = Union[Optional[str], Optional[object]] diff --git a/src/cloudflare/types/firewall/ua_rule_delete_response.py b/src/cloudflare/types/firewall/ua_rule_delete_response.py deleted file mode 100644 index 0d7cbd7d69d..00000000000 --- a/src/cloudflare/types/firewall/ua_rule_delete_response.py +++ /dev/null @@ -1,12 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional - -from ..._models import BaseModel - -__all__ = ["UARuleDeleteResponse"] - - -class UARuleDeleteResponse(BaseModel): - id: Optional[str] = None - """The unique identifier of the User Agent Blocking rule.""" diff --git a/src/cloudflare/types/firewall/ua_rule_get_response.py b/src/cloudflare/types/firewall/ua_rule_get_response.py deleted file mode 100644 index 10613bd3d5b..00000000000 --- a/src/cloudflare/types/firewall/ua_rule_get_response.py +++ /dev/null @@ -1,8 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Union, Optional -from typing_extensions import TypeAlias - -__all__ = ["UARuleGetResponse"] - -UARuleGetResponse: TypeAlias = Union[Optional[str], Optional[object]] diff --git a/src/cloudflare/types/firewall/ua_rule_list_params.py b/src/cloudflare/types/firewall/ua_rule_list_params.py deleted file mode 100644 index 5eb6fe0245a..00000000000 --- a/src/cloudflare/types/firewall/ua_rule_list_params.py +++ /dev/null @@ -1,31 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import Required, TypedDict - -__all__ = ["UARuleListParams"] - - -class UARuleListParams(TypedDict, total=False): - zone_id: Required[str] - """Identifier""" - - description: str - """A string to search for in the description of existing rules.""" - - description_search: str - """A string to search for in the description of existing rules.""" - - page: float - """Page number of paginated results.""" - - per_page: float - """The maximum number of results per page. - - You can only set the value to `1` or to a multiple of 5 such as `5`, `10`, `15`, - or `20`. - """ - - ua_search: str - """A string to search for in the user agent values of existing rules.""" diff --git a/src/cloudflare/types/firewall/ua_rule_list_response.py b/src/cloudflare/types/firewall/ua_rule_list_response.py deleted file mode 100644 index d3426a93fc3..00000000000 --- a/src/cloudflare/types/firewall/ua_rule_list_response.py +++ /dev/null @@ -1,39 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional -from typing_extensions import Literal - -from ..._models import BaseModel - -__all__ = ["UARuleListResponse", "Configuration"] - - -class Configuration(BaseModel): - target: Optional[str] = None - """The configuration target for this rule. - - You must set the target to `ua` for User Agent Blocking rules. - """ - - value: Optional[str] = None - """The exact user agent string to match. - - This value will be compared to the received `User-Agent` HTTP header value. - """ - - -class UARuleListResponse(BaseModel): - id: Optional[str] = None - """The unique identifier of the User Agent Blocking rule.""" - - configuration: Optional[Configuration] = None - """The configuration object for the current rule.""" - - description: Optional[str] = None - """An informative summary of the rule.""" - - mode: Optional[Literal["block", "challenge", "js_challenge", "managed_challenge"]] = None - """The action to apply to a matched request.""" - - paused: Optional[bool] = None - """When true, indicates that the rule is currently paused.""" diff --git a/src/cloudflare/types/firewall/ua_rule_update_params.py b/src/cloudflare/types/firewall/ua_rule_update_params.py deleted file mode 100644 index 5e7eae10702..00000000000 --- a/src/cloudflare/types/firewall/ua_rule_update_params.py +++ /dev/null @@ -1,34 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Union -from typing_extensions import Literal, Required, TypeAlias, TypedDict - -from .asn_configuration_param import ASNConfigurationParam -from .ipv6_configuration_param import IPV6ConfigurationParam -from .country_configuration_param import CountryConfigurationParam -from .access_rule_ip_configuration_param import AccessRuleIPConfigurationParam -from .access_rule_cidr_configuration_param import AccessRuleCIDRConfigurationParam - -__all__ = ["UARuleUpdateParams", "Configuration"] - - -class UARuleUpdateParams(TypedDict, total=False): - zone_id: Required[str] - """Identifier""" - - configuration: Required[Configuration] - """The rule configuration.""" - - mode: Required[Literal["block", "challenge", "whitelist", "js_challenge", "managed_challenge"]] - """The action to apply to a matched request.""" - - -Configuration: TypeAlias = Union[ - AccessRuleIPConfigurationParam, - IPV6ConfigurationParam, - AccessRuleCIDRConfigurationParam, - ASNConfigurationParam, - CountryConfigurationParam, -] diff --git a/src/cloudflare/types/firewall/ua_rule_update_response.py b/src/cloudflare/types/firewall/ua_rule_update_response.py deleted file mode 100644 index 4dc4d0ae168..00000000000 --- a/src/cloudflare/types/firewall/ua_rule_update_response.py +++ /dev/null @@ -1,8 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Union, Optional -from typing_extensions import TypeAlias - -__all__ = ["UARuleUpdateResponse"] - -UARuleUpdateResponse: TypeAlias = Union[Optional[str], Optional[object]] diff --git a/src/cloudflare/types/firewall/waf/__init__.py b/src/cloudflare/types/firewall/waf/__init__.py index 45373da4f22..94d4bfb4479 100644 --- a/src/cloudflare/types/firewall/waf/__init__.py +++ b/src/cloudflare/types/firewall/waf/__init__.py @@ -2,15 +2,4 @@ from __future__ import annotations -from .override import Override as Override -from .waf_rule import WAFRule as WAFRule from .override_url import OverrideURL as OverrideURL -from .rewrite_action import RewriteAction as RewriteAction -from .waf_rule_param import WAFRuleParam as WAFRuleParam -from .package_list_params import PackageListParams as PackageListParams -from .override_list_params import OverrideListParams as OverrideListParams -from .package_get_response import PackageGetResponse as PackageGetResponse -from .rewrite_action_param import RewriteActionParam as RewriteActionParam -from .override_create_params import OverrideCreateParams as OverrideCreateParams -from .override_update_params import OverrideUpdateParams as OverrideUpdateParams -from .override_delete_response import OverrideDeleteResponse as OverrideDeleteResponse diff --git a/src/cloudflare/types/firewall/waf/override.py b/src/cloudflare/types/firewall/waf/override.py deleted file mode 100644 index a758b89d18b..00000000000 --- a/src/cloudflare/types/firewall/waf/override.py +++ /dev/null @@ -1,59 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Dict, List, Optional - -from .waf_rule import WAFRule -from ...._models import BaseModel -from .override_url import OverrideURL -from .rewrite_action import RewriteAction - -__all__ = ["Override"] - - -class Override(BaseModel): - id: Optional[str] = None - """The unique identifier of the WAF override.""" - - description: Optional[str] = None - """An informative summary of the current URI-based WAF override.""" - - groups: Optional[Dict[str, object]] = None - """ - An object that allows you to enable or disable WAF rule groups for the current - WAF override. Each key of this object must be the ID of a WAF rule group, and - each value must be a valid WAF action (usually `default` or `disable`). When - creating a new URI-based WAF override, you must provide a `groups` object or a - `rules` object. - """ - - paused: Optional[bool] = None - """When true, indicates that the WAF package is currently paused.""" - - priority: Optional[float] = None - """ - The relative priority of the current URI-based WAF override when multiple - overrides match a single URL. A lower number indicates higher priority. Higher - priority overrides may overwrite values set by lower priority overrides. - """ - - rewrite_action: Optional[RewriteAction] = None - """ - Specifies that, when a WAF rule matches, its configured action will be replaced - by the action configured in this object. - """ - - rules: Optional[WAFRule] = None - """An object that allows you to override the action of specific WAF rules. - - Each key of this object must be the ID of a WAF rule, and each value must be a - valid WAF action. Unless you are disabling a rule, ensure that you also enable - the rule group that this WAF rule belongs to. When creating a new URI-based WAF - override, you must provide a `groups` object or a `rules` object. - """ - - urls: Optional[List[OverrideURL]] = None - """The URLs to include in the current WAF override. - - You can use wildcards. Each entered URL will be escaped before use, which means - you can only use simple wildcard patterns. - """ diff --git a/src/cloudflare/types/firewall/waf/override_create_params.py b/src/cloudflare/types/firewall/waf/override_create_params.py deleted file mode 100644 index 759ff41f3b9..00000000000 --- a/src/cloudflare/types/firewall/waf/override_create_params.py +++ /dev/null @@ -1,22 +0,0 @@ -# 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 Required, TypedDict - -from .override_url import OverrideURL - -__all__ = ["OverrideCreateParams"] - - -class OverrideCreateParams(TypedDict, total=False): - zone_id: Required[str] - """Identifier""" - - urls: Required[List[OverrideURL]] - """The URLs to include in the current WAF override. - - You can use wildcards. Each entered URL will be escaped before use, which means - you can only use simple wildcard patterns. - """ diff --git a/src/cloudflare/types/firewall/waf/override_delete_response.py b/src/cloudflare/types/firewall/waf/override_delete_response.py deleted file mode 100644 index 2c2830fff95..00000000000 --- a/src/cloudflare/types/firewall/waf/override_delete_response.py +++ /dev/null @@ -1,12 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional - -from ...._models import BaseModel - -__all__ = ["OverrideDeleteResponse"] - - -class OverrideDeleteResponse(BaseModel): - id: Optional[str] = None - """The unique identifier of the WAF override.""" diff --git a/src/cloudflare/types/firewall/waf/override_list_params.py b/src/cloudflare/types/firewall/waf/override_list_params.py deleted file mode 100644 index 59c53ef8846..00000000000 --- a/src/cloudflare/types/firewall/waf/override_list_params.py +++ /dev/null @@ -1,18 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import Required, TypedDict - -__all__ = ["OverrideListParams"] - - -class OverrideListParams(TypedDict, total=False): - zone_id: Required[str] - """Identifier""" - - page: float - """The page number of paginated results.""" - - per_page: float - """The number of WAF overrides per page.""" diff --git a/src/cloudflare/types/firewall/waf/override_update_params.py b/src/cloudflare/types/firewall/waf/override_update_params.py deleted file mode 100644 index 8375c6fcdfd..00000000000 --- a/src/cloudflare/types/firewall/waf/override_update_params.py +++ /dev/null @@ -1,42 +0,0 @@ -# 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 Required, TypedDict - -from .override_url import OverrideURL -from .waf_rule_param import WAFRuleParam -from .rewrite_action_param import RewriteActionParam - -__all__ = ["OverrideUpdateParams"] - - -class OverrideUpdateParams(TypedDict, total=False): - zone_id: Required[str] - """Identifier""" - - id: Required[str] - """Identifier""" - - rewrite_action: Required[RewriteActionParam] - """ - Specifies that, when a WAF rule matches, its configured action will be replaced - by the action configured in this object. - """ - - rules: Required[WAFRuleParam] - """An object that allows you to override the action of specific WAF rules. - - Each key of this object must be the ID of a WAF rule, and each value must be a - valid WAF action. Unless you are disabling a rule, ensure that you also enable - the rule group that this WAF rule belongs to. When creating a new URI-based WAF - override, you must provide a `groups` object or a `rules` object. - """ - - urls: Required[List[OverrideURL]] - """The URLs to include in the current WAF override. - - You can use wildcards. Each entered URL will be escaped before use, which means - you can only use simple wildcard patterns. - """ diff --git a/src/cloudflare/types/firewall/waf/package_get_response.py b/src/cloudflare/types/firewall/waf/package_get_response.py deleted file mode 100644 index 6c5fda24087..00000000000 --- a/src/cloudflare/types/firewall/waf/package_get_response.py +++ /dev/null @@ -1,27 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import List, Union, Optional -from typing_extensions import Literal, TypeAlias - -from ...._models import BaseModel -from ...shared.response_info import ResponseInfo - -__all__ = ["PackageGetResponse", "FirewallAPIResponseSingle", "Result"] - - -class FirewallAPIResponseSingle(BaseModel): - errors: List[ResponseInfo] - - messages: List[ResponseInfo] - - result: Union[Optional[str], Optional[object]] - - success: Literal[True] - """Whether the API call was successful""" - - -class Result(BaseModel): - result: Optional[object] = None - - -PackageGetResponse: TypeAlias = Union[FirewallAPIResponseSingle, Result] diff --git a/src/cloudflare/types/firewall/waf/package_list_params.py b/src/cloudflare/types/firewall/waf/package_list_params.py deleted file mode 100644 index 7c4cfda6bfe..00000000000 --- a/src/cloudflare/types/firewall/waf/package_list_params.py +++ /dev/null @@ -1,33 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import Literal, Required, TypedDict - -__all__ = ["PackageListParams"] - - -class PackageListParams(TypedDict, total=False): - zone_id: Required[str] - """Identifier""" - - direction: Literal["asc", "desc"] - """The direction used to sort returned packages.""" - - match: Literal["any", "all"] - """When set to `all`, all the search requirements must match. - - When set to `any`, only one of the search requirements has to match. - """ - - name: str - """The name of the WAF package.""" - - order: Literal["name"] - """The field used to sort returned packages.""" - - page: float - """The page number of paginated results.""" - - per_page: float - """The number of packages per page.""" diff --git a/src/cloudflare/types/firewall/waf/rewrite_action.py b/src/cloudflare/types/firewall/waf/rewrite_action.py deleted file mode 100644 index cfdd8b826c1..00000000000 --- a/src/cloudflare/types/firewall/waf/rewrite_action.py +++ /dev/null @@ -1,25 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional -from typing_extensions import Literal - -from ...._models import BaseModel - -__all__ = ["RewriteAction"] - - -class RewriteAction(BaseModel): - block: Optional[Literal["challenge", "block", "simulate", "disable", "default"]] = None - """The WAF rule action to apply.""" - - challenge: Optional[Literal["challenge", "block", "simulate", "disable", "default"]] = None - """The WAF rule action to apply.""" - - default: Optional[Literal["challenge", "block", "simulate", "disable", "default"]] = None - """The WAF rule action to apply.""" - - disable: Optional[Literal["challenge", "block", "simulate", "disable", "default"]] = None - """The WAF rule action to apply.""" - - simulate: Optional[Literal["challenge", "block", "simulate", "disable", "default"]] = None - """The WAF rule action to apply.""" diff --git a/src/cloudflare/types/firewall/waf/rewrite_action_param.py b/src/cloudflare/types/firewall/waf/rewrite_action_param.py deleted file mode 100644 index 9115252b294..00000000000 --- a/src/cloudflare/types/firewall/waf/rewrite_action_param.py +++ /dev/null @@ -1,24 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import Literal, TypedDict - -__all__ = ["RewriteActionParam"] - - -class RewriteActionParam(TypedDict, total=False): - block: Literal["challenge", "block", "simulate", "disable", "default"] - """The WAF rule action to apply.""" - - challenge: Literal["challenge", "block", "simulate", "disable", "default"] - """The WAF rule action to apply.""" - - default: Literal["challenge", "block", "simulate", "disable", "default"] - """The WAF rule action to apply.""" - - disable: Literal["challenge", "block", "simulate", "disable", "default"] - """The WAF rule action to apply.""" - - simulate: Literal["challenge", "block", "simulate", "disable", "default"] - """The WAF rule action to apply.""" diff --git a/src/cloudflare/types/firewall/waf/waf_rule.py b/src/cloudflare/types/firewall/waf/waf_rule.py deleted file mode 100644 index 3e6abc12da2..00000000000 --- a/src/cloudflare/types/firewall/waf/waf_rule.py +++ /dev/null @@ -1,8 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Dict -from typing_extensions import Literal, TypeAlias - -__all__ = ["WAFRule"] - -WAFRule: TypeAlias = Dict[str, Literal["challenge", "block", "simulate", "disable", "default"]] diff --git a/src/cloudflare/types/firewall/waf/waf_rule_param.py b/src/cloudflare/types/firewall/waf/waf_rule_param.py deleted file mode 100644 index 80123839548..00000000000 --- a/src/cloudflare/types/firewall/waf/waf_rule_param.py +++ /dev/null @@ -1,10 +0,0 @@ -# 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, TypeAlias - -__all__ = ["WAFRuleParam"] - -WAFRuleParam: TypeAlias = Dict[str, Literal["challenge", "block", "simulate", "disable", "default"]] diff --git a/src/cloudflare/types/rate_limits/__init__.py b/src/cloudflare/types/rate_limits/__init__.py index 3a9129f1e6e..4a096a81acd 100644 --- a/src/cloudflare/types/rate_limits/__init__.py +++ b/src/cloudflare/types/rate_limits/__init__.py @@ -4,8 +4,3 @@ from .action import Action as Action from .methods import Methods as Methods -from .rate_limit import RateLimit as RateLimit -from .rate_limit_edit_params import RateLimitEditParams as RateLimitEditParams -from .rate_limit_list_params import RateLimitListParams as RateLimitListParams -from .rate_limit_create_params import RateLimitCreateParams as RateLimitCreateParams -from .rate_limit_delete_response import RateLimitDeleteResponse as RateLimitDeleteResponse diff --git a/src/cloudflare/types/rate_limits/rate_limit.py b/src/cloudflare/types/rate_limits/rate_limit.py deleted file mode 100644 index 9fa5741af1a..00000000000 --- a/src/cloudflare/types/rate_limits/rate_limit.py +++ /dev/null @@ -1,150 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import List, Optional -from typing_extensions import Literal - -from .methods import Methods -from ..._models import BaseModel - -__all__ = ["RateLimit", "Action", "ActionResponse", "Bypass", "Match", "MatchHeader", "MatchRequest", "MatchResponse"] - - -class ActionResponse(BaseModel): - body: Optional[str] = None - """The response body to return. - - The value must conform to the configured content type. - """ - - content_type: Optional[str] = None - """The content type of the body. - - Must be one of the following: `text/plain`, `text/xml`, or `application/json`. - """ - - -class Action(BaseModel): - mode: Optional[Literal["simulate", "ban", "challenge", "js_challenge", "managed_challenge"]] = None - """The action to perform.""" - - response: Optional[ActionResponse] = None - """A custom content type and reponse to return when the threshold is exceeded. - - The custom response configured in this object will override the custom error for - the zone. This object is optional. Notes: If you omit this object, Cloudflare - will use the default HTML error page. If "mode" is "challenge", - "managed_challenge", or "js_challenge", Cloudflare will use the zone challenge - pages and you should not provide the "response" object. - """ - - timeout: Optional[float] = None - """The time in seconds during which Cloudflare will perform the mitigation action. - - Must be an integer value greater than or equal to the period. Notes: If "mode" - is "challenge", "managed_challenge", or "js_challenge", Cloudflare will use the - zone's Challenge Passage time and you should not provide this value. - """ - - -class Bypass(BaseModel): - name: Optional[Literal["url"]] = None - - value: Optional[str] = None - """The URL to bypass.""" - - -class MatchHeader(BaseModel): - name: Optional[str] = None - """The name of the response header to match.""" - - op: Optional[Literal["eq", "ne"]] = None - """The operator used when matching: `eq` means "equal" and `ne` means "not equal".""" - - value: Optional[str] = None - """The value of the response header, which must match exactly.""" - - -class MatchRequest(BaseModel): - methods: Optional[List[Methods]] = None - """The HTTP methods to match. - - You can specify a subset (for example, `['POST','PUT']`) or all methods - (`['_ALL_']`). This field is optional when creating a rate limit. - """ - - schemes: Optional[List[str]] = None - """The HTTP schemes to match. - - You can specify one scheme (`['HTTPS']`), both schemes (`['HTTP','HTTPS']`), or - all schemes (`['_ALL_']`). This field is optional. - """ - - url: Optional[str] = None - """ - The URL pattern to match, composed of a host and a path such as - `example.org/path*`. Normalization is applied before the pattern is matched. `*` - wildcards are expanded to match applicable traffic. Query strings are not - matched. Set the value to `*` to match all traffic to your zone. - """ - - -class MatchResponse(BaseModel): - origin_traffic: Optional[bool] = None - """ - When true, only the uncached traffic served from your origin servers will count - towards rate limiting. In this case, any cached traffic served by Cloudflare - will not count towards rate limiting. This field is optional. Notes: This field - is deprecated. Instead, use response headers and set "origin_traffic" to "false" - to avoid legacy behaviour interacting with the "response_headers" property. - """ - - -class Match(BaseModel): - headers: Optional[List[MatchHeader]] = None - - request: Optional[MatchRequest] = None - - response: Optional[MatchResponse] = None - - -class RateLimit(BaseModel): - id: Optional[str] = None - """The unique identifier of the rate limit.""" - - action: Optional[Action] = None - """ - The action to perform when the threshold of matched traffic within the - configured period is exceeded. - """ - - bypass: Optional[List[Bypass]] = None - """Criteria specifying when the current rate limit should be bypassed. - - You can specify that the rate limit should not apply to one or more URLs. - """ - - description: Optional[str] = None - """An informative summary of the rate limit. - - This value is sanitized and any tags will be removed. - """ - - disabled: Optional[bool] = None - """When true, indicates that the rate limit is currently disabled.""" - - match: Optional[Match] = None - """Determines which traffic the rate limit counts towards the threshold.""" - - period: Optional[float] = None - """The time in seconds (an integer value) to count matching traffic. - - If the count exceeds the configured threshold within this period, Cloudflare - will perform the configured action. - """ - - threshold: Optional[float] = None - """The threshold that will trigger the configured mitigation action. - - Configure this value along with the `period` property to establish a threshold - per period. - """ diff --git a/src/cloudflare/types/rate_limits/rate_limit_create_params.py b/src/cloudflare/types/rate_limits/rate_limit_create_params.py deleted file mode 100644 index e4f35081a32..00000000000 --- a/src/cloudflare/types/rate_limits/rate_limit_create_params.py +++ /dev/null @@ -1,129 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import List, Iterable -from typing_extensions import Literal, Required, TypedDict - -from .methods import Methods - -__all__ = ["RateLimitCreateParams", "Action", "ActionResponse", "Match", "MatchHeader", "MatchRequest", "MatchResponse"] - - -class RateLimitCreateParams(TypedDict, total=False): - zone_id: Required[str] - """Identifier""" - - action: Required[Action] - """ - The action to perform when the threshold of matched traffic within the - configured period is exceeded. - """ - - match: Required[Match] - """Determines which traffic the rate limit counts towards the threshold.""" - - period: Required[float] - """The time in seconds (an integer value) to count matching traffic. - - If the count exceeds the configured threshold within this period, Cloudflare - will perform the configured action. - """ - - threshold: Required[float] - """The threshold that will trigger the configured mitigation action. - - Configure this value along with the `period` property to establish a threshold - per period. - """ - - -class ActionResponse(TypedDict, total=False): - body: str - """The response body to return. - - The value must conform to the configured content type. - """ - - content_type: str - """The content type of the body. - - Must be one of the following: `text/plain`, `text/xml`, or `application/json`. - """ - - -class Action(TypedDict, total=False): - mode: Literal["simulate", "ban", "challenge", "js_challenge", "managed_challenge"] - """The action to perform.""" - - response: ActionResponse - """A custom content type and reponse to return when the threshold is exceeded. - - The custom response configured in this object will override the custom error for - the zone. This object is optional. Notes: If you omit this object, Cloudflare - will use the default HTML error page. If "mode" is "challenge", - "managed_challenge", or "js_challenge", Cloudflare will use the zone challenge - pages and you should not provide the "response" object. - """ - - timeout: float - """The time in seconds during which Cloudflare will perform the mitigation action. - - Must be an integer value greater than or equal to the period. Notes: If "mode" - is "challenge", "managed_challenge", or "js_challenge", Cloudflare will use the - zone's Challenge Passage time and you should not provide this value. - """ - - -class MatchHeader(TypedDict, total=False): - name: str - """The name of the response header to match.""" - - op: Literal["eq", "ne"] - """The operator used when matching: `eq` means "equal" and `ne` means "not equal".""" - - value: str - """The value of the response header, which must match exactly.""" - - -class MatchRequest(TypedDict, total=False): - methods: List[Methods] - """The HTTP methods to match. - - You can specify a subset (for example, `['POST','PUT']`) or all methods - (`['_ALL_']`). This field is optional when creating a rate limit. - """ - - schemes: List[str] - """The HTTP schemes to match. - - You can specify one scheme (`['HTTPS']`), both schemes (`['HTTP','HTTPS']`), or - all schemes (`['_ALL_']`). This field is optional. - """ - - url: str - """ - The URL pattern to match, composed of a host and a path such as - `example.org/path*`. Normalization is applied before the pattern is matched. `*` - wildcards are expanded to match applicable traffic. Query strings are not - matched. Set the value to `*` to match all traffic to your zone. - """ - - -class MatchResponse(TypedDict, total=False): - origin_traffic: bool - """ - When true, only the uncached traffic served from your origin servers will count - towards rate limiting. In this case, any cached traffic served by Cloudflare - will not count towards rate limiting. This field is optional. Notes: This field - is deprecated. Instead, use response headers and set "origin_traffic" to "false" - to avoid legacy behaviour interacting with the "response_headers" property. - """ - - -class Match(TypedDict, total=False): - headers: Iterable[MatchHeader] - - request: MatchRequest - - response: MatchResponse diff --git a/src/cloudflare/types/rate_limits/rate_limit_delete_response.py b/src/cloudflare/types/rate_limits/rate_limit_delete_response.py deleted file mode 100644 index 380d71356ee..00000000000 --- a/src/cloudflare/types/rate_limits/rate_limit_delete_response.py +++ /dev/null @@ -1,159 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import List, Optional -from typing_extensions import Literal - -from .methods import Methods -from ..._models import BaseModel - -__all__ = [ - "RateLimitDeleteResponse", - "Action", - "ActionResponse", - "Bypass", - "Match", - "MatchHeader", - "MatchRequest", - "MatchResponse", -] - - -class ActionResponse(BaseModel): - body: Optional[str] = None - """The response body to return. - - The value must conform to the configured content type. - """ - - content_type: Optional[str] = None - """The content type of the body. - - Must be one of the following: `text/plain`, `text/xml`, or `application/json`. - """ - - -class Action(BaseModel): - mode: Optional[Literal["simulate", "ban", "challenge", "js_challenge", "managed_challenge"]] = None - """The action to perform.""" - - response: Optional[ActionResponse] = None - """A custom content type and reponse to return when the threshold is exceeded. - - The custom response configured in this object will override the custom error for - the zone. This object is optional. Notes: If you omit this object, Cloudflare - will use the default HTML error page. If "mode" is "challenge", - "managed_challenge", or "js_challenge", Cloudflare will use the zone challenge - pages and you should not provide the "response" object. - """ - - timeout: Optional[float] = None - """The time in seconds during which Cloudflare will perform the mitigation action. - - Must be an integer value greater than or equal to the period. Notes: If "mode" - is "challenge", "managed_challenge", or "js_challenge", Cloudflare will use the - zone's Challenge Passage time and you should not provide this value. - """ - - -class Bypass(BaseModel): - name: Optional[Literal["url"]] = None - - value: Optional[str] = None - """The URL to bypass.""" - - -class MatchHeader(BaseModel): - name: Optional[str] = None - """The name of the response header to match.""" - - op: Optional[Literal["eq", "ne"]] = None - """The operator used when matching: `eq` means "equal" and `ne` means "not equal".""" - - value: Optional[str] = None - """The value of the response header, which must match exactly.""" - - -class MatchRequest(BaseModel): - methods: Optional[List[Methods]] = None - """The HTTP methods to match. - - You can specify a subset (for example, `['POST','PUT']`) or all methods - (`['_ALL_']`). This field is optional when creating a rate limit. - """ - - schemes: Optional[List[str]] = None - """The HTTP schemes to match. - - You can specify one scheme (`['HTTPS']`), both schemes (`['HTTP','HTTPS']`), or - all schemes (`['_ALL_']`). This field is optional. - """ - - url: Optional[str] = None - """ - The URL pattern to match, composed of a host and a path such as - `example.org/path*`. Normalization is applied before the pattern is matched. `*` - wildcards are expanded to match applicable traffic. Query strings are not - matched. Set the value to `*` to match all traffic to your zone. - """ - - -class MatchResponse(BaseModel): - origin_traffic: Optional[bool] = None - """ - When true, only the uncached traffic served from your origin servers will count - towards rate limiting. In this case, any cached traffic served by Cloudflare - will not count towards rate limiting. This field is optional. Notes: This field - is deprecated. Instead, use response headers and set "origin_traffic" to "false" - to avoid legacy behaviour interacting with the "response_headers" property. - """ - - -class Match(BaseModel): - headers: Optional[List[MatchHeader]] = None - - request: Optional[MatchRequest] = None - - response: Optional[MatchResponse] = None - - -class RateLimitDeleteResponse(BaseModel): - id: Optional[str] = None - """The unique identifier of the rate limit.""" - - action: Optional[Action] = None - """ - The action to perform when the threshold of matched traffic within the - configured period is exceeded. - """ - - bypass: Optional[List[Bypass]] = None - """Criteria specifying when the current rate limit should be bypassed. - - You can specify that the rate limit should not apply to one or more URLs. - """ - - description: Optional[str] = None - """An informative summary of the rate limit. - - This value is sanitized and any tags will be removed. - """ - - disabled: Optional[bool] = None - """When true, indicates that the rate limit is currently disabled.""" - - match: Optional[Match] = None - """Determines which traffic the rate limit counts towards the threshold.""" - - period: Optional[float] = None - """The time in seconds (an integer value) to count matching traffic. - - If the count exceeds the configured threshold within this period, Cloudflare - will perform the configured action. - """ - - threshold: Optional[float] = None - """The threshold that will trigger the configured mitigation action. - - Configure this value along with the `period` property to establish a threshold - per period. - """ diff --git a/src/cloudflare/types/rate_limits/rate_limit_edit_params.py b/src/cloudflare/types/rate_limits/rate_limit_edit_params.py deleted file mode 100644 index 3358bb60c93..00000000000 --- a/src/cloudflare/types/rate_limits/rate_limit_edit_params.py +++ /dev/null @@ -1,129 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import List, Iterable -from typing_extensions import Literal, Required, TypedDict - -from .methods import Methods - -__all__ = ["RateLimitEditParams", "Action", "ActionResponse", "Match", "MatchHeader", "MatchRequest", "MatchResponse"] - - -class RateLimitEditParams(TypedDict, total=False): - zone_id: Required[str] - """Identifier""" - - action: Required[Action] - """ - The action to perform when the threshold of matched traffic within the - configured period is exceeded. - """ - - match: Required[Match] - """Determines which traffic the rate limit counts towards the threshold.""" - - period: Required[float] - """The time in seconds (an integer value) to count matching traffic. - - If the count exceeds the configured threshold within this period, Cloudflare - will perform the configured action. - """ - - threshold: Required[float] - """The threshold that will trigger the configured mitigation action. - - Configure this value along with the `period` property to establish a threshold - per period. - """ - - -class ActionResponse(TypedDict, total=False): - body: str - """The response body to return. - - The value must conform to the configured content type. - """ - - content_type: str - """The content type of the body. - - Must be one of the following: `text/plain`, `text/xml`, or `application/json`. - """ - - -class Action(TypedDict, total=False): - mode: Literal["simulate", "ban", "challenge", "js_challenge", "managed_challenge"] - """The action to perform.""" - - response: ActionResponse - """A custom content type and reponse to return when the threshold is exceeded. - - The custom response configured in this object will override the custom error for - the zone. This object is optional. Notes: If you omit this object, Cloudflare - will use the default HTML error page. If "mode" is "challenge", - "managed_challenge", or "js_challenge", Cloudflare will use the zone challenge - pages and you should not provide the "response" object. - """ - - timeout: float - """The time in seconds during which Cloudflare will perform the mitigation action. - - Must be an integer value greater than or equal to the period. Notes: If "mode" - is "challenge", "managed_challenge", or "js_challenge", Cloudflare will use the - zone's Challenge Passage time and you should not provide this value. - """ - - -class MatchHeader(TypedDict, total=False): - name: str - """The name of the response header to match.""" - - op: Literal["eq", "ne"] - """The operator used when matching: `eq` means "equal" and `ne` means "not equal".""" - - value: str - """The value of the response header, which must match exactly.""" - - -class MatchRequest(TypedDict, total=False): - methods: List[Methods] - """The HTTP methods to match. - - You can specify a subset (for example, `['POST','PUT']`) or all methods - (`['_ALL_']`). This field is optional when creating a rate limit. - """ - - schemes: List[str] - """The HTTP schemes to match. - - You can specify one scheme (`['HTTPS']`), both schemes (`['HTTP','HTTPS']`), or - all schemes (`['_ALL_']`). This field is optional. - """ - - url: str - """ - The URL pattern to match, composed of a host and a path such as - `example.org/path*`. Normalization is applied before the pattern is matched. `*` - wildcards are expanded to match applicable traffic. Query strings are not - matched. Set the value to `*` to match all traffic to your zone. - """ - - -class MatchResponse(TypedDict, total=False): - origin_traffic: bool - """ - When true, only the uncached traffic served from your origin servers will count - towards rate limiting. In this case, any cached traffic served by Cloudflare - will not count towards rate limiting. This field is optional. Notes: This field - is deprecated. Instead, use response headers and set "origin_traffic" to "false" - to avoid legacy behaviour interacting with the "response_headers" property. - """ - - -class Match(TypedDict, total=False): - headers: Iterable[MatchHeader] - - request: MatchRequest - - response: MatchResponse diff --git a/src/cloudflare/types/rate_limits/rate_limit_list_params.py b/src/cloudflare/types/rate_limits/rate_limit_list_params.py deleted file mode 100644 index 4d9d72910be..00000000000 --- a/src/cloudflare/types/rate_limits/rate_limit_list_params.py +++ /dev/null @@ -1,22 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import Required, TypedDict - -__all__ = ["RateLimitListParams"] - - -class RateLimitListParams(TypedDict, total=False): - zone_id: Required[str] - """Identifier""" - - page: float - """The page number of paginated results.""" - - per_page: float - """The maximum number of results per page. - - You can only set the value to `1` or to a multiple of 5 such as `5`, `10`, `15`, - or `20`. - """ diff --git a/tests/api_resources/firewall/test_access_rules.py b/tests/api_resources/firewall/test_access_rules.py index 0e1faa1b86e..f7b7debb11d 100644 --- a/tests/api_resources/firewall/test_access_rules.py +++ b/tests/api_resources/firewall/test_access_rules.py @@ -3,20 +3,14 @@ from __future__ import annotations import os -from typing import Any, Optional, cast +from typing import Any, cast import pytest from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray -from cloudflare.types.firewall import ( - AccessRuleGetResponse, - AccessRuleEditResponse, - AccessRuleListResponse, - AccessRuleCreateResponse, - AccessRuleDeleteResponse, -) +from cloudflare.types.firewall import AccessRuleCreateResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -101,7 +95,7 @@ def test_method_list(self, client: Cloudflare) -> None: access_rule = client.firewall.access_rules.list( account_id="account_id", ) - assert_matches_type(SyncV4PagePaginationArray[AccessRuleListResponse], access_rule, path=["response"]) + assert_matches_type(SyncV4PagePaginationArray[object], access_rule, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -120,7 +114,7 @@ def test_method_list_with_all_params(self, client: Cloudflare) -> None: page=1, per_page=20, ) - assert_matches_type(SyncV4PagePaginationArray[AccessRuleListResponse], access_rule, path=["response"]) + assert_matches_type(SyncV4PagePaginationArray[object], access_rule, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -132,7 +126,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" access_rule = response.parse() - assert_matches_type(SyncV4PagePaginationArray[AccessRuleListResponse], access_rule, path=["response"]) + assert_matches_type(SyncV4PagePaginationArray[object], access_rule, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -144,7 +138,7 @@ def test_streaming_response_list(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" access_rule = response.parse() - assert_matches_type(SyncV4PagePaginationArray[AccessRuleListResponse], access_rule, path=["response"]) + assert_matches_type(SyncV4PagePaginationArray[object], access_rule, path=["response"]) assert cast(Any, response.is_closed) is True @@ -161,225 +155,6 @@ def test_path_params_list(self, client: Cloudflare) -> None: account_id="account_id", ) - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_delete(self, client: Cloudflare) -> None: - access_rule = client.firewall.access_rules.delete( - rule_id="023e105f4ecef8ad9ca31a8372d0c353", - account_id="account_id", - ) - assert_matches_type(Optional[AccessRuleDeleteResponse], access_rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_delete_with_all_params(self, client: Cloudflare) -> None: - access_rule = client.firewall.access_rules.delete( - rule_id="023e105f4ecef8ad9ca31a8372d0c353", - account_id="account_id", - ) - assert_matches_type(Optional[AccessRuleDeleteResponse], access_rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_delete(self, client: Cloudflare) -> None: - response = client.firewall.access_rules.with_raw_response.delete( - rule_id="023e105f4ecef8ad9ca31a8372d0c353", - account_id="account_id", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - access_rule = response.parse() - assert_matches_type(Optional[AccessRuleDeleteResponse], access_rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_delete(self, client: Cloudflare) -> None: - with client.firewall.access_rules.with_streaming_response.delete( - rule_id="023e105f4ecef8ad9ca31a8372d0c353", - account_id="account_id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - access_rule = response.parse() - assert_matches_type(Optional[AccessRuleDeleteResponse], access_rule, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_delete(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): - client.firewall.access_rules.with_raw_response.delete( - rule_id="", - account_id="account_id", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.firewall.access_rules.with_raw_response.delete( - rule_id="023e105f4ecef8ad9ca31a8372d0c353", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.firewall.access_rules.with_raw_response.delete( - rule_id="023e105f4ecef8ad9ca31a8372d0c353", - account_id="account_id", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_edit(self, client: Cloudflare) -> None: - access_rule = client.firewall.access_rules.edit( - rule_id="023e105f4ecef8ad9ca31a8372d0c353", - configuration={}, - mode="block", - account_id="account_id", - ) - assert_matches_type(AccessRuleEditResponse, access_rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_edit_with_all_params(self, client: Cloudflare) -> None: - access_rule = client.firewall.access_rules.edit( - rule_id="023e105f4ecef8ad9ca31a8372d0c353", - configuration={ - "target": "ip", - "value": "198.51.100.4", - }, - mode="block", - account_id="account_id", - notes="This rule is enabled because of an event that occurred on date X.", - ) - assert_matches_type(AccessRuleEditResponse, access_rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_edit(self, client: Cloudflare) -> None: - response = client.firewall.access_rules.with_raw_response.edit( - rule_id="023e105f4ecef8ad9ca31a8372d0c353", - configuration={}, - mode="block", - account_id="account_id", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - access_rule = response.parse() - assert_matches_type(AccessRuleEditResponse, access_rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_edit(self, client: Cloudflare) -> None: - with client.firewall.access_rules.with_streaming_response.edit( - rule_id="023e105f4ecef8ad9ca31a8372d0c353", - configuration={}, - mode="block", - account_id="account_id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - access_rule = response.parse() - assert_matches_type(AccessRuleEditResponse, access_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(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): - client.firewall.access_rules.with_raw_response.edit( - rule_id="", - configuration={}, - mode="block", - account_id="account_id", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.firewall.access_rules.with_raw_response.edit( - rule_id="023e105f4ecef8ad9ca31a8372d0c353", - configuration={}, - mode="block", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.firewall.access_rules.with_raw_response.edit( - rule_id="023e105f4ecef8ad9ca31a8372d0c353", - configuration={}, - mode="block", - account_id="account_id", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_get(self, client: Cloudflare) -> None: - access_rule = client.firewall.access_rules.get( - rule_id="023e105f4ecef8ad9ca31a8372d0c353", - account_id="account_id", - ) - assert_matches_type(AccessRuleGetResponse, access_rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_get_with_all_params(self, client: Cloudflare) -> None: - access_rule = client.firewall.access_rules.get( - rule_id="023e105f4ecef8ad9ca31a8372d0c353", - account_id="account_id", - ) - assert_matches_type(AccessRuleGetResponse, access_rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_get(self, client: Cloudflare) -> None: - response = client.firewall.access_rules.with_raw_response.get( - rule_id="023e105f4ecef8ad9ca31a8372d0c353", - account_id="account_id", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - access_rule = response.parse() - assert_matches_type(AccessRuleGetResponse, access_rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_get(self, client: Cloudflare) -> None: - with client.firewall.access_rules.with_streaming_response.get( - rule_id="023e105f4ecef8ad9ca31a8372d0c353", - account_id="account_id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - access_rule = response.parse() - assert_matches_type(AccessRuleGetResponse, access_rule, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_get(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): - client.firewall.access_rules.with_raw_response.get( - rule_id="", - account_id="account_id", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.firewall.access_rules.with_raw_response.get( - rule_id="023e105f4ecef8ad9ca31a8372d0c353", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.firewall.access_rules.with_raw_response.get( - rule_id="023e105f4ecef8ad9ca31a8372d0c353", - account_id="account_id", - ) - class TestAsyncAccessRules: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @@ -461,7 +236,7 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None: access_rule = await async_client.firewall.access_rules.list( account_id="account_id", ) - assert_matches_type(AsyncV4PagePaginationArray[AccessRuleListResponse], access_rule, path=["response"]) + assert_matches_type(AsyncV4PagePaginationArray[object], access_rule, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -480,7 +255,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) page=1, per_page=20, ) - assert_matches_type(AsyncV4PagePaginationArray[AccessRuleListResponse], access_rule, path=["response"]) + assert_matches_type(AsyncV4PagePaginationArray[object], access_rule, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -492,7 +267,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" access_rule = await response.parse() - assert_matches_type(AsyncV4PagePaginationArray[AccessRuleListResponse], access_rule, path=["response"]) + assert_matches_type(AsyncV4PagePaginationArray[object], access_rule, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize @@ -504,7 +279,7 @@ async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> N assert response.http_request.headers.get("X-Stainless-Lang") == "python" access_rule = await response.parse() - assert_matches_type(AsyncV4PagePaginationArray[AccessRuleListResponse], access_rule, path=["response"]) + assert_matches_type(AsyncV4PagePaginationArray[object], access_rule, path=["response"]) assert cast(Any, response.is_closed) is True @@ -520,222 +295,3 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: await async_client.firewall.access_rules.with_raw_response.list( account_id="account_id", ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_delete(self, async_client: AsyncCloudflare) -> None: - access_rule = await async_client.firewall.access_rules.delete( - rule_id="023e105f4ecef8ad9ca31a8372d0c353", - account_id="account_id", - ) - assert_matches_type(Optional[AccessRuleDeleteResponse], access_rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_delete_with_all_params(self, async_client: AsyncCloudflare) -> None: - access_rule = await async_client.firewall.access_rules.delete( - rule_id="023e105f4ecef8ad9ca31a8372d0c353", - account_id="account_id", - ) - assert_matches_type(Optional[AccessRuleDeleteResponse], access_rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: - response = await async_client.firewall.access_rules.with_raw_response.delete( - rule_id="023e105f4ecef8ad9ca31a8372d0c353", - account_id="account_id", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - access_rule = await response.parse() - assert_matches_type(Optional[AccessRuleDeleteResponse], access_rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: - async with async_client.firewall.access_rules.with_streaming_response.delete( - rule_id="023e105f4ecef8ad9ca31a8372d0c353", - account_id="account_id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - access_rule = await response.parse() - assert_matches_type(Optional[AccessRuleDeleteResponse], access_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_delete(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): - await async_client.firewall.access_rules.with_raw_response.delete( - rule_id="", - account_id="account_id", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.firewall.access_rules.with_raw_response.delete( - rule_id="023e105f4ecef8ad9ca31a8372d0c353", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.firewall.access_rules.with_raw_response.delete( - rule_id="023e105f4ecef8ad9ca31a8372d0c353", - account_id="account_id", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_edit(self, async_client: AsyncCloudflare) -> None: - access_rule = await async_client.firewall.access_rules.edit( - rule_id="023e105f4ecef8ad9ca31a8372d0c353", - configuration={}, - mode="block", - account_id="account_id", - ) - assert_matches_type(AccessRuleEditResponse, access_rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) -> None: - access_rule = await async_client.firewall.access_rules.edit( - rule_id="023e105f4ecef8ad9ca31a8372d0c353", - configuration={ - "target": "ip", - "value": "198.51.100.4", - }, - mode="block", - account_id="account_id", - notes="This rule is enabled because of an event that occurred on date X.", - ) - assert_matches_type(AccessRuleEditResponse, access_rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: - response = await async_client.firewall.access_rules.with_raw_response.edit( - rule_id="023e105f4ecef8ad9ca31a8372d0c353", - configuration={}, - mode="block", - account_id="account_id", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - access_rule = await response.parse() - assert_matches_type(AccessRuleEditResponse, access_rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: - async with async_client.firewall.access_rules.with_streaming_response.edit( - rule_id="023e105f4ecef8ad9ca31a8372d0c353", - configuration={}, - mode="block", - account_id="account_id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - access_rule = await response.parse() - assert_matches_type(AccessRuleEditResponse, access_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(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): - await async_client.firewall.access_rules.with_raw_response.edit( - rule_id="", - configuration={}, - mode="block", - account_id="account_id", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.firewall.access_rules.with_raw_response.edit( - rule_id="023e105f4ecef8ad9ca31a8372d0c353", - configuration={}, - mode="block", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.firewall.access_rules.with_raw_response.edit( - rule_id="023e105f4ecef8ad9ca31a8372d0c353", - configuration={}, - mode="block", - account_id="account_id", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_get(self, async_client: AsyncCloudflare) -> None: - access_rule = await async_client.firewall.access_rules.get( - rule_id="023e105f4ecef8ad9ca31a8372d0c353", - account_id="account_id", - ) - assert_matches_type(AccessRuleGetResponse, access_rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: - access_rule = await async_client.firewall.access_rules.get( - rule_id="023e105f4ecef8ad9ca31a8372d0c353", - account_id="account_id", - ) - assert_matches_type(AccessRuleGetResponse, access_rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: - response = await async_client.firewall.access_rules.with_raw_response.get( - rule_id="023e105f4ecef8ad9ca31a8372d0c353", - account_id="account_id", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - access_rule = await response.parse() - assert_matches_type(AccessRuleGetResponse, access_rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: - async with async_client.firewall.access_rules.with_streaming_response.get( - rule_id="023e105f4ecef8ad9ca31a8372d0c353", - account_id="account_id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - access_rule = await response.parse() - assert_matches_type(AccessRuleGetResponse, access_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_get(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): - await async_client.firewall.access_rules.with_raw_response.get( - rule_id="", - account_id="account_id", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.firewall.access_rules.with_raw_response.get( - rule_id="023e105f4ecef8ad9ca31a8372d0c353", - account_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.firewall.access_rules.with_raw_response.get( - rule_id="023e105f4ecef8ad9ca31a8372d0c353", - account_id="account_id", - ) diff --git a/tests/api_resources/firewall/test_lockdowns.py b/tests/api_resources/firewall/test_lockdowns.py deleted file mode 100644 index b7dfcbadaf0..00000000000 --- a/tests/api_resources/firewall/test_lockdowns.py +++ /dev/null @@ -1,555 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import os -from typing import Any, Optional, cast - -import pytest - -from cloudflare import Cloudflare, AsyncCloudflare -from tests.utils import assert_matches_type -from cloudflare._utils import parse_datetime -from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray -from cloudflare.types.firewall import ( - Lockdown, - LockdownDeleteResponse, -) - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestLockdowns: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_create(self, client: Cloudflare) -> None: - lockdown = client.firewall.lockdowns.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - configurations=[{}, {}, {}], - urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"], - ) - assert_matches_type(Lockdown, lockdown, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_create(self, client: Cloudflare) -> None: - response = client.firewall.lockdowns.with_raw_response.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - configurations=[{}, {}, {}], - urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"], - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - lockdown = response.parse() - assert_matches_type(Lockdown, lockdown, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_create(self, client: Cloudflare) -> None: - with client.firewall.lockdowns.with_streaming_response.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - configurations=[{}, {}, {}], - urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"], - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - lockdown = response.parse() - assert_matches_type(Lockdown, lockdown, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_create(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.firewall.lockdowns.with_raw_response.create( - zone_id="", - configurations=[{}, {}, {}], - urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"], - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update(self, client: Cloudflare) -> None: - lockdown = client.firewall.lockdowns.update( - lock_downs_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - configurations=[{}, {}, {}], - urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"], - ) - assert_matches_type(Lockdown, lockdown, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_update(self, client: Cloudflare) -> None: - response = client.firewall.lockdowns.with_raw_response.update( - lock_downs_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - configurations=[{}, {}, {}], - urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"], - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - lockdown = response.parse() - assert_matches_type(Lockdown, lockdown, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_update(self, client: Cloudflare) -> None: - with client.firewall.lockdowns.with_streaming_response.update( - lock_downs_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - configurations=[{}, {}, {}], - urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"], - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - lockdown = response.parse() - assert_matches_type(Lockdown, lockdown, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_update(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.firewall.lockdowns.with_raw_response.update( - lock_downs_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="", - configurations=[{}, {}, {}], - urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"], - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `lock_downs_id` but received ''"): - client.firewall.lockdowns.with_raw_response.update( - lock_downs_id="", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - configurations=[{}, {}, {}], - urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"], - ) - - @parametrize - def test_method_list(self, client: Cloudflare) -> None: - lockdown = client.firewall.lockdowns.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(SyncV4PagePaginationArray[Lockdown], lockdown, path=["response"]) - - @parametrize - def test_method_list_with_all_params(self, client: Cloudflare) -> None: - lockdown = client.firewall.lockdowns.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - created_on=parse_datetime("2014-01-01T05:20:00.12345Z"), - description="endpoints", - description_search="endpoints", - ip="1.2.3.4", - ip_range_search="1.2.3.0/16", - ip_search="1.2.3.4", - modified_on=parse_datetime("2014-01-01T05:20:00.12345Z"), - page=1, - per_page=1, - priority=5, - uri_search="/some/path", - ) - assert_matches_type(SyncV4PagePaginationArray[Lockdown], lockdown, path=["response"]) - - @parametrize - def test_raw_response_list(self, client: Cloudflare) -> None: - response = client.firewall.lockdowns.with_raw_response.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - lockdown = response.parse() - assert_matches_type(SyncV4PagePaginationArray[Lockdown], lockdown, path=["response"]) - - @parametrize - def test_streaming_response_list(self, client: Cloudflare) -> None: - with client.firewall.lockdowns.with_streaming_response.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - lockdown = response.parse() - assert_matches_type(SyncV4PagePaginationArray[Lockdown], lockdown, 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 `zone_id` but received ''"): - client.firewall.lockdowns.with_raw_response.list( - zone_id="", - ) - - @parametrize - def test_method_delete(self, client: Cloudflare) -> None: - lockdown = client.firewall.lockdowns.delete( - lock_downs_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Optional[LockdownDeleteResponse], lockdown, path=["response"]) - - @parametrize - def test_raw_response_delete(self, client: Cloudflare) -> None: - response = client.firewall.lockdowns.with_raw_response.delete( - lock_downs_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - lockdown = response.parse() - assert_matches_type(Optional[LockdownDeleteResponse], lockdown, path=["response"]) - - @parametrize - def test_streaming_response_delete(self, client: Cloudflare) -> None: - with client.firewall.lockdowns.with_streaming_response.delete( - lock_downs_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - lockdown = response.parse() - assert_matches_type(Optional[LockdownDeleteResponse], lockdown, 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 `zone_id` but received ''"): - client.firewall.lockdowns.with_raw_response.delete( - lock_downs_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `lock_downs_id` but received ''"): - client.firewall.lockdowns.with_raw_response.delete( - lock_downs_id="", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - @parametrize - def test_method_get(self, client: Cloudflare) -> None: - lockdown = client.firewall.lockdowns.get( - lock_downs_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Lockdown, lockdown, path=["response"]) - - @parametrize - def test_raw_response_get(self, client: Cloudflare) -> None: - response = client.firewall.lockdowns.with_raw_response.get( - lock_downs_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - lockdown = response.parse() - assert_matches_type(Lockdown, lockdown, path=["response"]) - - @parametrize - def test_streaming_response_get(self, client: Cloudflare) -> None: - with client.firewall.lockdowns.with_streaming_response.get( - lock_downs_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - lockdown = response.parse() - assert_matches_type(Lockdown, lockdown, 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.firewall.lockdowns.with_raw_response.get( - lock_downs_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `lock_downs_id` but received ''"): - client.firewall.lockdowns.with_raw_response.get( - lock_downs_id="", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - -class TestAsyncLockdowns: - parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create(self, async_client: AsyncCloudflare) -> None: - lockdown = await async_client.firewall.lockdowns.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - configurations=[{}, {}, {}], - urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"], - ) - assert_matches_type(Lockdown, lockdown, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: - response = await async_client.firewall.lockdowns.with_raw_response.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - configurations=[{}, {}, {}], - urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"], - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - lockdown = await response.parse() - assert_matches_type(Lockdown, lockdown, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: - async with async_client.firewall.lockdowns.with_streaming_response.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - configurations=[{}, {}, {}], - urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"], - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - lockdown = await response.parse() - assert_matches_type(Lockdown, lockdown, 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(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.firewall.lockdowns.with_raw_response.create( - zone_id="", - configurations=[{}, {}, {}], - urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"], - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_update(self, async_client: AsyncCloudflare) -> None: - lockdown = await async_client.firewall.lockdowns.update( - lock_downs_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - configurations=[{}, {}, {}], - urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"], - ) - assert_matches_type(Lockdown, lockdown, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: - response = await async_client.firewall.lockdowns.with_raw_response.update( - lock_downs_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - configurations=[{}, {}, {}], - urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"], - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - lockdown = await response.parse() - assert_matches_type(Lockdown, lockdown, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: - async with async_client.firewall.lockdowns.with_streaming_response.update( - lock_downs_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - configurations=[{}, {}, {}], - urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"], - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - lockdown = await response.parse() - assert_matches_type(Lockdown, lockdown, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.firewall.lockdowns.with_raw_response.update( - lock_downs_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="", - configurations=[{}, {}, {}], - urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"], - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `lock_downs_id` but received ''"): - await async_client.firewall.lockdowns.with_raw_response.update( - lock_downs_id="", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - configurations=[{}, {}, {}], - urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"], - ) - - @parametrize - async def test_method_list(self, async_client: AsyncCloudflare) -> None: - lockdown = await async_client.firewall.lockdowns.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(AsyncV4PagePaginationArray[Lockdown], lockdown, path=["response"]) - - @parametrize - async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: - lockdown = await async_client.firewall.lockdowns.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - created_on=parse_datetime("2014-01-01T05:20:00.12345Z"), - description="endpoints", - description_search="endpoints", - ip="1.2.3.4", - ip_range_search="1.2.3.0/16", - ip_search="1.2.3.4", - modified_on=parse_datetime("2014-01-01T05:20:00.12345Z"), - page=1, - per_page=1, - priority=5, - uri_search="/some/path", - ) - assert_matches_type(AsyncV4PagePaginationArray[Lockdown], lockdown, path=["response"]) - - @parametrize - async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: - response = await async_client.firewall.lockdowns.with_raw_response.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - lockdown = await response.parse() - assert_matches_type(AsyncV4PagePaginationArray[Lockdown], lockdown, path=["response"]) - - @parametrize - async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: - async with async_client.firewall.lockdowns.with_streaming_response.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - lockdown = await response.parse() - assert_matches_type(AsyncV4PagePaginationArray[Lockdown], lockdown, 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 `zone_id` but received ''"): - await async_client.firewall.lockdowns.with_raw_response.list( - zone_id="", - ) - - @parametrize - async def test_method_delete(self, async_client: AsyncCloudflare) -> None: - lockdown = await async_client.firewall.lockdowns.delete( - lock_downs_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Optional[LockdownDeleteResponse], lockdown, path=["response"]) - - @parametrize - async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: - response = await async_client.firewall.lockdowns.with_raw_response.delete( - lock_downs_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - lockdown = await response.parse() - assert_matches_type(Optional[LockdownDeleteResponse], lockdown, path=["response"]) - - @parametrize - async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: - async with async_client.firewall.lockdowns.with_streaming_response.delete( - lock_downs_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - lockdown = await response.parse() - assert_matches_type(Optional[LockdownDeleteResponse], lockdown, 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 `zone_id` but received ''"): - await async_client.firewall.lockdowns.with_raw_response.delete( - lock_downs_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `lock_downs_id` but received ''"): - await async_client.firewall.lockdowns.with_raw_response.delete( - lock_downs_id="", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - @parametrize - async def test_method_get(self, async_client: AsyncCloudflare) -> None: - lockdown = await async_client.firewall.lockdowns.get( - lock_downs_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Lockdown, lockdown, path=["response"]) - - @parametrize - async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: - response = await async_client.firewall.lockdowns.with_raw_response.get( - lock_downs_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - lockdown = await response.parse() - assert_matches_type(Lockdown, lockdown, path=["response"]) - - @parametrize - async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: - async with async_client.firewall.lockdowns.with_streaming_response.get( - lock_downs_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - lockdown = await response.parse() - assert_matches_type(Lockdown, lockdown, 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.firewall.lockdowns.with_raw_response.get( - lock_downs_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `lock_downs_id` but received ''"): - await async_client.firewall.lockdowns.with_raw_response.get( - lock_downs_id="", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) diff --git a/tests/api_resources/firewall/test_rules.py b/tests/api_resources/firewall/test_rules.py deleted file mode 100644 index 8f4c18bf1e2..00000000000 --- a/tests/api_resources/firewall/test_rules.py +++ /dev/null @@ -1,835 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import os -from typing import Any, Optional, cast - -import pytest - -from cloudflare import Cloudflare, AsyncCloudflare -from tests.utils import assert_matches_type -from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray -from cloudflare.types.firewall import ( - FirewallRule, - RuleEditResponse, - RuleCreateResponse, -) - -# pyright: reportDeprecated=false - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestRules: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_create(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - rule = client.firewall.rules.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - action={}, - filter={}, - ) - - assert_matches_type(Optional[RuleCreateResponse], rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_create_with_all_params(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - rule = client.firewall.rules.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - action={ - "mode": "simulate", - "response": { - "body": "This request has been rate-limited.", - "content_type": "text/xml", - }, - "timeout": 86400, - }, - filter={ - "description": "Restrict access from these browsers on this address range.", - "expression": '(http.request.uri.path ~ ".*wp-login.php" or http.request.uri.path ~ ".*xmlrpc.php") and ip.addr ne 172.16.22.155', - "paused": False, - "ref": "FIL-100", - }, - ) - - assert_matches_type(Optional[RuleCreateResponse], rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_create(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - response = client.firewall.rules.with_raw_response.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - action={}, - filter={}, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = response.parse() - assert_matches_type(Optional[RuleCreateResponse], rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_create(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - with client.firewall.rules.with_streaming_response.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - action={}, - filter={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - rule = response.parse() - assert_matches_type(Optional[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(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.firewall.rules.with_raw_response.create( - zone_id="", - action={}, - filter={}, - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - rule = client.firewall.rules.update( - rule_id="372e67954025e0ba6aaa6d586b9e0b60", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - action={}, - filter={}, - ) - - assert_matches_type(FirewallRule, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update_with_all_params(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - rule = client.firewall.rules.update( - rule_id="372e67954025e0ba6aaa6d586b9e0b60", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - action={ - "mode": "simulate", - "response": { - "body": "This request has been rate-limited.", - "content_type": "text/xml", - }, - "timeout": 86400, - }, - filter={ - "description": "Restrict access from these browsers on this address range.", - "expression": '(http.request.uri.path ~ ".*wp-login.php" or http.request.uri.path ~ ".*xmlrpc.php") and ip.addr ne 172.16.22.155', - "paused": False, - "ref": "FIL-100", - }, - ) - - assert_matches_type(FirewallRule, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_update(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - response = client.firewall.rules.with_raw_response.update( - rule_id="372e67954025e0ba6aaa6d586b9e0b60", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - action={}, - filter={}, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = response.parse() - assert_matches_type(FirewallRule, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_update(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - with client.firewall.rules.with_streaming_response.update( - rule_id="372e67954025e0ba6aaa6d586b9e0b60", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - action={}, - filter={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - rule = response.parse() - assert_matches_type(FirewallRule, rule, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_update(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.firewall.rules.with_raw_response.update( - rule_id="372e67954025e0ba6aaa6d586b9e0b60", - zone_id="", - action={}, - filter={}, - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): - client.firewall.rules.with_raw_response.update( - rule_id="", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - action={}, - filter={}, - ) - - @parametrize - def test_method_list(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - rule = client.firewall.rules.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert_matches_type(SyncV4PagePaginationArray[FirewallRule], rule, path=["response"]) - - @parametrize - def test_method_list_with_all_params(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - rule = client.firewall.rules.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - id="372e67954025e0ba6aaa6d586b9e0b60", - action="block", - description="mir", - page=1, - paused=False, - per_page=5, - ) - - assert_matches_type(SyncV4PagePaginationArray[FirewallRule], rule, path=["response"]) - - @parametrize - def test_raw_response_list(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - response = client.firewall.rules.with_raw_response.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = response.parse() - assert_matches_type(SyncV4PagePaginationArray[FirewallRule], rule, path=["response"]) - - @parametrize - def test_streaming_response_list(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - with client.firewall.rules.with_streaming_response.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - rule = response.parse() - assert_matches_type(SyncV4PagePaginationArray[FirewallRule], rule, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_list(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.firewall.rules.with_raw_response.list( - zone_id="", - ) - - @parametrize - def test_method_delete(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - rule = client.firewall.rules.delete( - rule_id="372e67954025e0ba6aaa6d586b9e0b60", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert_matches_type(FirewallRule, rule, path=["response"]) - - @parametrize - def test_raw_response_delete(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - response = client.firewall.rules.with_raw_response.delete( - rule_id="372e67954025e0ba6aaa6d586b9e0b60", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = response.parse() - assert_matches_type(FirewallRule, rule, path=["response"]) - - @parametrize - def test_streaming_response_delete(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - with client.firewall.rules.with_streaming_response.delete( - rule_id="372e67954025e0ba6aaa6d586b9e0b60", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - rule = response.parse() - assert_matches_type(FirewallRule, rule, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_delete(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.firewall.rules.with_raw_response.delete( - rule_id="372e67954025e0ba6aaa6d586b9e0b60", - zone_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): - client.firewall.rules.with_raw_response.delete( - rule_id="", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_edit(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - rule = client.firewall.rules.edit( - rule_id="372e67954025e0ba6aaa6d586b9e0b60", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert_matches_type(Optional[RuleEditResponse], rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_edit(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - response = client.firewall.rules.with_raw_response.edit( - rule_id="372e67954025e0ba6aaa6d586b9e0b60", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = response.parse() - assert_matches_type(Optional[RuleEditResponse], rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_edit(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - with client.firewall.rules.with_streaming_response.edit( - rule_id="372e67954025e0ba6aaa6d586b9e0b60", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - rule = response.parse() - assert_matches_type(Optional[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(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.firewall.rules.with_raw_response.edit( - rule_id="372e67954025e0ba6aaa6d586b9e0b60", - zone_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): - client.firewall.rules.with_raw_response.edit( - rule_id="", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - @parametrize - def test_method_get(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - rule = client.firewall.rules.get( - rule_id="372e67954025e0ba6aaa6d586b9e0b60", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert_matches_type(FirewallRule, rule, path=["response"]) - - @parametrize - def test_method_get_with_all_params(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - rule = client.firewall.rules.get( - rule_id="372e67954025e0ba6aaa6d586b9e0b60", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - id="372e67954025e0ba6aaa6d586b9e0b60", - ) - - assert_matches_type(FirewallRule, rule, path=["response"]) - - @parametrize - def test_raw_response_get(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - response = client.firewall.rules.with_raw_response.get( - rule_id="372e67954025e0ba6aaa6d586b9e0b60", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = response.parse() - assert_matches_type(FirewallRule, rule, path=["response"]) - - @parametrize - def test_streaming_response_get(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - with client.firewall.rules.with_streaming_response.get( - rule_id="372e67954025e0ba6aaa6d586b9e0b60", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - rule = response.parse() - assert_matches_type(FirewallRule, rule, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_get(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.firewall.rules.with_raw_response.get( - rule_id="372e67954025e0ba6aaa6d586b9e0b60", - zone_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): - client.firewall.rules.with_raw_response.get( - rule_id="", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - -class TestAsyncRules: - parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - rule = await async_client.firewall.rules.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - action={}, - filter={}, - ) - - assert_matches_type(Optional[RuleCreateResponse], rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - rule = await async_client.firewall.rules.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - action={ - "mode": "simulate", - "response": { - "body": "This request has been rate-limited.", - "content_type": "text/xml", - }, - "timeout": 86400, - }, - filter={ - "description": "Restrict access from these browsers on this address range.", - "expression": '(http.request.uri.path ~ ".*wp-login.php" or http.request.uri.path ~ ".*xmlrpc.php") and ip.addr ne 172.16.22.155', - "paused": False, - "ref": "FIL-100", - }, - ) - - assert_matches_type(Optional[RuleCreateResponse], rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.firewall.rules.with_raw_response.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - action={}, - filter={}, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = await response.parse() - assert_matches_type(Optional[RuleCreateResponse], rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.firewall.rules.with_streaming_response.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - action={}, - filter={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - rule = await response.parse() - assert_matches_type(Optional[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(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.firewall.rules.with_raw_response.create( - zone_id="", - action={}, - filter={}, - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_update(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - rule = await async_client.firewall.rules.update( - rule_id="372e67954025e0ba6aaa6d586b9e0b60", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - action={}, - filter={}, - ) - - assert_matches_type(FirewallRule, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - rule = await async_client.firewall.rules.update( - rule_id="372e67954025e0ba6aaa6d586b9e0b60", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - action={ - "mode": "simulate", - "response": { - "body": "This request has been rate-limited.", - "content_type": "text/xml", - }, - "timeout": 86400, - }, - filter={ - "description": "Restrict access from these browsers on this address range.", - "expression": '(http.request.uri.path ~ ".*wp-login.php" or http.request.uri.path ~ ".*xmlrpc.php") and ip.addr ne 172.16.22.155', - "paused": False, - "ref": "FIL-100", - }, - ) - - assert_matches_type(FirewallRule, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.firewall.rules.with_raw_response.update( - rule_id="372e67954025e0ba6aaa6d586b9e0b60", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - action={}, - filter={}, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = await response.parse() - assert_matches_type(FirewallRule, rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.firewall.rules.with_streaming_response.update( - rule_id="372e67954025e0ba6aaa6d586b9e0b60", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - action={}, - filter={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - rule = await response.parse() - assert_matches_type(FirewallRule, 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_update(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.firewall.rules.with_raw_response.update( - rule_id="372e67954025e0ba6aaa6d586b9e0b60", - zone_id="", - action={}, - filter={}, - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): - await async_client.firewall.rules.with_raw_response.update( - rule_id="", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - action={}, - filter={}, - ) - - @parametrize - async def test_method_list(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - rule = await async_client.firewall.rules.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert_matches_type(AsyncV4PagePaginationArray[FirewallRule], rule, path=["response"]) - - @parametrize - async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - rule = await async_client.firewall.rules.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - id="372e67954025e0ba6aaa6d586b9e0b60", - action="block", - description="mir", - page=1, - paused=False, - per_page=5, - ) - - assert_matches_type(AsyncV4PagePaginationArray[FirewallRule], rule, path=["response"]) - - @parametrize - async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.firewall.rules.with_raw_response.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = await response.parse() - assert_matches_type(AsyncV4PagePaginationArray[FirewallRule], rule, path=["response"]) - - @parametrize - async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.firewall.rules.with_streaming_response.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - rule = await response.parse() - assert_matches_type(AsyncV4PagePaginationArray[FirewallRule], rule, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.firewall.rules.with_raw_response.list( - zone_id="", - ) - - @parametrize - async def test_method_delete(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - rule = await async_client.firewall.rules.delete( - rule_id="372e67954025e0ba6aaa6d586b9e0b60", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert_matches_type(FirewallRule, rule, path=["response"]) - - @parametrize - async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.firewall.rules.with_raw_response.delete( - rule_id="372e67954025e0ba6aaa6d586b9e0b60", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = await response.parse() - assert_matches_type(FirewallRule, rule, path=["response"]) - - @parametrize - async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.firewall.rules.with_streaming_response.delete( - rule_id="372e67954025e0ba6aaa6d586b9e0b60", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - rule = await response.parse() - assert_matches_type(FirewallRule, rule, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.firewall.rules.with_raw_response.delete( - rule_id="372e67954025e0ba6aaa6d586b9e0b60", - zone_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): - await async_client.firewall.rules.with_raw_response.delete( - rule_id="", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_edit(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - rule = await async_client.firewall.rules.edit( - rule_id="372e67954025e0ba6aaa6d586b9e0b60", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert_matches_type(Optional[RuleEditResponse], rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.firewall.rules.with_raw_response.edit( - rule_id="372e67954025e0ba6aaa6d586b9e0b60", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = await response.parse() - assert_matches_type(Optional[RuleEditResponse], rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.firewall.rules.with_streaming_response.edit( - rule_id="372e67954025e0ba6aaa6d586b9e0b60", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - rule = await response.parse() - assert_matches_type(Optional[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(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.firewall.rules.with_raw_response.edit( - rule_id="372e67954025e0ba6aaa6d586b9e0b60", - zone_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): - await async_client.firewall.rules.with_raw_response.edit( - rule_id="", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - @parametrize - async def test_method_get(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - rule = await async_client.firewall.rules.get( - rule_id="372e67954025e0ba6aaa6d586b9e0b60", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert_matches_type(FirewallRule, rule, path=["response"]) - - @parametrize - async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - rule = await async_client.firewall.rules.get( - rule_id="372e67954025e0ba6aaa6d586b9e0b60", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - id="372e67954025e0ba6aaa6d586b9e0b60", - ) - - assert_matches_type(FirewallRule, rule, path=["response"]) - - @parametrize - async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.firewall.rules.with_raw_response.get( - rule_id="372e67954025e0ba6aaa6d586b9e0b60", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = await response.parse() - assert_matches_type(FirewallRule, rule, path=["response"]) - - @parametrize - async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.firewall.rules.with_streaming_response.get( - rule_id="372e67954025e0ba6aaa6d586b9e0b60", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - rule = await response.parse() - assert_matches_type(FirewallRule, rule, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.firewall.rules.with_raw_response.get( - rule_id="372e67954025e0ba6aaa6d586b9e0b60", - zone_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): - await async_client.firewall.rules.with_raw_response.get( - rule_id="", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) diff --git a/tests/api_resources/firewall/test_ua_rules.py b/tests/api_resources/firewall/test_ua_rules.py deleted file mode 100644 index 4dae57f296b..00000000000 --- a/tests/api_resources/firewall/test_ua_rules.py +++ /dev/null @@ -1,599 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import os -from typing import Any, cast - -import pytest - -from cloudflare import Cloudflare, AsyncCloudflare -from tests.utils import assert_matches_type -from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray -from cloudflare.types.firewall import ( - UARuleGetResponse, - UARuleListResponse, - UARuleCreateResponse, - UARuleDeleteResponse, - UARuleUpdateResponse, -) - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestUARules: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_create(self, client: Cloudflare) -> None: - ua_rule = client.firewall.ua_rules.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - configuration={}, - mode="block", - ) - assert_matches_type(UARuleCreateResponse, ua_rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_create_with_all_params(self, client: Cloudflare) -> None: - ua_rule = client.firewall.ua_rules.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - configuration={ - "target": "ip", - "value": "198.51.100.4", - }, - mode="block", - ) - assert_matches_type(UARuleCreateResponse, ua_rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_create(self, client: Cloudflare) -> None: - response = client.firewall.ua_rules.with_raw_response.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - configuration={}, - mode="block", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - ua_rule = response.parse() - assert_matches_type(UARuleCreateResponse, ua_rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_create(self, client: Cloudflare) -> None: - with client.firewall.ua_rules.with_streaming_response.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - configuration={}, - mode="block", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - ua_rule = response.parse() - assert_matches_type(UARuleCreateResponse, ua_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(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.firewall.ua_rules.with_raw_response.create( - zone_id="", - configuration={}, - mode="block", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update(self, client: Cloudflare) -> None: - ua_rule = client.firewall.ua_rules.update( - ua_rule_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - configuration={}, - mode="block", - ) - assert_matches_type(UARuleUpdateResponse, ua_rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update_with_all_params(self, client: Cloudflare) -> None: - ua_rule = client.firewall.ua_rules.update( - ua_rule_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - configuration={ - "target": "ip", - "value": "198.51.100.4", - }, - mode="block", - ) - assert_matches_type(UARuleUpdateResponse, ua_rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_update(self, client: Cloudflare) -> None: - response = client.firewall.ua_rules.with_raw_response.update( - ua_rule_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - configuration={}, - mode="block", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - ua_rule = response.parse() - assert_matches_type(UARuleUpdateResponse, ua_rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_update(self, client: Cloudflare) -> None: - with client.firewall.ua_rules.with_streaming_response.update( - ua_rule_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - configuration={}, - mode="block", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - ua_rule = response.parse() - assert_matches_type(UARuleUpdateResponse, ua_rule, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_update(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.firewall.ua_rules.with_raw_response.update( - ua_rule_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="", - configuration={}, - mode="block", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `ua_rule_id` but received ''"): - client.firewall.ua_rules.with_raw_response.update( - ua_rule_id="", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - configuration={}, - mode="block", - ) - - @parametrize - def test_method_list(self, client: Cloudflare) -> None: - ua_rule = client.firewall.ua_rules.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(SyncV4PagePaginationArray[UARuleListResponse], ua_rule, path=["response"]) - - @parametrize - def test_method_list_with_all_params(self, client: Cloudflare) -> None: - ua_rule = client.firewall.ua_rules.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - description="abusive", - description_search="abusive", - page=1, - per_page=1, - ua_search="Safari", - ) - assert_matches_type(SyncV4PagePaginationArray[UARuleListResponse], ua_rule, path=["response"]) - - @parametrize - def test_raw_response_list(self, client: Cloudflare) -> None: - response = client.firewall.ua_rules.with_raw_response.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - ua_rule = response.parse() - assert_matches_type(SyncV4PagePaginationArray[UARuleListResponse], ua_rule, path=["response"]) - - @parametrize - def test_streaming_response_list(self, client: Cloudflare) -> None: - with client.firewall.ua_rules.with_streaming_response.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - ua_rule = response.parse() - assert_matches_type(SyncV4PagePaginationArray[UARuleListResponse], ua_rule, 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 `zone_id` but received ''"): - client.firewall.ua_rules.with_raw_response.list( - zone_id="", - ) - - @parametrize - def test_method_delete(self, client: Cloudflare) -> None: - ua_rule = client.firewall.ua_rules.delete( - ua_rule_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(UARuleDeleteResponse, ua_rule, path=["response"]) - - @parametrize - def test_raw_response_delete(self, client: Cloudflare) -> None: - response = client.firewall.ua_rules.with_raw_response.delete( - ua_rule_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - ua_rule = response.parse() - assert_matches_type(UARuleDeleteResponse, ua_rule, path=["response"]) - - @parametrize - def test_streaming_response_delete(self, client: Cloudflare) -> None: - with client.firewall.ua_rules.with_streaming_response.delete( - ua_rule_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - ua_rule = response.parse() - assert_matches_type(UARuleDeleteResponse, ua_rule, 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 `zone_id` but received ''"): - client.firewall.ua_rules.with_raw_response.delete( - ua_rule_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `ua_rule_id` but received ''"): - client.firewall.ua_rules.with_raw_response.delete( - ua_rule_id="", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - @parametrize - def test_method_get(self, client: Cloudflare) -> None: - ua_rule = client.firewall.ua_rules.get( - ua_rule_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(UARuleGetResponse, ua_rule, path=["response"]) - - @parametrize - def test_raw_response_get(self, client: Cloudflare) -> None: - response = client.firewall.ua_rules.with_raw_response.get( - ua_rule_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - ua_rule = response.parse() - assert_matches_type(UARuleGetResponse, ua_rule, path=["response"]) - - @parametrize - def test_streaming_response_get(self, client: Cloudflare) -> None: - with client.firewall.ua_rules.with_streaming_response.get( - ua_rule_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - ua_rule = response.parse() - assert_matches_type(UARuleGetResponse, ua_rule, 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.firewall.ua_rules.with_raw_response.get( - ua_rule_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `ua_rule_id` but received ''"): - client.firewall.ua_rules.with_raw_response.get( - ua_rule_id="", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - -class TestAsyncUARules: - parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create(self, async_client: AsyncCloudflare) -> None: - ua_rule = await async_client.firewall.ua_rules.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - configuration={}, - mode="block", - ) - assert_matches_type(UARuleCreateResponse, ua_rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: - ua_rule = await async_client.firewall.ua_rules.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - configuration={ - "target": "ip", - "value": "198.51.100.4", - }, - mode="block", - ) - assert_matches_type(UARuleCreateResponse, ua_rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: - response = await async_client.firewall.ua_rules.with_raw_response.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - configuration={}, - mode="block", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - ua_rule = await response.parse() - assert_matches_type(UARuleCreateResponse, ua_rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: - async with async_client.firewall.ua_rules.with_streaming_response.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - configuration={}, - mode="block", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - ua_rule = await response.parse() - assert_matches_type(UARuleCreateResponse, ua_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(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.firewall.ua_rules.with_raw_response.create( - zone_id="", - configuration={}, - mode="block", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_update(self, async_client: AsyncCloudflare) -> None: - ua_rule = await async_client.firewall.ua_rules.update( - ua_rule_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - configuration={}, - mode="block", - ) - assert_matches_type(UARuleUpdateResponse, ua_rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: - ua_rule = await async_client.firewall.ua_rules.update( - ua_rule_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - configuration={ - "target": "ip", - "value": "198.51.100.4", - }, - mode="block", - ) - assert_matches_type(UARuleUpdateResponse, ua_rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: - response = await async_client.firewall.ua_rules.with_raw_response.update( - ua_rule_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - configuration={}, - mode="block", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - ua_rule = await response.parse() - assert_matches_type(UARuleUpdateResponse, ua_rule, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: - async with async_client.firewall.ua_rules.with_streaming_response.update( - ua_rule_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - configuration={}, - mode="block", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - ua_rule = await response.parse() - assert_matches_type(UARuleUpdateResponse, ua_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_update(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.firewall.ua_rules.with_raw_response.update( - ua_rule_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="", - configuration={}, - mode="block", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `ua_rule_id` but received ''"): - await async_client.firewall.ua_rules.with_raw_response.update( - ua_rule_id="", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - configuration={}, - mode="block", - ) - - @parametrize - async def test_method_list(self, async_client: AsyncCloudflare) -> None: - ua_rule = await async_client.firewall.ua_rules.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(AsyncV4PagePaginationArray[UARuleListResponse], ua_rule, path=["response"]) - - @parametrize - async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: - ua_rule = await async_client.firewall.ua_rules.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - description="abusive", - description_search="abusive", - page=1, - per_page=1, - ua_search="Safari", - ) - assert_matches_type(AsyncV4PagePaginationArray[UARuleListResponse], ua_rule, path=["response"]) - - @parametrize - async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: - response = await async_client.firewall.ua_rules.with_raw_response.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - ua_rule = await response.parse() - assert_matches_type(AsyncV4PagePaginationArray[UARuleListResponse], ua_rule, path=["response"]) - - @parametrize - async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: - async with async_client.firewall.ua_rules.with_streaming_response.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - ua_rule = await response.parse() - assert_matches_type(AsyncV4PagePaginationArray[UARuleListResponse], ua_rule, 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 `zone_id` but received ''"): - await async_client.firewall.ua_rules.with_raw_response.list( - zone_id="", - ) - - @parametrize - async def test_method_delete(self, async_client: AsyncCloudflare) -> None: - ua_rule = await async_client.firewall.ua_rules.delete( - ua_rule_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(UARuleDeleteResponse, ua_rule, path=["response"]) - - @parametrize - async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: - response = await async_client.firewall.ua_rules.with_raw_response.delete( - ua_rule_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - ua_rule = await response.parse() - assert_matches_type(UARuleDeleteResponse, ua_rule, path=["response"]) - - @parametrize - async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: - async with async_client.firewall.ua_rules.with_streaming_response.delete( - ua_rule_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - ua_rule = await response.parse() - assert_matches_type(UARuleDeleteResponse, ua_rule, 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 `zone_id` but received ''"): - await async_client.firewall.ua_rules.with_raw_response.delete( - ua_rule_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `ua_rule_id` but received ''"): - await async_client.firewall.ua_rules.with_raw_response.delete( - ua_rule_id="", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - @parametrize - async def test_method_get(self, async_client: AsyncCloudflare) -> None: - ua_rule = await async_client.firewall.ua_rules.get( - ua_rule_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(UARuleGetResponse, ua_rule, path=["response"]) - - @parametrize - async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: - response = await async_client.firewall.ua_rules.with_raw_response.get( - ua_rule_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - ua_rule = await response.parse() - assert_matches_type(UARuleGetResponse, ua_rule, path=["response"]) - - @parametrize - async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: - async with async_client.firewall.ua_rules.with_streaming_response.get( - ua_rule_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - ua_rule = await response.parse() - assert_matches_type(UARuleGetResponse, ua_rule, 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.firewall.ua_rules.with_raw_response.get( - ua_rule_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `ua_rule_id` but received ''"): - await async_client.firewall.ua_rules.with_raw_response.get( - ua_rule_id="", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) diff --git a/tests/api_resources/firewall/waf/test_overrides.py b/tests/api_resources/firewall/waf/test_overrides.py deleted file mode 100644 index 6c62fed412b..00000000000 --- a/tests/api_resources/firewall/waf/test_overrides.py +++ /dev/null @@ -1,586 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import os -from typing import Any, Optional, cast - -import pytest - -from cloudflare import Cloudflare, AsyncCloudflare -from tests.utils import assert_matches_type -from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray -from cloudflare.types.firewall.waf import ( - Override, - OverrideDeleteResponse, -) - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestOverrides: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_create(self, client: Cloudflare) -> None: - override = client.firewall.waf.overrides.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"], - ) - assert_matches_type(Override, override, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_create(self, client: Cloudflare) -> None: - response = client.firewall.waf.overrides.with_raw_response.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"], - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - override = response.parse() - assert_matches_type(Override, override, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_create(self, client: Cloudflare) -> None: - with client.firewall.waf.overrides.with_streaming_response.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"], - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - override = response.parse() - assert_matches_type(Override, override, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_create(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.firewall.waf.overrides.with_raw_response.create( - zone_id="", - urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"], - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update(self, client: Cloudflare) -> None: - override = client.firewall.waf.overrides.update( - overrides_id="de677e5818985db1285d0e80225f06e5", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - id="023e105f4ecef8ad9ca31a8372d0c353", - rewrite_action={}, - rules={"100015": "challenge"}, - urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"], - ) - assert_matches_type(Override, override, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update_with_all_params(self, client: Cloudflare) -> None: - override = client.firewall.waf.overrides.update( - overrides_id="de677e5818985db1285d0e80225f06e5", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - id="023e105f4ecef8ad9ca31a8372d0c353", - rewrite_action={ - "block": "challenge", - "challenge": "challenge", - "default": "challenge", - "disable": "challenge", - "simulate": "challenge", - }, - rules={"100015": "challenge"}, - urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"], - ) - assert_matches_type(Override, override, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_update(self, client: Cloudflare) -> None: - response = client.firewall.waf.overrides.with_raw_response.update( - overrides_id="de677e5818985db1285d0e80225f06e5", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - id="023e105f4ecef8ad9ca31a8372d0c353", - rewrite_action={}, - rules={"100015": "challenge"}, - urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"], - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - override = response.parse() - assert_matches_type(Override, override, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_update(self, client: Cloudflare) -> None: - with client.firewall.waf.overrides.with_streaming_response.update( - overrides_id="de677e5818985db1285d0e80225f06e5", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - id="023e105f4ecef8ad9ca31a8372d0c353", - rewrite_action={}, - rules={"100015": "challenge"}, - urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"], - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - override = response.parse() - assert_matches_type(Override, override, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_update(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.firewall.waf.overrides.with_raw_response.update( - overrides_id="de677e5818985db1285d0e80225f06e5", - zone_id="", - id="023e105f4ecef8ad9ca31a8372d0c353", - rewrite_action={}, - rules={"100015": "challenge"}, - urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"], - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `overrides_id` but received ''"): - client.firewall.waf.overrides.with_raw_response.update( - overrides_id="", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - id="023e105f4ecef8ad9ca31a8372d0c353", - rewrite_action={}, - rules={"100015": "challenge"}, - urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"], - ) - - @parametrize - def test_method_list(self, client: Cloudflare) -> None: - override = client.firewall.waf.overrides.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(SyncV4PagePaginationArray[Override], override, path=["response"]) - - @parametrize - def test_method_list_with_all_params(self, client: Cloudflare) -> None: - override = client.firewall.waf.overrides.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - page=1, - per_page=5, - ) - assert_matches_type(SyncV4PagePaginationArray[Override], override, path=["response"]) - - @parametrize - def test_raw_response_list(self, client: Cloudflare) -> None: - response = client.firewall.waf.overrides.with_raw_response.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - override = response.parse() - assert_matches_type(SyncV4PagePaginationArray[Override], override, path=["response"]) - - @parametrize - def test_streaming_response_list(self, client: Cloudflare) -> None: - with client.firewall.waf.overrides.with_streaming_response.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - override = response.parse() - assert_matches_type(SyncV4PagePaginationArray[Override], override, 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 `zone_id` but received ''"): - client.firewall.waf.overrides.with_raw_response.list( - zone_id="", - ) - - @parametrize - def test_method_delete(self, client: Cloudflare) -> None: - override = client.firewall.waf.overrides.delete( - overrides_id="de677e5818985db1285d0e80225f06e5", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Optional[OverrideDeleteResponse], override, path=["response"]) - - @parametrize - def test_raw_response_delete(self, client: Cloudflare) -> None: - response = client.firewall.waf.overrides.with_raw_response.delete( - overrides_id="de677e5818985db1285d0e80225f06e5", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - override = response.parse() - assert_matches_type(Optional[OverrideDeleteResponse], override, path=["response"]) - - @parametrize - def test_streaming_response_delete(self, client: Cloudflare) -> None: - with client.firewall.waf.overrides.with_streaming_response.delete( - overrides_id="de677e5818985db1285d0e80225f06e5", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - override = response.parse() - assert_matches_type(Optional[OverrideDeleteResponse], override, 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 `zone_id` but received ''"): - client.firewall.waf.overrides.with_raw_response.delete( - overrides_id="de677e5818985db1285d0e80225f06e5", - zone_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `overrides_id` but received ''"): - client.firewall.waf.overrides.with_raw_response.delete( - overrides_id="", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - @parametrize - def test_method_get(self, client: Cloudflare) -> None: - override = client.firewall.waf.overrides.get( - overrides_id="de677e5818985db1285d0e80225f06e5", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Override, override, path=["response"]) - - @parametrize - def test_raw_response_get(self, client: Cloudflare) -> None: - response = client.firewall.waf.overrides.with_raw_response.get( - overrides_id="de677e5818985db1285d0e80225f06e5", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - override = response.parse() - assert_matches_type(Override, override, path=["response"]) - - @parametrize - def test_streaming_response_get(self, client: Cloudflare) -> None: - with client.firewall.waf.overrides.with_streaming_response.get( - overrides_id="de677e5818985db1285d0e80225f06e5", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - override = response.parse() - assert_matches_type(Override, override, 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.firewall.waf.overrides.with_raw_response.get( - overrides_id="de677e5818985db1285d0e80225f06e5", - zone_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `overrides_id` but received ''"): - client.firewall.waf.overrides.with_raw_response.get( - overrides_id="", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - -class TestAsyncOverrides: - parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create(self, async_client: AsyncCloudflare) -> None: - override = await async_client.firewall.waf.overrides.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"], - ) - assert_matches_type(Override, override, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: - response = await async_client.firewall.waf.overrides.with_raw_response.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"], - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - override = await response.parse() - assert_matches_type(Override, override, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: - async with async_client.firewall.waf.overrides.with_streaming_response.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"], - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - override = await response.parse() - assert_matches_type(Override, override, 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(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.firewall.waf.overrides.with_raw_response.create( - zone_id="", - urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"], - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_update(self, async_client: AsyncCloudflare) -> None: - override = await async_client.firewall.waf.overrides.update( - overrides_id="de677e5818985db1285d0e80225f06e5", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - id="023e105f4ecef8ad9ca31a8372d0c353", - rewrite_action={}, - rules={"100015": "challenge"}, - urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"], - ) - assert_matches_type(Override, override, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: - override = await async_client.firewall.waf.overrides.update( - overrides_id="de677e5818985db1285d0e80225f06e5", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - id="023e105f4ecef8ad9ca31a8372d0c353", - rewrite_action={ - "block": "challenge", - "challenge": "challenge", - "default": "challenge", - "disable": "challenge", - "simulate": "challenge", - }, - rules={"100015": "challenge"}, - urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"], - ) - assert_matches_type(Override, override, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: - response = await async_client.firewall.waf.overrides.with_raw_response.update( - overrides_id="de677e5818985db1285d0e80225f06e5", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - id="023e105f4ecef8ad9ca31a8372d0c353", - rewrite_action={}, - rules={"100015": "challenge"}, - urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"], - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - override = await response.parse() - assert_matches_type(Override, override, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: - async with async_client.firewall.waf.overrides.with_streaming_response.update( - overrides_id="de677e5818985db1285d0e80225f06e5", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - id="023e105f4ecef8ad9ca31a8372d0c353", - rewrite_action={}, - rules={"100015": "challenge"}, - urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"], - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - override = await response.parse() - assert_matches_type(Override, override, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.firewall.waf.overrides.with_raw_response.update( - overrides_id="de677e5818985db1285d0e80225f06e5", - zone_id="", - id="023e105f4ecef8ad9ca31a8372d0c353", - rewrite_action={}, - rules={"100015": "challenge"}, - urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"], - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `overrides_id` but received ''"): - await async_client.firewall.waf.overrides.with_raw_response.update( - overrides_id="", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - id="023e105f4ecef8ad9ca31a8372d0c353", - rewrite_action={}, - rules={"100015": "challenge"}, - urls=["shop.example.com/*", "shop.example.com/*", "shop.example.com/*"], - ) - - @parametrize - async def test_method_list(self, async_client: AsyncCloudflare) -> None: - override = await async_client.firewall.waf.overrides.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(AsyncV4PagePaginationArray[Override], override, path=["response"]) - - @parametrize - async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: - override = await async_client.firewall.waf.overrides.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - page=1, - per_page=5, - ) - assert_matches_type(AsyncV4PagePaginationArray[Override], override, path=["response"]) - - @parametrize - async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: - response = await async_client.firewall.waf.overrides.with_raw_response.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - override = await response.parse() - assert_matches_type(AsyncV4PagePaginationArray[Override], override, path=["response"]) - - @parametrize - async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: - async with async_client.firewall.waf.overrides.with_streaming_response.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - override = await response.parse() - assert_matches_type(AsyncV4PagePaginationArray[Override], override, 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 `zone_id` but received ''"): - await async_client.firewall.waf.overrides.with_raw_response.list( - zone_id="", - ) - - @parametrize - async def test_method_delete(self, async_client: AsyncCloudflare) -> None: - override = await async_client.firewall.waf.overrides.delete( - overrides_id="de677e5818985db1285d0e80225f06e5", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Optional[OverrideDeleteResponse], override, path=["response"]) - - @parametrize - async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: - response = await async_client.firewall.waf.overrides.with_raw_response.delete( - overrides_id="de677e5818985db1285d0e80225f06e5", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - override = await response.parse() - assert_matches_type(Optional[OverrideDeleteResponse], override, path=["response"]) - - @parametrize - async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: - async with async_client.firewall.waf.overrides.with_streaming_response.delete( - overrides_id="de677e5818985db1285d0e80225f06e5", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - override = await response.parse() - assert_matches_type(Optional[OverrideDeleteResponse], override, 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 `zone_id` but received ''"): - await async_client.firewall.waf.overrides.with_raw_response.delete( - overrides_id="de677e5818985db1285d0e80225f06e5", - zone_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `overrides_id` but received ''"): - await async_client.firewall.waf.overrides.with_raw_response.delete( - overrides_id="", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - @parametrize - async def test_method_get(self, async_client: AsyncCloudflare) -> None: - override = await async_client.firewall.waf.overrides.get( - overrides_id="de677e5818985db1285d0e80225f06e5", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(Override, override, path=["response"]) - - @parametrize - async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: - response = await async_client.firewall.waf.overrides.with_raw_response.get( - overrides_id="de677e5818985db1285d0e80225f06e5", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - override = await response.parse() - assert_matches_type(Override, override, path=["response"]) - - @parametrize - async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: - async with async_client.firewall.waf.overrides.with_streaming_response.get( - overrides_id="de677e5818985db1285d0e80225f06e5", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - override = await response.parse() - assert_matches_type(Override, override, 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.firewall.waf.overrides.with_raw_response.get( - overrides_id="de677e5818985db1285d0e80225f06e5", - zone_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `overrides_id` but received ''"): - await async_client.firewall.waf.overrides.with_raw_response.get( - overrides_id="", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) diff --git a/tests/api_resources/firewall/waf/test_packages.py b/tests/api_resources/firewall/waf/test_packages.py deleted file mode 100644 index f6f0d2b054e..00000000000 --- a/tests/api_resources/firewall/waf/test_packages.py +++ /dev/null @@ -1,231 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import os -from typing import Any, cast - -import pytest - -from cloudflare import Cloudflare, AsyncCloudflare -from tests.utils import assert_matches_type -from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray -from cloudflare.types.firewall.waf import PackageGetResponse - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestPackages: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_list(self, client: Cloudflare) -> None: - package = client.firewall.waf.packages.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(SyncV4PagePaginationArray[object], package, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_list_with_all_params(self, client: Cloudflare) -> None: - package = client.firewall.waf.packages.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - direction="asc", - match="any", - name="USER", - order="name", - page=1, - per_page=5, - ) - assert_matches_type(SyncV4PagePaginationArray[object], package, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_list(self, client: Cloudflare) -> None: - response = client.firewall.waf.packages.with_raw_response.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - package = response.parse() - assert_matches_type(SyncV4PagePaginationArray[object], package, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_list(self, client: Cloudflare) -> None: - with client.firewall.waf.packages.with_streaming_response.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - package = response.parse() - assert_matches_type(SyncV4PagePaginationArray[object], package, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_list(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.firewall.waf.packages.with_raw_response.list( - zone_id="", - ) - - @parametrize - def test_method_get(self, client: Cloudflare) -> None: - package = client.firewall.waf.packages.get( - package_id="023e105f4ecef8ad9ca31a8372d0c353", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(PackageGetResponse, package, path=["response"]) - - @parametrize - def test_raw_response_get(self, client: Cloudflare) -> None: - response = client.firewall.waf.packages.with_raw_response.get( - package_id="023e105f4ecef8ad9ca31a8372d0c353", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - package = response.parse() - assert_matches_type(PackageGetResponse, package, path=["response"]) - - @parametrize - def test_streaming_response_get(self, client: Cloudflare) -> None: - with client.firewall.waf.packages.with_streaming_response.get( - package_id="023e105f4ecef8ad9ca31a8372d0c353", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - package = response.parse() - assert_matches_type(PackageGetResponse, package, 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.firewall.waf.packages.with_raw_response.get( - package_id="023e105f4ecef8ad9ca31a8372d0c353", - zone_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `package_id` but received ''"): - client.firewall.waf.packages.with_raw_response.get( - package_id="", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - -class TestAsyncPackages: - parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_list(self, async_client: AsyncCloudflare) -> None: - package = await async_client.firewall.waf.packages.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(AsyncV4PagePaginationArray[object], package, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: - package = await async_client.firewall.waf.packages.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - direction="asc", - match="any", - name="USER", - order="name", - page=1, - per_page=5, - ) - assert_matches_type(AsyncV4PagePaginationArray[object], package, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: - response = await async_client.firewall.waf.packages.with_raw_response.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - package = await response.parse() - assert_matches_type(AsyncV4PagePaginationArray[object], package, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: - async with async_client.firewall.waf.packages.with_streaming_response.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - package = await response.parse() - assert_matches_type(AsyncV4PagePaginationArray[object], package, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.firewall.waf.packages.with_raw_response.list( - zone_id="", - ) - - @parametrize - async def test_method_get(self, async_client: AsyncCloudflare) -> None: - package = await async_client.firewall.waf.packages.get( - package_id="023e105f4ecef8ad9ca31a8372d0c353", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(PackageGetResponse, package, path=["response"]) - - @parametrize - async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: - response = await async_client.firewall.waf.packages.with_raw_response.get( - package_id="023e105f4ecef8ad9ca31a8372d0c353", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - package = await response.parse() - assert_matches_type(PackageGetResponse, package, path=["response"]) - - @parametrize - async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: - async with async_client.firewall.waf.packages.with_streaming_response.get( - package_id="023e105f4ecef8ad9ca31a8372d0c353", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - package = await response.parse() - assert_matches_type(PackageGetResponse, package, 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.firewall.waf.packages.with_raw_response.get( - package_id="023e105f4ecef8ad9ca31a8372d0c353", - zone_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `package_id` but received ''"): - await async_client.firewall.waf.packages.with_raw_response.get( - package_id="", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) diff --git a/tests/api_resources/test_filters.py b/tests/api_resources/test_filters.py deleted file mode 100644 index 683f923ca5a..00000000000 --- a/tests/api_resources/test_filters.py +++ /dev/null @@ -1,584 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import os -from typing import Any, Optional, cast - -import pytest - -from cloudflare import Cloudflare, AsyncCloudflare -from tests.utils import assert_matches_type -from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray -from cloudflare.types.filters import ( - FirewallFilter, - FilterCreateResponse, -) - -# pyright: reportDeprecated=false - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestFilters: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_create(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - filter = client.filters.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - expression='(http.request.uri.path ~ ".*wp-login.php" or http.request.uri.path ~ ".*xmlrpc.php") and ip.addr ne 172.16.22.155', - ) - - assert_matches_type(Optional[FilterCreateResponse], filter, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_create(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - response = client.filters.with_raw_response.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - expression='(http.request.uri.path ~ ".*wp-login.php" or http.request.uri.path ~ ".*xmlrpc.php") and ip.addr ne 172.16.22.155', - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - filter = response.parse() - assert_matches_type(Optional[FilterCreateResponse], filter, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_create(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - with client.filters.with_streaming_response.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - expression='(http.request.uri.path ~ ".*wp-login.php" or http.request.uri.path ~ ".*xmlrpc.php") and ip.addr ne 172.16.22.155', - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - filter = response.parse() - assert_matches_type(Optional[FilterCreateResponse], filter, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_create(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.filters.with_raw_response.create( - zone_id="", - expression='(http.request.uri.path ~ ".*wp-login.php" or http.request.uri.path ~ ".*xmlrpc.php") and ip.addr ne 172.16.22.155', - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_update(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - filter = client.filters.update( - filter_id="372e67954025e0ba6aaa6d586b9e0b61", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) - - assert_matches_type(FirewallFilter, filter, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_update(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - response = client.filters.with_raw_response.update( - filter_id="372e67954025e0ba6aaa6d586b9e0b61", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - filter = response.parse() - assert_matches_type(FirewallFilter, filter, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_update(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - with client.filters.with_streaming_response.update( - filter_id="372e67954025e0ba6aaa6d586b9e0b61", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - filter = response.parse() - assert_matches_type(FirewallFilter, filter, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_update(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.filters.with_raw_response.update( - filter_id="372e67954025e0ba6aaa6d586b9e0b61", - zone_id="", - body={}, - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `filter_id` but received ''"): - client.filters.with_raw_response.update( - filter_id="", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) - - @parametrize - def test_method_list(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - filter = client.filters.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert_matches_type(SyncV4PagePaginationArray[FirewallFilter], filter, path=["response"]) - - @parametrize - def test_method_list_with_all_params(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - filter = client.filters.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - id="372e67954025e0ba6aaa6d586b9e0b61", - description="browsers", - expression="php", - page=1, - paused=False, - per_page=5, - ref="FIL-100", - ) - - assert_matches_type(SyncV4PagePaginationArray[FirewallFilter], filter, path=["response"]) - - @parametrize - def test_raw_response_list(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - response = client.filters.with_raw_response.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - filter = response.parse() - assert_matches_type(SyncV4PagePaginationArray[FirewallFilter], filter, path=["response"]) - - @parametrize - def test_streaming_response_list(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - with client.filters.with_streaming_response.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - filter = response.parse() - assert_matches_type(SyncV4PagePaginationArray[FirewallFilter], filter, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_list(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.filters.with_raw_response.list( - zone_id="", - ) - - @parametrize - def test_method_delete(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - filter = client.filters.delete( - filter_id="372e67954025e0ba6aaa6d586b9e0b61", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert_matches_type(FirewallFilter, filter, path=["response"]) - - @parametrize - def test_raw_response_delete(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - response = client.filters.with_raw_response.delete( - filter_id="372e67954025e0ba6aaa6d586b9e0b61", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - filter = response.parse() - assert_matches_type(FirewallFilter, filter, path=["response"]) - - @parametrize - def test_streaming_response_delete(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - with client.filters.with_streaming_response.delete( - filter_id="372e67954025e0ba6aaa6d586b9e0b61", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - filter = response.parse() - assert_matches_type(FirewallFilter, filter, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_delete(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.filters.with_raw_response.delete( - filter_id="372e67954025e0ba6aaa6d586b9e0b61", - zone_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `filter_id` but received ''"): - client.filters.with_raw_response.delete( - filter_id="", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - @parametrize - def test_method_get(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - filter = client.filters.get( - filter_id="372e67954025e0ba6aaa6d586b9e0b61", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert_matches_type(FirewallFilter, filter, path=["response"]) - - @parametrize - def test_raw_response_get(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - response = client.filters.with_raw_response.get( - filter_id="372e67954025e0ba6aaa6d586b9e0b61", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - filter = response.parse() - assert_matches_type(FirewallFilter, filter, path=["response"]) - - @parametrize - def test_streaming_response_get(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - with client.filters.with_streaming_response.get( - filter_id="372e67954025e0ba6aaa6d586b9e0b61", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - filter = response.parse() - assert_matches_type(FirewallFilter, filter, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_get(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.filters.with_raw_response.get( - filter_id="372e67954025e0ba6aaa6d586b9e0b61", - zone_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `filter_id` but received ''"): - client.filters.with_raw_response.get( - filter_id="", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - -class TestAsyncFilters: - parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - filter = await async_client.filters.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - expression='(http.request.uri.path ~ ".*wp-login.php" or http.request.uri.path ~ ".*xmlrpc.php") and ip.addr ne 172.16.22.155', - ) - - assert_matches_type(Optional[FilterCreateResponse], filter, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.filters.with_raw_response.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - expression='(http.request.uri.path ~ ".*wp-login.php" or http.request.uri.path ~ ".*xmlrpc.php") and ip.addr ne 172.16.22.155', - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - filter = await response.parse() - assert_matches_type(Optional[FilterCreateResponse], filter, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.filters.with_streaming_response.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - expression='(http.request.uri.path ~ ".*wp-login.php" or http.request.uri.path ~ ".*xmlrpc.php") and ip.addr ne 172.16.22.155', - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - filter = await response.parse() - assert_matches_type(Optional[FilterCreateResponse], filter, 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(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.filters.with_raw_response.create( - zone_id="", - expression='(http.request.uri.path ~ ".*wp-login.php" or http.request.uri.path ~ ".*xmlrpc.php") and ip.addr ne 172.16.22.155', - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_update(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - filter = await async_client.filters.update( - filter_id="372e67954025e0ba6aaa6d586b9e0b61", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) - - assert_matches_type(FirewallFilter, filter, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.filters.with_raw_response.update( - filter_id="372e67954025e0ba6aaa6d586b9e0b61", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - filter = await response.parse() - assert_matches_type(FirewallFilter, filter, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.filters.with_streaming_response.update( - filter_id="372e67954025e0ba6aaa6d586b9e0b61", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - filter = await response.parse() - assert_matches_type(FirewallFilter, filter, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.filters.with_raw_response.update( - filter_id="372e67954025e0ba6aaa6d586b9e0b61", - zone_id="", - body={}, - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `filter_id` but received ''"): - await async_client.filters.with_raw_response.update( - filter_id="", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - body={}, - ) - - @parametrize - async def test_method_list(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - filter = await async_client.filters.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert_matches_type(AsyncV4PagePaginationArray[FirewallFilter], filter, path=["response"]) - - @parametrize - async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - filter = await async_client.filters.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - id="372e67954025e0ba6aaa6d586b9e0b61", - description="browsers", - expression="php", - page=1, - paused=False, - per_page=5, - ref="FIL-100", - ) - - assert_matches_type(AsyncV4PagePaginationArray[FirewallFilter], filter, path=["response"]) - - @parametrize - async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.filters.with_raw_response.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - filter = await response.parse() - assert_matches_type(AsyncV4PagePaginationArray[FirewallFilter], filter, path=["response"]) - - @parametrize - async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.filters.with_streaming_response.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - filter = await response.parse() - assert_matches_type(AsyncV4PagePaginationArray[FirewallFilter], filter, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.filters.with_raw_response.list( - zone_id="", - ) - - @parametrize - async def test_method_delete(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - filter = await async_client.filters.delete( - filter_id="372e67954025e0ba6aaa6d586b9e0b61", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert_matches_type(FirewallFilter, filter, path=["response"]) - - @parametrize - async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.filters.with_raw_response.delete( - filter_id="372e67954025e0ba6aaa6d586b9e0b61", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - filter = await response.parse() - assert_matches_type(FirewallFilter, filter, path=["response"]) - - @parametrize - async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.filters.with_streaming_response.delete( - filter_id="372e67954025e0ba6aaa6d586b9e0b61", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - filter = await response.parse() - assert_matches_type(FirewallFilter, filter, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.filters.with_raw_response.delete( - filter_id="372e67954025e0ba6aaa6d586b9e0b61", - zone_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `filter_id` but received ''"): - await async_client.filters.with_raw_response.delete( - filter_id="", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - @parametrize - async def test_method_get(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - filter = await async_client.filters.get( - filter_id="372e67954025e0ba6aaa6d586b9e0b61", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert_matches_type(FirewallFilter, filter, path=["response"]) - - @parametrize - async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.filters.with_raw_response.get( - filter_id="372e67954025e0ba6aaa6d586b9e0b61", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - filter = await response.parse() - assert_matches_type(FirewallFilter, filter, path=["response"]) - - @parametrize - async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.filters.with_streaming_response.get( - filter_id="372e67954025e0ba6aaa6d586b9e0b61", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - filter = await response.parse() - assert_matches_type(FirewallFilter, filter, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.filters.with_raw_response.get( - filter_id="372e67954025e0ba6aaa6d586b9e0b61", - zone_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `filter_id` but received ''"): - await async_client.filters.with_raw_response.get( - filter_id="", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) diff --git a/tests/api_resources/test_rate_limits.py b/tests/api_resources/test_rate_limits.py deleted file mode 100644 index 8433a8e9ae9..00000000000 --- a/tests/api_resources/test_rate_limits.py +++ /dev/null @@ -1,810 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import os -from typing import Any, cast - -import pytest - -from cloudflare import Cloudflare, AsyncCloudflare -from tests.utils import assert_matches_type -from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray -from cloudflare.types.rate_limits import ( - RateLimit, - RateLimitDeleteResponse, -) - -# pyright: reportDeprecated=false - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestRateLimits: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_create(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - rate_limit = client.rate_limits.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - action={}, - match={}, - period=900, - threshold=60, - ) - - assert_matches_type(RateLimit, rate_limit, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_create_with_all_params(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - rate_limit = client.rate_limits.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - action={ - "mode": "simulate", - "response": { - "body": "This request has been rate-limited.", - "content_type": "text/xml", - }, - "timeout": 86400, - }, - match={ - "headers": [ - { - "name": "Cf-Cache-Status", - "op": "eq", - "value": "HIT", - }, - { - "name": "Cf-Cache-Status", - "op": "eq", - "value": "HIT", - }, - { - "name": "Cf-Cache-Status", - "op": "eq", - "value": "HIT", - }, - ], - "request": { - "methods": ["GET", "POST"], - "schemes": ["HTTP", "HTTPS"], - "url": "*.example.org/path*", - }, - "response": {"origin_traffic": True}, - }, - period=900, - threshold=60, - ) - - assert_matches_type(RateLimit, rate_limit, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_create(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - response = client.rate_limits.with_raw_response.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - action={}, - match={}, - period=900, - threshold=60, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rate_limit = response.parse() - assert_matches_type(RateLimit, rate_limit, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_create(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - with client.rate_limits.with_streaming_response.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - action={}, - match={}, - period=900, - threshold=60, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - rate_limit = response.parse() - assert_matches_type(RateLimit, rate_limit, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_create(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.rate_limits.with_raw_response.create( - zone_id="", - action={}, - match={}, - period=900, - threshold=60, - ) - - @parametrize - def test_method_list(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - rate_limit = client.rate_limits.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert_matches_type(SyncV4PagePaginationArray[RateLimit], rate_limit, path=["response"]) - - @parametrize - def test_method_list_with_all_params(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - rate_limit = client.rate_limits.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - page=1, - per_page=1, - ) - - assert_matches_type(SyncV4PagePaginationArray[RateLimit], rate_limit, path=["response"]) - - @parametrize - def test_raw_response_list(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - response = client.rate_limits.with_raw_response.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rate_limit = response.parse() - assert_matches_type(SyncV4PagePaginationArray[RateLimit], rate_limit, path=["response"]) - - @parametrize - def test_streaming_response_list(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - with client.rate_limits.with_streaming_response.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - rate_limit = response.parse() - assert_matches_type(SyncV4PagePaginationArray[RateLimit], rate_limit, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_list(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.rate_limits.with_raw_response.list( - zone_id="", - ) - - @parametrize - def test_method_delete(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - rate_limit = client.rate_limits.delete( - rate_limit_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert_matches_type(RateLimitDeleteResponse, rate_limit, path=["response"]) - - @parametrize - def test_raw_response_delete(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - response = client.rate_limits.with_raw_response.delete( - rate_limit_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rate_limit = response.parse() - assert_matches_type(RateLimitDeleteResponse, rate_limit, path=["response"]) - - @parametrize - def test_streaming_response_delete(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - with client.rate_limits.with_streaming_response.delete( - rate_limit_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - rate_limit = response.parse() - assert_matches_type(RateLimitDeleteResponse, rate_limit, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_delete(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.rate_limits.with_raw_response.delete( - rate_limit_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `rate_limit_id` but received ''"): - client.rate_limits.with_raw_response.delete( - rate_limit_id="", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_edit(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - rate_limit = client.rate_limits.edit( - rate_limit_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - action={}, - match={}, - period=900, - threshold=60, - ) - - assert_matches_type(RateLimit, rate_limit, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_method_edit_with_all_params(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - rate_limit = client.rate_limits.edit( - rate_limit_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - action={ - "mode": "simulate", - "response": { - "body": "This request has been rate-limited.", - "content_type": "text/xml", - }, - "timeout": 86400, - }, - match={ - "headers": [ - { - "name": "Cf-Cache-Status", - "op": "eq", - "value": "HIT", - }, - { - "name": "Cf-Cache-Status", - "op": "eq", - "value": "HIT", - }, - { - "name": "Cf-Cache-Status", - "op": "eq", - "value": "HIT", - }, - ], - "request": { - "methods": ["GET", "POST"], - "schemes": ["HTTP", "HTTPS"], - "url": "*.example.org/path*", - }, - "response": {"origin_traffic": True}, - }, - period=900, - threshold=60, - ) - - assert_matches_type(RateLimit, rate_limit, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_raw_response_edit(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - response = client.rate_limits.with_raw_response.edit( - rate_limit_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - action={}, - match={}, - period=900, - threshold=60, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rate_limit = response.parse() - assert_matches_type(RateLimit, rate_limit, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_streaming_response_edit(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - with client.rate_limits.with_streaming_response.edit( - rate_limit_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - action={}, - match={}, - period=900, - threshold=60, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - rate_limit = response.parse() - assert_matches_type(RateLimit, rate_limit, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - def test_path_params_edit(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.rate_limits.with_raw_response.edit( - rate_limit_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="", - action={}, - match={}, - period=900, - threshold=60, - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `rate_limit_id` but received ''"): - client.rate_limits.with_raw_response.edit( - rate_limit_id="", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - action={}, - match={}, - period=900, - threshold=60, - ) - - @parametrize - def test_method_get(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - rate_limit = client.rate_limits.get( - rate_limit_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert_matches_type(RateLimit, rate_limit, path=["response"]) - - @parametrize - def test_raw_response_get(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - response = client.rate_limits.with_raw_response.get( - rate_limit_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rate_limit = response.parse() - assert_matches_type(RateLimit, rate_limit, path=["response"]) - - @parametrize - def test_streaming_response_get(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - with client.rate_limits.with_streaming_response.get( - rate_limit_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - rate_limit = response.parse() - assert_matches_type(RateLimit, rate_limit, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_get(self, client: Cloudflare) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.rate_limits.with_raw_response.get( - rate_limit_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `rate_limit_id` but received ''"): - client.rate_limits.with_raw_response.get( - rate_limit_id="", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - -class TestAsyncRateLimits: - parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - rate_limit = await async_client.rate_limits.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - action={}, - match={}, - period=900, - threshold=60, - ) - - assert_matches_type(RateLimit, rate_limit, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - rate_limit = await async_client.rate_limits.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - action={ - "mode": "simulate", - "response": { - "body": "This request has been rate-limited.", - "content_type": "text/xml", - }, - "timeout": 86400, - }, - match={ - "headers": [ - { - "name": "Cf-Cache-Status", - "op": "eq", - "value": "HIT", - }, - { - "name": "Cf-Cache-Status", - "op": "eq", - "value": "HIT", - }, - { - "name": "Cf-Cache-Status", - "op": "eq", - "value": "HIT", - }, - ], - "request": { - "methods": ["GET", "POST"], - "schemes": ["HTTP", "HTTPS"], - "url": "*.example.org/path*", - }, - "response": {"origin_traffic": True}, - }, - period=900, - threshold=60, - ) - - assert_matches_type(RateLimit, rate_limit, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.rate_limits.with_raw_response.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - action={}, - match={}, - period=900, - threshold=60, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rate_limit = await response.parse() - assert_matches_type(RateLimit, rate_limit, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.rate_limits.with_streaming_response.create( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - action={}, - match={}, - period=900, - threshold=60, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - rate_limit = await response.parse() - assert_matches_type(RateLimit, rate_limit, 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(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.rate_limits.with_raw_response.create( - zone_id="", - action={}, - match={}, - period=900, - threshold=60, - ) - - @parametrize - async def test_method_list(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - rate_limit = await async_client.rate_limits.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert_matches_type(AsyncV4PagePaginationArray[RateLimit], rate_limit, path=["response"]) - - @parametrize - async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - rate_limit = await async_client.rate_limits.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - page=1, - per_page=1, - ) - - assert_matches_type(AsyncV4PagePaginationArray[RateLimit], rate_limit, path=["response"]) - - @parametrize - async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.rate_limits.with_raw_response.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rate_limit = await response.parse() - assert_matches_type(AsyncV4PagePaginationArray[RateLimit], rate_limit, path=["response"]) - - @parametrize - async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.rate_limits.with_streaming_response.list( - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - rate_limit = await response.parse() - assert_matches_type(AsyncV4PagePaginationArray[RateLimit], rate_limit, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.rate_limits.with_raw_response.list( - zone_id="", - ) - - @parametrize - async def test_method_delete(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - rate_limit = await async_client.rate_limits.delete( - rate_limit_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert_matches_type(RateLimitDeleteResponse, rate_limit, path=["response"]) - - @parametrize - async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.rate_limits.with_raw_response.delete( - rate_limit_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rate_limit = await response.parse() - assert_matches_type(RateLimitDeleteResponse, rate_limit, path=["response"]) - - @parametrize - async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.rate_limits.with_streaming_response.delete( - rate_limit_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - rate_limit = await response.parse() - assert_matches_type(RateLimitDeleteResponse, rate_limit, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.rate_limits.with_raw_response.delete( - rate_limit_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `rate_limit_id` but received ''"): - await async_client.rate_limits.with_raw_response.delete( - rate_limit_id="", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_edit(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - rate_limit = await async_client.rate_limits.edit( - rate_limit_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - action={}, - match={}, - period=900, - threshold=60, - ) - - assert_matches_type(RateLimit, rate_limit, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - rate_limit = await async_client.rate_limits.edit( - rate_limit_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - action={ - "mode": "simulate", - "response": { - "body": "This request has been rate-limited.", - "content_type": "text/xml", - }, - "timeout": 86400, - }, - match={ - "headers": [ - { - "name": "Cf-Cache-Status", - "op": "eq", - "value": "HIT", - }, - { - "name": "Cf-Cache-Status", - "op": "eq", - "value": "HIT", - }, - { - "name": "Cf-Cache-Status", - "op": "eq", - "value": "HIT", - }, - ], - "request": { - "methods": ["GET", "POST"], - "schemes": ["HTTP", "HTTPS"], - "url": "*.example.org/path*", - }, - "response": {"origin_traffic": True}, - }, - period=900, - threshold=60, - ) - - assert_matches_type(RateLimit, rate_limit, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.rate_limits.with_raw_response.edit( - rate_limit_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - action={}, - match={}, - period=900, - threshold=60, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rate_limit = await response.parse() - assert_matches_type(RateLimit, rate_limit, path=["response"]) - - @pytest.mark.skip(reason="TODO: investigate broken test") - @parametrize - async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.rate_limits.with_streaming_response.edit( - rate_limit_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - action={}, - match={}, - period=900, - threshold=60, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - rate_limit = await response.parse() - assert_matches_type(RateLimit, rate_limit, 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(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.rate_limits.with_raw_response.edit( - rate_limit_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="", - action={}, - match={}, - period=900, - threshold=60, - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `rate_limit_id` but received ''"): - await async_client.rate_limits.with_raw_response.edit( - rate_limit_id="", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - action={}, - match={}, - period=900, - threshold=60, - ) - - @parametrize - async def test_method_get(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - rate_limit = await async_client.rate_limits.get( - rate_limit_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert_matches_type(RateLimit, rate_limit, path=["response"]) - - @parametrize - async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - response = await async_client.rate_limits.with_raw_response.get( - rate_limit_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rate_limit = await response.parse() - assert_matches_type(RateLimit, rate_limit, path=["response"]) - - @parametrize - async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - async with async_client.rate_limits.with_streaming_response.get( - rate_limit_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - rate_limit = await response.parse() - assert_matches_type(RateLimit, rate_limit, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: - with pytest.warns(DeprecationWarning): - with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.rate_limits.with_raw_response.get( - rate_limit_id="372e67954025e0ba6aaa6d586b9e0b59", - zone_id="", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `rate_limit_id` but received ''"): - await async_client.rate_limits.with_raw_response.get( - rate_limit_id="", - zone_id="023e105f4ecef8ad9ca31a8372d0c353", - )