diff --git a/api.md b/api.md index da2eed346f5..ec5c8558fd2 100644 --- a/api.md +++ b/api.md @@ -17,6 +17,7 @@ from cloudflare.types import ( ResponseInfo, Result, Role, + SortDirection, ) ``` @@ -278,7 +279,7 @@ Methods: Types: ```python -from cloudflare.types.zones import Zone, ZoneDeleteResponse +from cloudflare.types.zones import Type, Zone, ZoneDeleteResponse ``` Methods: @@ -1159,7 +1160,7 @@ Methods: Types: ```python -from cloudflare.types.load_balancers import RegionListResponse, RegionGetResponse +from cloudflare.types.load_balancers import RegionID, RegionListResponse, RegionGetResponse ``` Methods: @@ -1199,6 +1200,7 @@ Types: from cloudflare.types.cache import ( CacheReserve, CacheReserveClear, + State, CacheReserveClearResponse, CacheReserveEditResponse, CacheReserveGetResponse, @@ -3021,6 +3023,8 @@ Types: ```python from cloudflare.types.rulesets import ( + Kind, + Phase, Ruleset, RulesetCreateResponse, RulesetUpdateResponse, diff --git a/src/cloudflare/resources/dns/records.py b/src/cloudflare/resources/dns/records.py index ca50b06af90..a3fc72a9354 100644 --- a/src/cloudflare/resources/dns/records.py +++ b/src/cloudflare/resources/dns/records.py @@ -38,6 +38,7 @@ from ...types.dns.record import Record from ...types.dns.ttl_param import TTLParam from ...types.dns.record_tags import RecordTags +from ...types.shared.sort_direction import SortDirection from ...types.dns.record_scan_response import RecordScanResponse from ...types.dns.record_delete_response import RecordDeleteResponse from ...types.dns.record_import_response import RecordImportResponse @@ -2597,7 +2598,7 @@ def list( zone_id: str, comment: record_list_params.Comment | NotGiven = NOT_GIVEN, content: str | NotGiven = NOT_GIVEN, - direction: Literal["asc", "desc"] | NotGiven = NOT_GIVEN, + direction: SortDirection | NotGiven = NOT_GIVEN, match: Literal["any", "all"] | NotGiven = NOT_GIVEN, name: str | NotGiven = NOT_GIVEN, order: Literal["type", "name", "content", "ttl", "proxied"] | NotGiven = NOT_GIVEN, @@ -6801,7 +6802,7 @@ def list( zone_id: str, comment: record_list_params.Comment | NotGiven = NOT_GIVEN, content: str | NotGiven = NOT_GIVEN, - direction: Literal["asc", "desc"] | NotGiven = NOT_GIVEN, + direction: SortDirection | NotGiven = NOT_GIVEN, match: Literal["any", "all"] | NotGiven = NOT_GIVEN, name: str | NotGiven = NOT_GIVEN, order: Literal["type", "name", "content", "ttl", "proxied"] | NotGiven = NOT_GIVEN, diff --git a/src/cloudflare/resources/load_balancers/pools/pools.py b/src/cloudflare/resources/load_balancers/pools/pools.py index 1652a3bed56..61c33e710d1 100644 --- a/src/cloudflare/resources/load_balancers/pools/pools.py +++ b/src/cloudflare/resources/load_balancers/pools/pools.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Iterable, Optional, cast +from typing import Type, Iterable, Optional, cast import httpx @@ -48,8 +48,8 @@ pool_update_params, ) from ....types.load_balancers.pool import Pool -from ....types.load_balancers.check_region import CheckRegion from ....types.load_balancers.origin_param import OriginParam +from ....types.load_balancers.region_id_param import RegionIDParam from ....types.load_balancers.load_shedding_param import LoadSheddingParam from ....types.load_balancers.pool_delete_response import PoolDeleteResponse from ....types.load_balancers.origin_steering_param import OriginSteeringParam @@ -189,7 +189,7 @@ def update( account_id: str, name: str, origins: Iterable[OriginParam], - check_regions: Optional[List[CheckRegion]] | NotGiven = NOT_GIVEN, + check_regions: Optional[RegionIDParam] | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, enabled: bool | NotGiven = NOT_GIVEN, latitude: float | NotGiven = NOT_GIVEN, @@ -388,7 +388,7 @@ def edit( pool_id: str, *, account_id: str, - check_regions: Optional[List[CheckRegion]] | NotGiven = NOT_GIVEN, + check_regions: Optional[RegionIDParam] | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, enabled: bool | NotGiven = NOT_GIVEN, latitude: float | NotGiven = NOT_GIVEN, @@ -672,7 +672,7 @@ async def update( account_id: str, name: str, origins: Iterable[OriginParam], - check_regions: Optional[List[CheckRegion]] | NotGiven = NOT_GIVEN, + check_regions: Optional[RegionIDParam] | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, enabled: bool | NotGiven = NOT_GIVEN, latitude: float | NotGiven = NOT_GIVEN, @@ -871,7 +871,7 @@ async def edit( pool_id: str, *, account_id: str, - check_regions: Optional[List[CheckRegion]] | NotGiven = NOT_GIVEN, + check_regions: Optional[RegionIDParam] | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, enabled: bool | NotGiven = NOT_GIVEN, latitude: float | NotGiven = NOT_GIVEN, diff --git a/src/cloudflare/resources/rulesets/phases/phases.py b/src/cloudflare/resources/rulesets/phases/phases.py index 05b1b1c7e49..5cb0317d0fa 100644 --- a/src/cloudflare/resources/rulesets/phases/phases.py +++ b/src/cloudflare/resources/rulesets/phases/phases.py @@ -3,7 +3,6 @@ from __future__ import annotations from typing import Type, Iterable, cast -from typing_extensions import Literal import httpx @@ -32,7 +31,9 @@ from ...._base_client import ( make_request_options, ) -from ....types.rulesets import phase_update_params +from ....types.rulesets import Kind, Phase, phase_update_params +from ....types.rulesets.kind import Kind +from ....types.rulesets.phase import Phase from ....types.rulesets.phase_get_response import PhaseGetResponse from ....types.rulesets.phase_update_response import PhaseUpdateResponse @@ -54,64 +55,15 @@ def with_streaming_response(self) -> PhasesResourceWithStreamingResponse: def update( self, - ruleset_phase: Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ], + ruleset_phase: Phase, *, rules: Iterable[phase_update_params.Rule], account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, - kind: Literal["managed", "custom", "root", "zone"] | NotGiven = NOT_GIVEN, + kind: Kind | NotGiven = NOT_GIVEN, name: str | NotGiven = NOT_GIVEN, - phase: Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ] - | NotGiven = NOT_GIVEN, + phase: Phase | 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, @@ -185,31 +137,7 @@ def update( def get( self, - ruleset_phase: Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ], + ruleset_phase: Phase, *, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, @@ -281,64 +209,15 @@ def with_streaming_response(self) -> AsyncPhasesResourceWithStreamingResponse: async def update( self, - ruleset_phase: Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ], + ruleset_phase: Phase, *, rules: Iterable[phase_update_params.Rule], account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, - kind: Literal["managed", "custom", "root", "zone"] | NotGiven = NOT_GIVEN, + kind: Kind | NotGiven = NOT_GIVEN, name: str | NotGiven = NOT_GIVEN, - phase: Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ] - | NotGiven = NOT_GIVEN, + phase: Phase | 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, @@ -412,31 +291,7 @@ async def update( async def get( self, - ruleset_phase: Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ], + ruleset_phase: Phase, *, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, diff --git a/src/cloudflare/resources/rulesets/phases/versions.py b/src/cloudflare/resources/rulesets/phases/versions.py index 96e68eee754..60967a5872f 100644 --- a/src/cloudflare/resources/rulesets/phases/versions.py +++ b/src/cloudflare/resources/rulesets/phases/versions.py @@ -3,7 +3,6 @@ from __future__ import annotations from typing import Type, cast -from typing_extensions import Literal import httpx @@ -22,6 +21,8 @@ AsyncPaginator, make_request_options, ) +from ....types.rulesets import Phase +from ....types.rulesets.phase import Phase from ....types.rulesets.ruleset import Ruleset from ....types.rulesets.phases.version_get_response import VersionGetResponse @@ -39,31 +40,7 @@ def with_streaming_response(self) -> VersionsResourceWithStreamingResponse: def list( self, - ruleset_phase: Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ], + ruleset_phase: Phase, *, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, @@ -119,31 +96,7 @@ def get( self, ruleset_version: str, *, - ruleset_phase: Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ], + ruleset_phase: Phase, 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. @@ -213,31 +166,7 @@ def with_streaming_response(self) -> AsyncVersionsResourceWithStreamingResponse: def list( self, - ruleset_phase: Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ], + ruleset_phase: Phase, *, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, @@ -293,31 +222,7 @@ async def get( self, ruleset_version: str, *, - ruleset_phase: Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ], + ruleset_phase: Phase, 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. diff --git a/src/cloudflare/resources/rulesets/rulesets.py b/src/cloudflare/resources/rulesets/rulesets.py index 5c040db3ff0..f28542d39f5 100644 --- a/src/cloudflare/resources/rulesets/rulesets.py +++ b/src/cloudflare/resources/rulesets/rulesets.py @@ -3,7 +3,6 @@ from __future__ import annotations from typing import Type, Iterable, cast -from typing_extensions import Literal import httpx @@ -51,8 +50,10 @@ AsyncPaginator, make_request_options, ) -from ...types.rulesets import ruleset_create_params, ruleset_update_params +from ...types.rulesets import Kind, Phase, ruleset_create_params, ruleset_update_params from .versions.versions import VersionsResource, AsyncVersionsResource +from ...types.rulesets.kind import Kind +from ...types.rulesets.phase import Phase from ...types.rulesets.ruleset import Ruleset from ...types.rulesets.ruleset_get_response import RulesetGetResponse from ...types.rulesets.ruleset_create_response import RulesetCreateResponse @@ -85,33 +86,9 @@ def with_streaming_response(self) -> RulesetsResourceWithStreamingResponse: def create( self, *, - kind: Literal["managed", "custom", "root", "zone"], + kind: Kind, name: str, - phase: Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ], + phase: Phase, rules: Iterable[ruleset_create_params.Rule], account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, @@ -191,34 +168,9 @@ def update( account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, - kind: Literal["managed", "custom", "root", "zone"] | NotGiven = NOT_GIVEN, + kind: Kind | NotGiven = NOT_GIVEN, name: str | NotGiven = NOT_GIVEN, - phase: Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ] - | NotGiven = NOT_GIVEN, + phase: Phase | 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, @@ -475,33 +427,9 @@ def with_streaming_response(self) -> AsyncRulesetsResourceWithStreamingResponse: async def create( self, *, - kind: Literal["managed", "custom", "root", "zone"], + kind: Kind, name: str, - phase: Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ], + phase: Phase, rules: Iterable[ruleset_create_params.Rule], account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, @@ -581,34 +509,9 @@ async def update( account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, - kind: Literal["managed", "custom", "root", "zone"] | NotGiven = NOT_GIVEN, + kind: Kind | NotGiven = NOT_GIVEN, name: str | NotGiven = NOT_GIVEN, - phase: Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ] - | NotGiven = NOT_GIVEN, + phase: Phase | 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, diff --git a/src/cloudflare/resources/zones/zones.py b/src/cloudflare/resources/zones/zones.py index 2f44b6f7014..6256a5db72a 100644 --- a/src/cloudflare/resources/zones/zones.py +++ b/src/cloudflare/resources/zones/zones.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import List, Type, Optional, cast +from typing import List, Type as TypingType, Optional, cast from typing_extensions import Literal import httpx @@ -68,6 +68,7 @@ AsyncActivationCheckResourceWithStreamingResponse, ) from .settings.settings import SettingsResource, AsyncSettingsResource +from ...types.zones.type import Type as ZonesType from ...types.zones.zone import Zone from .custom_nameservers import ( CustomNameserversResource, @@ -120,7 +121,7 @@ def create( *, account: zone_create_params.Account, name: str, - type: Literal["full", "partial", "secondary"] | NotGiven = NOT_GIVEN, + type: ZonesType | 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, @@ -162,7 +163,7 @@ def create( timeout=timeout, post_parser=ResultWrapper[Optional[Zone]]._unwrapper, ), - cast_to=cast(Type[Optional[Zone]], ResultWrapper[Zone]), + cast_to=cast(TypingType[Optional[Zone]], ResultWrapper[Zone]), ) def list( @@ -280,7 +281,7 @@ def delete( timeout=timeout, post_parser=ResultWrapper[Optional[ZoneDeleteResponse]]._unwrapper, ), - cast_to=cast(Type[Optional[ZoneDeleteResponse]], ResultWrapper[ZoneDeleteResponse]), + cast_to=cast(TypingType[Optional[ZoneDeleteResponse]], ResultWrapper[ZoneDeleteResponse]), ) def edit( @@ -343,7 +344,7 @@ def edit( timeout=timeout, post_parser=ResultWrapper[Optional[Zone]]._unwrapper, ), - cast_to=cast(Type[Optional[Zone]], ResultWrapper[Zone]), + cast_to=cast(TypingType[Optional[Zone]], ResultWrapper[Zone]), ) def get( @@ -382,7 +383,7 @@ def get( timeout=timeout, post_parser=ResultWrapper[Optional[Zone]]._unwrapper, ), - cast_to=cast(Type[Optional[Zone]], ResultWrapper[Zone]), + cast_to=cast(TypingType[Optional[Zone]], ResultWrapper[Zone]), ) @@ -424,7 +425,7 @@ async def create( *, account: zone_create_params.Account, name: str, - type: Literal["full", "partial", "secondary"] | NotGiven = NOT_GIVEN, + type: ZonesType | 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, @@ -466,7 +467,7 @@ async def create( timeout=timeout, post_parser=ResultWrapper[Optional[Zone]]._unwrapper, ), - cast_to=cast(Type[Optional[Zone]], ResultWrapper[Zone]), + cast_to=cast(TypingType[Optional[Zone]], ResultWrapper[Zone]), ) def list( @@ -584,7 +585,7 @@ async def delete( timeout=timeout, post_parser=ResultWrapper[Optional[ZoneDeleteResponse]]._unwrapper, ), - cast_to=cast(Type[Optional[ZoneDeleteResponse]], ResultWrapper[ZoneDeleteResponse]), + cast_to=cast(TypingType[Optional[ZoneDeleteResponse]], ResultWrapper[ZoneDeleteResponse]), ) async def edit( @@ -647,7 +648,7 @@ async def edit( timeout=timeout, post_parser=ResultWrapper[Optional[Zone]]._unwrapper, ), - cast_to=cast(Type[Optional[Zone]], ResultWrapper[Zone]), + cast_to=cast(TypingType[Optional[Zone]], ResultWrapper[Zone]), ) async def get( @@ -686,7 +687,7 @@ async def get( timeout=timeout, post_parser=ResultWrapper[Optional[Zone]]._unwrapper, ), - cast_to=cast(Type[Optional[Zone]], ResultWrapper[Zone]), + cast_to=cast(TypingType[Optional[Zone]], ResultWrapper[Zone]), ) diff --git a/src/cloudflare/types/__init__.py b/src/cloudflare/types/__init__.py index 99ea53c6e3d..d99e0567acf 100644 --- a/src/cloudflare/types/__init__.py +++ b/src/cloudflare/types/__init__.py @@ -13,6 +13,7 @@ Permission as Permission, ResponseInfo as ResponseInfo, CertificateCA as CertificateCA, + SortDirection as SortDirection, PaginationInfo as PaginationInfo, PermissionGrant as PermissionGrant, CloudflareTunnel as CloudflareTunnel, diff --git a/src/cloudflare/types/cache/__init__.py b/src/cloudflare/types/cache/__init__.py index d31d3fae042..520b990501d 100644 --- a/src/cloudflare/types/cache/__init__.py +++ b/src/cloudflare/types/cache/__init__.py @@ -2,6 +2,7 @@ from __future__ import annotations +from .state import State as State from .cache_reserve import CacheReserve as CacheReserve from .cache_variant import CacheVariant as CacheVariant from .cache_purge_params import CachePurgeParams as CachePurgeParams diff --git a/src/cloudflare/types/cache/cache_reserve_clear_response.py b/src/cloudflare/types/cache/cache_reserve_clear_response.py index b65b18ed8c3..6ef83d88029 100644 --- a/src/cloudflare/types/cache/cache_reserve_clear_response.py +++ b/src/cloudflare/types/cache/cache_reserve_clear_response.py @@ -2,8 +2,8 @@ from typing import Optional from datetime import datetime -from typing_extensions import Literal +from .state import State from ..._models import BaseModel from .cache_reserve_clear import CacheReserveClear @@ -20,7 +20,7 @@ class CacheReserveClearResponse(BaseModel): start_ts: datetime """The time that the latest Cache Reserve Clear operation started.""" - state: Literal["In-progress", "Completed"] + state: State """The current state of the Cache Reserve Clear operation.""" end_ts: Optional[datetime] = None diff --git a/src/cloudflare/types/cache/cache_reserve_status_response.py b/src/cloudflare/types/cache/cache_reserve_status_response.py index 46d79cbf06b..abc1c4cba82 100644 --- a/src/cloudflare/types/cache/cache_reserve_status_response.py +++ b/src/cloudflare/types/cache/cache_reserve_status_response.py @@ -2,8 +2,8 @@ from typing import Optional from datetime import datetime -from typing_extensions import Literal +from .state import State from ..._models import BaseModel from .cache_reserve_clear import CacheReserveClear @@ -20,7 +20,7 @@ class CacheReserveStatusResponse(BaseModel): start_ts: datetime """The time that the latest Cache Reserve Clear operation started.""" - state: Literal["In-progress", "Completed"] + state: State """The current state of the Cache Reserve Clear operation.""" end_ts: Optional[datetime] = None diff --git a/src/cloudflare/types/cache/state.py b/src/cloudflare/types/cache/state.py new file mode 100644 index 00000000000..24320fdfa62 --- /dev/null +++ b/src/cloudflare/types/cache/state.py @@ -0,0 +1,7 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing_extensions import Literal + +__all__ = ["State"] + +State = Literal["In-progress", "Completed"] diff --git a/src/cloudflare/types/dns/record_list_params.py b/src/cloudflare/types/dns/record_list_params.py index d9fa8165d0c..1effd2f75e9 100644 --- a/src/cloudflare/types/dns/record_list_params.py +++ b/src/cloudflare/types/dns/record_list_params.py @@ -4,6 +4,8 @@ from typing_extensions import Literal, Required, TypedDict +from ..shared.sort_direction import SortDirection + __all__ = ["RecordListParams", "Comment", "Tag"] @@ -16,7 +18,7 @@ class RecordListParams(TypedDict, total=False): content: str """DNS record content.""" - direction: Literal["asc", "desc"] + direction: SortDirection """Direction to order DNS records in.""" match: Literal["any", "all"] diff --git a/src/cloudflare/types/load_balancers/__init__.py b/src/cloudflare/types/load_balancers/__init__.py index 46d78e92ec5..0dac8532e00 100644 --- a/src/cloudflare/types/load_balancers/__init__.py +++ b/src/cloudflare/types/load_balancers/__init__.py @@ -8,6 +8,7 @@ from .header import Header as Header from .origin import Origin as Origin from .monitor import Monitor as Monitor +from .region_id import RegionID as RegionID from .rules_param import RulesParam as RulesParam from .check_region import CheckRegion as CheckRegion from .header_param import HeaderParam as HeaderParam @@ -18,6 +19,7 @@ from .filter_options import FilterOptions as FilterOptions from .origin_steering import OriginSteering as OriginSteering from .random_steering import RandomSteering as RandomSteering +from .region_id_param import RegionIDParam as RegionIDParam from .steering_policy import SteeringPolicy as SteeringPolicy from .adaptive_routing import AdaptiveRouting as AdaptiveRouting from .pool_edit_params import PoolEditParams as PoolEditParams diff --git a/src/cloudflare/types/load_balancers/pool.py b/src/cloudflare/types/load_balancers/pool.py index beb27193b3d..2b5a549420b 100644 --- a/src/cloudflare/types/load_balancers/pool.py +++ b/src/cloudflare/types/load_balancers/pool.py @@ -5,7 +5,7 @@ from .origin import Origin from ..._models import BaseModel -from .check_region import CheckRegion +from .region_id import RegionID from .load_shedding import LoadShedding from .origin_steering import OriginSteering from .notification_filter import NotificationFilter @@ -16,7 +16,7 @@ class Pool(BaseModel): id: Optional[str] = None - check_regions: Optional[List[CheckRegion]] = None + check_regions: Optional[RegionID] = None """A list of regions from which to run health checks. Null means every Cloudflare data center. diff --git a/src/cloudflare/types/load_balancers/pool_edit_params.py b/src/cloudflare/types/load_balancers/pool_edit_params.py index 222e8ab9357..3a764923865 100644 --- a/src/cloudflare/types/load_balancers/pool_edit_params.py +++ b/src/cloudflare/types/load_balancers/pool_edit_params.py @@ -2,11 +2,11 @@ from __future__ import annotations -from typing import List, Iterable, Optional +from typing import Iterable, Optional from typing_extensions import Required, TypedDict -from .check_region import CheckRegion from .origin_param import OriginParam +from .region_id_param import RegionIDParam from .load_shedding_param import LoadSheddingParam from .origin_steering_param import OriginSteeringParam from .notification_filter_param import NotificationFilterParam @@ -18,7 +18,7 @@ class PoolEditParams(TypedDict, total=False): account_id: Required[str] """Identifier""" - check_regions: Optional[List[CheckRegion]] + check_regions: Optional[RegionIDParam] """A list of regions from which to run health checks. Null means every Cloudflare data center. diff --git a/src/cloudflare/types/load_balancers/pool_update_params.py b/src/cloudflare/types/load_balancers/pool_update_params.py index 834c3ec1b70..afbfd2a9af6 100644 --- a/src/cloudflare/types/load_balancers/pool_update_params.py +++ b/src/cloudflare/types/load_balancers/pool_update_params.py @@ -2,11 +2,11 @@ from __future__ import annotations -from typing import List, Iterable, Optional +from typing import Iterable, Optional from typing_extensions import Required, TypedDict -from .check_region import CheckRegion from .origin_param import OriginParam +from .region_id_param import RegionIDParam from .load_shedding_param import LoadSheddingParam from .origin_steering_param import OriginSteeringParam from .notification_filter_param import NotificationFilterParam @@ -31,7 +31,7 @@ class PoolUpdateParams(TypedDict, total=False): provided the pool itself is healthy. """ - check_regions: Optional[List[CheckRegion]] + check_regions: Optional[RegionIDParam] """A list of regions from which to run health checks. Null means every Cloudflare data center. diff --git a/src/cloudflare/types/load_balancers/region_id.py b/src/cloudflare/types/load_balancers/region_id.py new file mode 100644 index 00000000000..3b38543ab42 --- /dev/null +++ b/src/cloudflare/types/load_balancers/region_id.py @@ -0,0 +1,9 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List + +from .check_region import CheckRegion + +__all__ = ["RegionID"] + +RegionID = List[CheckRegion] diff --git a/src/cloudflare/types/load_balancers/region_id_param.py b/src/cloudflare/types/load_balancers/region_id_param.py new file mode 100644 index 00000000000..4dbec6ab70d --- /dev/null +++ b/src/cloudflare/types/load_balancers/region_id_param.py @@ -0,0 +1,14 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List +from typing_extensions import Literal + +__all__ = ["CheckRegion"] + +CheckRegion = Literal[ + "WNAM", "ENAM", "WEU", "EEU", "NSAM", "SSAM", "OC", "ME", "NAF", "SAF", "SAS", "SEAS", "NEAS", "ALL_REGIONS" +] + +RegionIDParam = List[CheckRegion] diff --git a/src/cloudflare/types/rulesets/__init__.py b/src/cloudflare/types/rulesets/__init__.py index 5ba52a2ca8b..d5b6a67cb87 100644 --- a/src/cloudflare/types/rulesets/__init__.py +++ b/src/cloudflare/types/rulesets/__init__.py @@ -2,6 +2,8 @@ from __future__ import annotations +from .kind import Kind as Kind +from .phase import Phase as Phase from .logging import Logging as Logging from .ruleset import Ruleset as Ruleset from .log_rule import LogRule as LogRule diff --git a/src/cloudflare/types/rulesets/kind.py b/src/cloudflare/types/rulesets/kind.py new file mode 100644 index 00000000000..d738a069920 --- /dev/null +++ b/src/cloudflare/types/rulesets/kind.py @@ -0,0 +1,7 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing_extensions import Literal + +__all__ = ["Kind"] + +Kind = Literal["managed", "custom", "root", "zone"] diff --git a/src/cloudflare/types/rulesets/phase.py b/src/cloudflare/types/rulesets/phase.py new file mode 100644 index 00000000000..2c762c89ddb --- /dev/null +++ b/src/cloudflare/types/rulesets/phase.py @@ -0,0 +1,31 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing_extensions import Literal + +__all__ = ["Phase"] + +Phase = Literal[ + "ddos_l4", + "ddos_l7", + "http_config_settings", + "http_custom_errors", + "http_log_custom_fields", + "http_ratelimit", + "http_request_cache_settings", + "http_request_dynamic_redirect", + "http_request_firewall_custom", + "http_request_firewall_managed", + "http_request_late_transform", + "http_request_origin", + "http_request_redirect", + "http_request_sanitize", + "http_request_sbfm", + "http_request_select_configuration", + "http_request_transform", + "http_response_compression", + "http_response_firewall_managed", + "http_response_headers_transform", + "magic_transit", + "magic_transit_ids_managed", + "magic_transit_managed", +] diff --git a/src/cloudflare/types/rulesets/phase_get_response.py b/src/cloudflare/types/rulesets/phase_get_response.py index ba836f604ee..659dae75d71 100644 --- a/src/cloudflare/types/rulesets/phase_get_response.py +++ b/src/cloudflare/types/rulesets/phase_get_response.py @@ -2,8 +2,9 @@ from typing import List, Union, Optional from datetime import datetime -from typing_extensions import Literal +from .kind import Kind +from .phase import Phase from .log_rule import LogRule from ..._models import BaseModel from .skip_rule import SkipRule @@ -46,7 +47,7 @@ class PhaseGetResponse(BaseModel): id: str """The unique ID of the ruleset.""" - kind: Literal["managed", "custom", "root", "zone"] + kind: Kind """The kind of the ruleset.""" last_updated: datetime @@ -55,31 +56,7 @@ class PhaseGetResponse(BaseModel): name: str """The human-readable name of the ruleset.""" - phase: Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ] + phase: Phase """The phase of the ruleset.""" rules: List[Rule] diff --git a/src/cloudflare/types/rulesets/phase_update_params.py b/src/cloudflare/types/rulesets/phase_update_params.py index 234efabd899..fbee22cf279 100644 --- a/src/cloudflare/types/rulesets/phase_update_params.py +++ b/src/cloudflare/types/rulesets/phase_update_params.py @@ -3,8 +3,10 @@ from __future__ import annotations from typing import Union, Iterable -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Required, TypedDict +from .kind import Kind +from .phase import Phase from .log_rule_param import LogRuleParam from .skip_rule_param import SkipRuleParam from .block_rule_param import BlockRuleParam @@ -37,37 +39,13 @@ class PhaseUpdateParams(TypedDict, total=False): description: str """An informative description of the ruleset.""" - kind: Literal["managed", "custom", "root", "zone"] + kind: Kind """The kind of the ruleset.""" name: str """The human-readable name of the ruleset.""" - phase: Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ] + phase: Phase """The phase of the ruleset.""" diff --git a/src/cloudflare/types/rulesets/phase_update_response.py b/src/cloudflare/types/rulesets/phase_update_response.py index 41257fc0f35..8d5b1b28eac 100644 --- a/src/cloudflare/types/rulesets/phase_update_response.py +++ b/src/cloudflare/types/rulesets/phase_update_response.py @@ -2,8 +2,9 @@ from typing import List, Union, Optional from datetime import datetime -from typing_extensions import Literal +from .kind import Kind +from .phase import Phase from .log_rule import LogRule from ..._models import BaseModel from .skip_rule import SkipRule @@ -46,7 +47,7 @@ class PhaseUpdateResponse(BaseModel): id: str """The unique ID of the ruleset.""" - kind: Literal["managed", "custom", "root", "zone"] + kind: Kind """The kind of the ruleset.""" last_updated: datetime @@ -55,31 +56,7 @@ class PhaseUpdateResponse(BaseModel): name: str """The human-readable name of the ruleset.""" - phase: Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ] + phase: Phase """The phase of the ruleset.""" rules: List[Rule] diff --git a/src/cloudflare/types/rulesets/phases/version_get_response.py b/src/cloudflare/types/rulesets/phases/version_get_response.py index 3109c6c05f3..e4a7e29890b 100644 --- a/src/cloudflare/types/rulesets/phases/version_get_response.py +++ b/src/cloudflare/types/rulesets/phases/version_get_response.py @@ -2,8 +2,9 @@ from typing import List, Union, Optional from datetime import datetime -from typing_extensions import Literal +from ..kind import Kind +from ..phase import Phase from ..log_rule import LogRule from ...._models import BaseModel from ..skip_rule import SkipRule @@ -46,7 +47,7 @@ class VersionGetResponse(BaseModel): id: str """The unique ID of the ruleset.""" - kind: Literal["managed", "custom", "root", "zone"] + kind: Kind """The kind of the ruleset.""" last_updated: datetime @@ -55,31 +56,7 @@ class VersionGetResponse(BaseModel): name: str """The human-readable name of the ruleset.""" - phase: Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ] + phase: Phase """The phase of the ruleset.""" rules: List[Rule] diff --git a/src/cloudflare/types/rulesets/rule_create_params.py b/src/cloudflare/types/rulesets/rule_create_params.py index e4df9ee3c94..84c2f09d8b5 100644 --- a/src/cloudflare/types/rulesets/rule_create_params.py +++ b/src/cloudflare/types/rulesets/rule_create_params.py @@ -5,6 +5,7 @@ from typing import Dict, List, Union, Iterable from typing_extensions import Literal, Required, TypedDict +from .phase import Phase from .logging_param import LoggingParam from .rewrite_uri_part_param import RewriteURIPartParam @@ -810,33 +811,7 @@ class SkipRule(TypedDict, total=False): class SkipRuleActionParameters(TypedDict, total=False): - phases: List[ - Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ] - ] + phases: List[Phase] """A list of phases to skip the execution of. This option is incompatible with the ruleset and rulesets options. diff --git a/src/cloudflare/types/rulesets/rule_create_response.py b/src/cloudflare/types/rulesets/rule_create_response.py index 8e554d96ac9..7fdfe28ad63 100644 --- a/src/cloudflare/types/rulesets/rule_create_response.py +++ b/src/cloudflare/types/rulesets/rule_create_response.py @@ -2,8 +2,9 @@ from typing import List, Union, Optional from datetime import datetime -from typing_extensions import Literal +from .kind import Kind +from .phase import Phase from .log_rule import LogRule from ..._models import BaseModel from .skip_rule import SkipRule @@ -46,7 +47,7 @@ class RuleCreateResponse(BaseModel): id: str """The unique ID of the ruleset.""" - kind: Literal["managed", "custom", "root", "zone"] + kind: Kind """The kind of the ruleset.""" last_updated: datetime @@ -55,31 +56,7 @@ class RuleCreateResponse(BaseModel): name: str """The human-readable name of the ruleset.""" - phase: Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ] + phase: Phase """The phase of the ruleset.""" rules: List[Rule] diff --git a/src/cloudflare/types/rulesets/rule_delete_response.py b/src/cloudflare/types/rulesets/rule_delete_response.py index d729df47b53..a199b17fd00 100644 --- a/src/cloudflare/types/rulesets/rule_delete_response.py +++ b/src/cloudflare/types/rulesets/rule_delete_response.py @@ -2,8 +2,9 @@ from typing import List, Union, Optional from datetime import datetime -from typing_extensions import Literal +from .kind import Kind +from .phase import Phase from .log_rule import LogRule from ..._models import BaseModel from .skip_rule import SkipRule @@ -46,7 +47,7 @@ class RuleDeleteResponse(BaseModel): id: str """The unique ID of the ruleset.""" - kind: Literal["managed", "custom", "root", "zone"] + kind: Kind """The kind of the ruleset.""" last_updated: datetime @@ -55,31 +56,7 @@ class RuleDeleteResponse(BaseModel): name: str """The human-readable name of the ruleset.""" - phase: Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ] + phase: Phase """The phase of the ruleset.""" rules: List[Rule] diff --git a/src/cloudflare/types/rulesets/rule_edit_params.py b/src/cloudflare/types/rulesets/rule_edit_params.py index 32c27ccd157..63f8b2a0b50 100644 --- a/src/cloudflare/types/rulesets/rule_edit_params.py +++ b/src/cloudflare/types/rulesets/rule_edit_params.py @@ -5,6 +5,7 @@ from typing import Dict, List, Union, Iterable from typing_extensions import Literal, Required, TypedDict +from .phase import Phase from .logging_param import LoggingParam from .rewrite_uri_part_param import RewriteURIPartParam @@ -852,33 +853,7 @@ class SkipRule(TypedDict, total=False): class SkipRuleActionParameters(TypedDict, total=False): - phases: List[ - Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ] - ] + phases: List[Phase] """A list of phases to skip the execution of. This option is incompatible with the ruleset and rulesets options. diff --git a/src/cloudflare/types/rulesets/rule_edit_response.py b/src/cloudflare/types/rulesets/rule_edit_response.py index 9239500ea74..38c4717f2f6 100644 --- a/src/cloudflare/types/rulesets/rule_edit_response.py +++ b/src/cloudflare/types/rulesets/rule_edit_response.py @@ -2,8 +2,9 @@ from typing import List, Union, Optional from datetime import datetime -from typing_extensions import Literal +from .kind import Kind +from .phase import Phase from .log_rule import LogRule from ..._models import BaseModel from .skip_rule import SkipRule @@ -46,7 +47,7 @@ class RuleEditResponse(BaseModel): id: str """The unique ID of the ruleset.""" - kind: Literal["managed", "custom", "root", "zone"] + kind: Kind """The kind of the ruleset.""" last_updated: datetime @@ -55,31 +56,7 @@ class RuleEditResponse(BaseModel): name: str """The human-readable name of the ruleset.""" - phase: Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ] + phase: Phase """The phase of the ruleset.""" rules: List[Rule] diff --git a/src/cloudflare/types/rulesets/ruleset.py b/src/cloudflare/types/rulesets/ruleset.py index e5973e1c4fc..a570fcc344d 100644 --- a/src/cloudflare/types/rulesets/ruleset.py +++ b/src/cloudflare/types/rulesets/ruleset.py @@ -2,8 +2,9 @@ from typing import Optional from datetime import datetime -from typing_extensions import Literal +from .kind import Kind +from .phase import Phase from ..._models import BaseModel __all__ = ["Ruleset"] @@ -22,37 +23,11 @@ class Ruleset(BaseModel): description: Optional[str] = None """An informative description of the ruleset.""" - kind: Optional[Literal["managed", "custom", "root", "zone"]] = None + kind: Optional[Kind] = None """The kind of the ruleset.""" name: Optional[str] = None """The human-readable name of the ruleset.""" - phase: Optional[ - Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ] - ] = None + phase: Optional[Phase] = None """The phase of the ruleset.""" diff --git a/src/cloudflare/types/rulesets/ruleset_create_params.py b/src/cloudflare/types/rulesets/ruleset_create_params.py index dba6629645b..db2759e933f 100644 --- a/src/cloudflare/types/rulesets/ruleset_create_params.py +++ b/src/cloudflare/types/rulesets/ruleset_create_params.py @@ -3,8 +3,10 @@ from __future__ import annotations from typing import Union, Iterable -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Required, TypedDict +from .kind import Kind +from .phase import Phase from .log_rule_param import LogRuleParam from .skip_rule_param import SkipRuleParam from .block_rule_param import BlockRuleParam @@ -25,39 +27,13 @@ class RulesetCreateParams(TypedDict, total=False): - kind: Required[Literal["managed", "custom", "root", "zone"]] + kind: Required[Kind] """The kind of the ruleset.""" name: Required[str] """The human-readable name of the ruleset.""" - phase: Required[ - Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ] - ] + phase: Required[Phase] """The phase of the ruleset.""" rules: Required[Iterable[Rule]] diff --git a/src/cloudflare/types/rulesets/ruleset_create_response.py b/src/cloudflare/types/rulesets/ruleset_create_response.py index a4cbefe983c..c14817bae8e 100644 --- a/src/cloudflare/types/rulesets/ruleset_create_response.py +++ b/src/cloudflare/types/rulesets/ruleset_create_response.py @@ -2,8 +2,9 @@ from typing import List, Union, Optional from datetime import datetime -from typing_extensions import Literal +from .kind import Kind +from .phase import Phase from .log_rule import LogRule from ..._models import BaseModel from .skip_rule import SkipRule @@ -46,7 +47,7 @@ class RulesetCreateResponse(BaseModel): id: str """The unique ID of the ruleset.""" - kind: Literal["managed", "custom", "root", "zone"] + kind: Kind """The kind of the ruleset.""" last_updated: datetime @@ -55,31 +56,7 @@ class RulesetCreateResponse(BaseModel): name: str """The human-readable name of the ruleset.""" - phase: Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ] + phase: Phase """The phase of the ruleset.""" rules: List[Rule] diff --git a/src/cloudflare/types/rulesets/ruleset_get_response.py b/src/cloudflare/types/rulesets/ruleset_get_response.py index b4eeea24277..99506e58175 100644 --- a/src/cloudflare/types/rulesets/ruleset_get_response.py +++ b/src/cloudflare/types/rulesets/ruleset_get_response.py @@ -2,8 +2,9 @@ from typing import List, Union, Optional from datetime import datetime -from typing_extensions import Literal +from .kind import Kind +from .phase import Phase from .log_rule import LogRule from ..._models import BaseModel from .skip_rule import SkipRule @@ -46,7 +47,7 @@ class RulesetGetResponse(BaseModel): id: str """The unique ID of the ruleset.""" - kind: Literal["managed", "custom", "root", "zone"] + kind: Kind """The kind of the ruleset.""" last_updated: datetime @@ -55,31 +56,7 @@ class RulesetGetResponse(BaseModel): name: str """The human-readable name of the ruleset.""" - phase: Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ] + phase: Phase """The phase of the ruleset.""" rules: List[Rule] diff --git a/src/cloudflare/types/rulesets/ruleset_update_params.py b/src/cloudflare/types/rulesets/ruleset_update_params.py index 328c7fbed0a..4e3b08a7640 100644 --- a/src/cloudflare/types/rulesets/ruleset_update_params.py +++ b/src/cloudflare/types/rulesets/ruleset_update_params.py @@ -3,8 +3,10 @@ from __future__ import annotations from typing import Union, Iterable -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Required, TypedDict +from .kind import Kind +from .phase import Phase from .log_rule_param import LogRuleParam from .skip_rule_param import SkipRuleParam from .block_rule_param import BlockRuleParam @@ -37,37 +39,13 @@ class RulesetUpdateParams(TypedDict, total=False): description: str """An informative description of the ruleset.""" - kind: Literal["managed", "custom", "root", "zone"] + kind: Kind """The kind of the ruleset.""" name: str """The human-readable name of the ruleset.""" - phase: Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ] + phase: Phase """The phase of the ruleset.""" diff --git a/src/cloudflare/types/rulesets/ruleset_update_response.py b/src/cloudflare/types/rulesets/ruleset_update_response.py index 7ed717a100d..6cc2c3f102c 100644 --- a/src/cloudflare/types/rulesets/ruleset_update_response.py +++ b/src/cloudflare/types/rulesets/ruleset_update_response.py @@ -2,8 +2,9 @@ from typing import List, Union, Optional from datetime import datetime -from typing_extensions import Literal +from .kind import Kind +from .phase import Phase from .log_rule import LogRule from ..._models import BaseModel from .skip_rule import SkipRule @@ -46,7 +47,7 @@ class RulesetUpdateResponse(BaseModel): id: str """The unique ID of the ruleset.""" - kind: Literal["managed", "custom", "root", "zone"] + kind: Kind """The kind of the ruleset.""" last_updated: datetime @@ -55,31 +56,7 @@ class RulesetUpdateResponse(BaseModel): name: str """The human-readable name of the ruleset.""" - phase: Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ] + phase: Phase """The phase of the ruleset.""" rules: List[Rule] diff --git a/src/cloudflare/types/rulesets/skip_rule.py b/src/cloudflare/types/rulesets/skip_rule.py index ae51803c15b..6b01bf8efb3 100644 --- a/src/cloudflare/types/rulesets/skip_rule.py +++ b/src/cloudflare/types/rulesets/skip_rule.py @@ -4,6 +4,7 @@ from datetime import datetime from typing_extensions import Literal +from .phase import Phase from .logging import Logging from ..._models import BaseModel @@ -11,35 +12,7 @@ class ActionParameters(BaseModel): - phases: Optional[ - List[ - Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ] - ] - ] = None + phases: Optional[List[Phase]] = None """A list of phases to skip the execution of. This option is incompatible with the ruleset and rulesets options. diff --git a/src/cloudflare/types/rulesets/skip_rule_param.py b/src/cloudflare/types/rulesets/skip_rule_param.py index 27b20ebba30..abf557ff94a 100644 --- a/src/cloudflare/types/rulesets/skip_rule_param.py +++ b/src/cloudflare/types/rulesets/skip_rule_param.py @@ -5,39 +5,14 @@ from typing import Dict, List from typing_extensions import Literal, TypedDict +from .phase import Phase from .logging_param import LoggingParam __all__ = ["SkipRuleParam", "ActionParameters"] class ActionParameters(TypedDict, total=False): - phases: List[ - Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ] - ] + phases: List[Phase] """A list of phases to skip the execution of. This option is incompatible with the ruleset and rulesets options. diff --git a/src/cloudflare/types/rulesets/version_get_response.py b/src/cloudflare/types/rulesets/version_get_response.py index 63d43d6a422..cb03724ddeb 100644 --- a/src/cloudflare/types/rulesets/version_get_response.py +++ b/src/cloudflare/types/rulesets/version_get_response.py @@ -2,8 +2,9 @@ from typing import List, Union, Optional from datetime import datetime -from typing_extensions import Literal +from .kind import Kind +from .phase import Phase from .log_rule import LogRule from ..._models import BaseModel from .skip_rule import SkipRule @@ -46,7 +47,7 @@ class VersionGetResponse(BaseModel): id: str """The unique ID of the ruleset.""" - kind: Literal["managed", "custom", "root", "zone"] + kind: Kind """The kind of the ruleset.""" last_updated: datetime @@ -55,31 +56,7 @@ class VersionGetResponse(BaseModel): name: str """The human-readable name of the ruleset.""" - phase: Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ] + phase: Phase """The phase of the ruleset.""" rules: List[Rule] diff --git a/src/cloudflare/types/rulesets/versions/by_tag_get_response.py b/src/cloudflare/types/rulesets/versions/by_tag_get_response.py index b5b714a8119..f1aa698a4af 100644 --- a/src/cloudflare/types/rulesets/versions/by_tag_get_response.py +++ b/src/cloudflare/types/rulesets/versions/by_tag_get_response.py @@ -2,8 +2,9 @@ from typing import List, Union, Optional from datetime import datetime -from typing_extensions import Literal +from ..kind import Kind +from ..phase import Phase from ..log_rule import LogRule from ...._models import BaseModel from ..skip_rule import SkipRule @@ -46,7 +47,7 @@ class ByTagGetResponse(BaseModel): id: str """The unique ID of the ruleset.""" - kind: Literal["managed", "custom", "root", "zone"] + kind: Kind """The kind of the ruleset.""" last_updated: datetime @@ -55,31 +56,7 @@ class ByTagGetResponse(BaseModel): name: str """The human-readable name of the ruleset.""" - phase: Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ] + phase: Phase """The phase of the ruleset.""" rules: List[Rule] diff --git a/src/cloudflare/types/shared/__init__.py b/src/cloudflare/types/shared/__init__.py index 9bafe8cf7b3..51d5d9d5f14 100644 --- a/src/cloudflare/types/shared/__init__.py +++ b/src/cloudflare/types/shared/__init__.py @@ -10,6 +10,7 @@ from .permission import Permission as Permission from .response_info import ResponseInfo as ResponseInfo from .certificate_ca import CertificateCA as CertificateCA +from .sort_direction import SortDirection as SortDirection from .pagination_info import PaginationInfo as PaginationInfo from .permission_grant import PermissionGrant as PermissionGrant from .cloudflare_tunnel import CloudflareTunnel as CloudflareTunnel diff --git a/src/cloudflare/types/shared/sort_direction.py b/src/cloudflare/types/shared/sort_direction.py new file mode 100644 index 00000000000..abc1f5dd8e0 --- /dev/null +++ b/src/cloudflare/types/shared/sort_direction.py @@ -0,0 +1,7 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing_extensions import Literal + +__all__ = ["SortDirection"] + +SortDirection = Literal["asc", "desc"] diff --git a/src/cloudflare/types/shared_params/__init__.py b/src/cloudflare/types/shared_params/__init__.py index 9aee71c9325..6a6befd7e33 100644 --- a/src/cloudflare/types/shared_params/__init__.py +++ b/src/cloudflare/types/shared_params/__init__.py @@ -2,5 +2,6 @@ from .asn import ASN as ASN from .certificate_ca import CertificateCA as CertificateCA +from .sort_direction import SortDirection as SortDirection from .permission_grant import PermissionGrant as PermissionGrant from .certificate_request_type import CertificateRequestType as CertificateRequestType diff --git a/src/cloudflare/types/shared_params/sort_direction.py b/src/cloudflare/types/shared_params/sort_direction.py new file mode 100644 index 00000000000..083d4b43165 --- /dev/null +++ b/src/cloudflare/types/shared_params/sort_direction.py @@ -0,0 +1,9 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal + +__all__ = ["SortDirection"] + +SortDirection = Literal["asc", "desc"] diff --git a/src/cloudflare/types/zones/__init__.py b/src/cloudflare/types/zones/__init__.py index 1f0b10e4ded..3d3e43049cf 100644 --- a/src/cloudflare/types/zones/__init__.py +++ b/src/cloudflare/types/zones/__init__.py @@ -2,6 +2,7 @@ from __future__ import annotations +from .type import Type as Type from .zone import Zone as Zone from .zone_hold import ZoneHold as ZoneHold from .nameserver import Nameserver as Nameserver diff --git a/src/cloudflare/types/zones/type.py b/src/cloudflare/types/zones/type.py new file mode 100644 index 00000000000..d5f60d0c7f4 --- /dev/null +++ b/src/cloudflare/types/zones/type.py @@ -0,0 +1,7 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing_extensions import Literal + +__all__ = ["Type"] + +Type = Literal["full", "partial", "secondary"] diff --git a/src/cloudflare/types/zones/zone_create_params.py b/src/cloudflare/types/zones/zone_create_params.py index 492bd7fab19..9500909dced 100644 --- a/src/cloudflare/types/zones/zone_create_params.py +++ b/src/cloudflare/types/zones/zone_create_params.py @@ -2,7 +2,9 @@ from __future__ import annotations -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Required, TypedDict + +from .type import Type __all__ = ["ZoneCreateParams", "Account"] @@ -13,7 +15,7 @@ class ZoneCreateParams(TypedDict, total=False): name: Required[str] """The domain name""" - type: Literal["full", "partial", "secondary"] + type: Type """A full zone implies that DNS is hosted with Cloudflare. A partial zone is typically a partner-hosted zone or a CNAME setup. diff --git a/tests/api_resources/test_zones.py b/tests/api_resources/test_zones.py index a587aaf14f5..f4a3a4dfb67 100644 --- a/tests/api_resources/test_zones.py +++ b/tests/api_resources/test_zones.py @@ -10,7 +10,10 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray -from cloudflare.types.zones import Zone, ZoneDeleteResponse +from cloudflare.types.zones import ( + Zone, + ZoneDeleteResponse, +) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")