diff --git a/src/cloudflare/resources/firewall/access_rules.py b/src/cloudflare/resources/firewall/access_rules.py index 6e5eb3dab16..941359d6651 100644 --- a/src/cloudflare/resources/firewall/access_rules.py +++ b/src/cloudflare/resources/firewall/access_rules.py @@ -91,12 +91,6 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -104,6 +98,9 @@ def create( 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 cast( @@ -176,12 +173,6 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -189,6 +180,9 @@ def list( 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_api_list( @@ -246,12 +240,6 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -259,6 +247,9 @@ def delete( 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( @@ -314,12 +305,6 @@ def edit( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -327,6 +312,9 @@ def edit( 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 cast( @@ -383,12 +371,6 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -396,6 +378,9 @@ def get( 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 cast( @@ -467,12 +452,6 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -480,6 +459,9 @@ async def create( 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 cast( @@ -552,12 +534,6 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -565,6 +541,9 @@ def list( 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_api_list( @@ -622,12 +601,6 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -635,6 +608,9 @@ async def delete( 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( @@ -690,12 +666,6 @@ async def edit( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -703,6 +673,9 @@ async def edit( 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 cast( @@ -759,12 +732,6 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -772,6 +739,9 @@ async def get( 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 cast( diff --git a/src/cloudflare/resources/logpush/datasets/fields.py b/src/cloudflare/resources/logpush/datasets/fields.py index a3c36cb11a8..96306dee47d 100644 --- a/src/cloudflare/resources/logpush/datasets/fields.py +++ b/src/cloudflare/resources/logpush/datasets/fields.py @@ -67,12 +67,6 @@ def get( """ if not dataset_id: raise ValueError(f"Expected a non-empty value for `dataset_id` but received {dataset_id!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -80,6 +74,9 @@ def get( 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( @@ -139,12 +136,6 @@ async def get( """ if not dataset_id: raise ValueError(f"Expected a non-empty value for `dataset_id` but received {dataset_id!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -152,6 +143,9 @@ async def get( 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( diff --git a/src/cloudflare/resources/logpush/datasets/jobs.py b/src/cloudflare/resources/logpush/datasets/jobs.py index 1fa7369012c..b6ce88278f4 100644 --- a/src/cloudflare/resources/logpush/datasets/jobs.py +++ b/src/cloudflare/resources/logpush/datasets/jobs.py @@ -66,12 +66,6 @@ def get( """ if not dataset_id: raise ValueError(f"Expected a non-empty value for `dataset_id` but received {dataset_id!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -79,6 +73,9 @@ def get( 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( @@ -136,12 +133,6 @@ async def get( """ if not dataset_id: raise ValueError(f"Expected a non-empty value for `dataset_id` but received {dataset_id!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -149,6 +140,9 @@ async def get( 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( diff --git a/src/cloudflare/resources/logpush/jobs.py b/src/cloudflare/resources/logpush/jobs.py index 520e6df2d0c..575b0beee35 100644 --- a/src/cloudflare/resources/logpush/jobs.py +++ b/src/cloudflare/resources/logpush/jobs.py @@ -110,12 +110,6 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -123,6 +117,9 @@ def create( 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._post( @@ -208,12 +205,6 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -221,6 +212,9 @@ def update( 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._put( @@ -274,12 +268,6 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -287,6 +275,9 @@ def list( 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_api_list( @@ -330,12 +321,6 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -343,6 +328,9 @@ def delete( 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 cast( @@ -394,12 +382,6 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -407,6 +389,9 @@ def get( 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( @@ -494,12 +479,6 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -507,6 +486,9 @@ async def create( 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._post( @@ -592,12 +574,6 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -605,6 +581,9 @@ async def update( 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._put( @@ -658,12 +637,6 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -671,6 +644,9 @@ def list( 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_api_list( @@ -714,12 +690,6 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -727,6 +697,9 @@ async def delete( 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 cast( @@ -778,12 +751,6 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -791,6 +758,9 @@ async def get( 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( diff --git a/src/cloudflare/resources/logpush/ownership.py b/src/cloudflare/resources/logpush/ownership.py index aebacdfa977..d0e0745bb9d 100644 --- a/src/cloudflare/resources/logpush/ownership.py +++ b/src/cloudflare/resources/logpush/ownership.py @@ -75,12 +75,6 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -88,6 +82,9 @@ def create( 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._post( @@ -139,12 +136,6 @@ def validate( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -152,6 +143,9 @@ def validate( 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._post( @@ -216,12 +210,6 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -229,6 +217,9 @@ async def create( 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._post( @@ -282,12 +273,6 @@ async def validate( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -295,6 +280,9 @@ async def validate( 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._post( diff --git a/src/cloudflare/resources/logpush/validate.py b/src/cloudflare/resources/logpush/validate.py index 407b47af93b..2c739ed17ec 100644 --- a/src/cloudflare/resources/logpush/validate.py +++ b/src/cloudflare/resources/logpush/validate.py @@ -75,12 +75,6 @@ def destination( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -88,6 +82,9 @@ def destination( 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._post( @@ -140,12 +137,6 @@ def origin( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -153,6 +144,9 @@ def origin( 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._post( @@ -211,12 +205,6 @@ async def destination( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -224,6 +212,9 @@ async def destination( 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._post( @@ -276,12 +267,6 @@ async def origin( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -289,6 +274,9 @@ async def origin( 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._post( diff --git a/src/cloudflare/resources/rulesets/phases/phases.py b/src/cloudflare/resources/rulesets/phases/phases.py index cc59c4d3d6f..c5f48a481ad 100644 --- a/src/cloudflare/resources/rulesets/phases/phases.py +++ b/src/cloudflare/resources/rulesets/phases/phases.py @@ -147,12 +147,6 @@ def update( """ if not ruleset_phase: raise ValueError(f"Expected a non-empty value for `ruleset_phase` but received {ruleset_phase!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -160,6 +154,9 @@ def update( 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._put( @@ -242,12 +239,6 @@ def get( """ if not ruleset_phase: raise ValueError(f"Expected a non-empty value for `ruleset_phase` but received {ruleset_phase!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -255,6 +246,9 @@ def get( 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( @@ -380,12 +374,6 @@ async def update( """ if not ruleset_phase: raise ValueError(f"Expected a non-empty value for `ruleset_phase` but received {ruleset_phase!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -393,6 +381,9 @@ async def update( 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._put( @@ -475,12 +466,6 @@ async def get( """ if not ruleset_phase: raise ValueError(f"Expected a non-empty value for `ruleset_phase` but received {ruleset_phase!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -488,6 +473,9 @@ async def get( 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( diff --git a/src/cloudflare/resources/rulesets/phases/versions.py b/src/cloudflare/resources/rulesets/phases/versions.py index 28c80b837c2..a1feaee0e15 100644 --- a/src/cloudflare/resources/rulesets/phases/versions.py +++ b/src/cloudflare/resources/rulesets/phases/versions.py @@ -94,12 +94,6 @@ def list( """ if not ruleset_phase: raise ValueError(f"Expected a non-empty value for `ruleset_phase` but received {ruleset_phase!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -107,6 +101,9 @@ def list( 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_api_list( @@ -180,12 +177,6 @@ def get( raise ValueError(f"Expected a non-empty value for `ruleset_phase` but received {ruleset_phase!r}") if not ruleset_version: raise ValueError(f"Expected a non-empty value for `ruleset_version` but received {ruleset_version!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -193,6 +184,9 @@ def get( 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( @@ -274,12 +268,6 @@ def list( """ if not ruleset_phase: raise ValueError(f"Expected a non-empty value for `ruleset_phase` but received {ruleset_phase!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -287,6 +275,9 @@ def list( 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_api_list( @@ -360,12 +351,6 @@ async def get( raise ValueError(f"Expected a non-empty value for `ruleset_phase` but received {ruleset_phase!r}") if not ruleset_version: raise ValueError(f"Expected a non-empty value for `ruleset_version` but received {ruleset_version!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -373,6 +358,9 @@ async def get( 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( diff --git a/src/cloudflare/resources/rulesets/rules.py b/src/cloudflare/resources/rulesets/rules.py index 393df75653b..c864665358b 100644 --- a/src/cloudflare/resources/rulesets/rules.py +++ b/src/cloudflare/resources/rulesets/rules.py @@ -996,12 +996,6 @@ def create( ) -> RuleCreateResponse: if not ruleset_id: raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -1009,6 +1003,9 @@ def create( 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._post( @@ -1074,12 +1071,6 @@ def delete( raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -1087,6 +1078,9 @@ def delete( 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( @@ -2086,12 +2080,6 @@ def edit( raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -2099,6 +2087,9 @@ def edit( 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( @@ -3086,12 +3077,6 @@ async def create( ) -> RuleCreateResponse: if not ruleset_id: raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -3099,6 +3084,9 @@ async def create( 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._post( @@ -3164,12 +3152,6 @@ async def delete( raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -3177,6 +3159,9 @@ async def delete( 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( @@ -4176,12 +4161,6 @@ async def edit( raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") if not rule_id: raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -4189,6 +4168,9 @@ async def edit( 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( diff --git a/src/cloudflare/resources/rulesets/rulesets.py b/src/cloudflare/resources/rulesets/rulesets.py index e88c1e2317a..ee36a733746 100644 --- a/src/cloudflare/resources/rulesets/rulesets.py +++ b/src/cloudflare/resources/rulesets/rulesets.py @@ -152,12 +152,6 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -165,6 +159,9 @@ def create( 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._post( @@ -262,12 +259,6 @@ def update( """ if not ruleset_id: raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -275,6 +266,9 @@ def update( 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._put( @@ -327,12 +321,6 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -340,6 +328,9 @@ def list( 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_api_list( @@ -384,12 +375,6 @@ def delete( """ if not ruleset_id: raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -397,6 +382,9 @@ def delete( 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 extra_headers = {"Accept": "*/*", **(extra_headers or {})} @@ -441,12 +429,6 @@ def get( """ if not ruleset_id: raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -454,6 +436,9 @@ def get( 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( @@ -557,12 +542,6 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -570,6 +549,9 @@ async def create( 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._post( @@ -667,12 +649,6 @@ async def update( """ if not ruleset_id: raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -680,6 +656,9 @@ async def update( 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._put( @@ -732,12 +711,6 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -745,6 +718,9 @@ def list( 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_api_list( @@ -789,12 +765,6 @@ async def delete( """ if not ruleset_id: raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -802,6 +772,9 @@ async def delete( 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 extra_headers = {"Accept": "*/*", **(extra_headers or {})} @@ -846,12 +819,6 @@ async def get( """ if not ruleset_id: raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -859,6 +826,9 @@ async def get( 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( diff --git a/src/cloudflare/resources/rulesets/versions/versions.py b/src/cloudflare/resources/rulesets/versions/versions.py index 1971b000bb1..f7744ec5b8f 100644 --- a/src/cloudflare/resources/rulesets/versions/versions.py +++ b/src/cloudflare/resources/rulesets/versions/versions.py @@ -81,12 +81,6 @@ def list( """ if not ruleset_id: raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -94,6 +88,9 @@ def list( 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_api_list( @@ -143,12 +140,6 @@ def delete( raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") if not ruleset_version: raise ValueError(f"Expected a non-empty value for `ruleset_version` but received {ruleset_version!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -156,6 +147,9 @@ def delete( 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 extra_headers = {"Accept": "*/*", **(extra_headers or {})} @@ -205,12 +199,6 @@ def get( raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") if not ruleset_version: raise ValueError(f"Expected a non-empty value for `ruleset_version` but received {ruleset_version!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -218,6 +206,9 @@ def get( 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( @@ -279,12 +270,6 @@ def list( """ if not ruleset_id: raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -292,6 +277,9 @@ def list( 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_api_list( @@ -341,12 +329,6 @@ async def delete( raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") if not ruleset_version: raise ValueError(f"Expected a non-empty value for `ruleset_version` but received {ruleset_version!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -354,6 +336,9 @@ async def delete( 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 extra_headers = {"Accept": "*/*", **(extra_headers or {})} @@ -403,12 +388,6 @@ async def get( raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") if not ruleset_version: raise ValueError(f"Expected a non-empty value for `ruleset_version` but received {ruleset_version!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -416,6 +395,9 @@ async def get( 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( diff --git a/src/cloudflare/resources/zero_trust/access/applications/applications.py b/src/cloudflare/resources/zero_trust/access/applications/applications.py index 008b75654aa..0b41414ea3f 100644 --- a/src/cloudflare/resources/zero_trust/access/applications/applications.py +++ b/src/cloudflare/resources/zero_trust/access/applications/applications.py @@ -706,12 +706,6 @@ def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> Application: - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -719,6 +713,9 @@ def create( 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 cast( @@ -1411,12 +1408,6 @@ def update( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> Application: - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -1424,6 +1415,9 @@ def update( 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 cast( @@ -1499,12 +1493,6 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -1512,6 +1500,9 @@ def list( 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_api_list( @@ -1554,12 +1545,6 @@ def delete( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -1567,6 +1552,9 @@ def delete( 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( @@ -1612,12 +1600,6 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -1625,6 +1607,9 @@ def get( 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 cast( @@ -1675,12 +1660,6 @@ def revoke_tokens( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -1688,6 +1667,9 @@ def revoke_tokens( 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._post( @@ -2344,12 +2326,6 @@ async def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> Application: - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -2357,6 +2333,9 @@ async def create( 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 cast( @@ -3049,12 +3028,6 @@ async def update( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> Application: - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -3062,6 +3035,9 @@ async def update( 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 cast( @@ -3137,12 +3113,6 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -3150,6 +3120,9 @@ def list( 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_api_list( @@ -3192,12 +3165,6 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -3205,6 +3172,9 @@ async def delete( 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( @@ -3250,12 +3220,6 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -3263,6 +3227,9 @@ async def get( 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 cast( @@ -3313,12 +3280,6 @@ async def revoke_tokens( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -3326,6 +3287,9 @@ async def revoke_tokens( 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._post( diff --git a/src/cloudflare/resources/zero_trust/access/applications/cas.py b/src/cloudflare/resources/zero_trust/access/applications/cas.py index bff83329c50..709826f1d4d 100644 --- a/src/cloudflare/resources/zero_trust/access/applications/cas.py +++ b/src/cloudflare/resources/zero_trust/access/applications/cas.py @@ -68,12 +68,6 @@ def create( """ if not uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -81,6 +75,9 @@ def create( 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 cast( @@ -128,12 +125,6 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -141,6 +132,9 @@ def list( 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_api_list( @@ -185,12 +179,6 @@ def delete( """ if not uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -198,6 +186,9 @@ def delete( 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( @@ -245,12 +236,6 @@ def get( """ if not uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -258,6 +243,9 @@ def get( 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 cast( @@ -320,12 +308,6 @@ async def create( """ if not uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -333,6 +315,9 @@ async def create( 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 cast( @@ -380,12 +365,6 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -393,6 +372,9 @@ def list( 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_api_list( @@ -437,12 +419,6 @@ async def delete( """ if not uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -450,6 +426,9 @@ async def delete( 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( @@ -497,12 +476,6 @@ async def get( """ if not uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -510,6 +483,9 @@ async def get( 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 cast( diff --git a/src/cloudflare/resources/zero_trust/access/applications/policies.py b/src/cloudflare/resources/zero_trust/access/applications/policies.py index 667bff5b526..ca932d7fce4 100644 --- a/src/cloudflare/resources/zero_trust/access/applications/policies.py +++ b/src/cloudflare/resources/zero_trust/access/applications/policies.py @@ -124,12 +124,6 @@ def create( """ if not uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -137,6 +131,9 @@ def create( 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._post( @@ -250,12 +247,6 @@ def update( raise ValueError(f"Expected a non-empty value for `uuid1` but received {uuid1!r}") if not uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -263,6 +254,9 @@ def update( 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._put( @@ -327,12 +321,6 @@ def list( """ if not uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -340,6 +328,9 @@ def list( 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_api_list( @@ -389,12 +380,6 @@ def delete( raise ValueError(f"Expected a non-empty value for `uuid1` but received {uuid1!r}") if not uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -402,6 +387,9 @@ def delete( 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( @@ -454,12 +442,6 @@ def get( raise ValueError(f"Expected a non-empty value for `uuid1` but received {uuid1!r}") if not uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -467,6 +449,9 @@ def get( 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( @@ -568,12 +553,6 @@ async def create( """ if not uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -581,6 +560,9 @@ async def create( 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._post( @@ -694,12 +676,6 @@ async def update( raise ValueError(f"Expected a non-empty value for `uuid1` but received {uuid1!r}") if not uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -707,6 +683,9 @@ async def update( 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._put( @@ -771,12 +750,6 @@ def list( """ if not uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -784,6 +757,9 @@ def list( 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_api_list( @@ -833,12 +809,6 @@ async def delete( raise ValueError(f"Expected a non-empty value for `uuid1` but received {uuid1!r}") if not uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -846,6 +816,9 @@ async def delete( 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( @@ -898,12 +871,6 @@ async def get( raise ValueError(f"Expected a non-empty value for `uuid1` but received {uuid1!r}") if not uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -911,6 +878,9 @@ async def get( 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( diff --git a/src/cloudflare/resources/zero_trust/access/applications/user_policy_checks.py b/src/cloudflare/resources/zero_trust/access/applications/user_policy_checks.py index f14b9d86dd5..21b71964d8d 100644 --- a/src/cloudflare/resources/zero_trust/access/applications/user_policy_checks.py +++ b/src/cloudflare/resources/zero_trust/access/applications/user_policy_checks.py @@ -65,12 +65,6 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -78,6 +72,9 @@ def list( 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( @@ -133,12 +130,6 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -146,6 +137,9 @@ async def list( 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( diff --git a/src/cloudflare/resources/zero_trust/access/certificates/certificates.py b/src/cloudflare/resources/zero_trust/access/certificates/certificates.py index 2beb3649a5f..6e9e231f471 100644 --- a/src/cloudflare/resources/zero_trust/access/certificates/certificates.py +++ b/src/cloudflare/resources/zero_trust/access/certificates/certificates.py @@ -94,12 +94,6 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -107,6 +101,9 @@ def create( 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._post( @@ -168,12 +165,6 @@ def update( """ if not uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -181,6 +172,9 @@ def update( 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._put( @@ -230,12 +224,6 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -243,6 +231,9 @@ def list( 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_api_list( @@ -287,12 +278,6 @@ def delete( """ if not uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -300,6 +285,9 @@ def delete( 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( @@ -347,12 +335,6 @@ def get( """ if not uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -360,6 +342,9 @@ def get( 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( @@ -425,12 +410,6 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -438,6 +417,9 @@ async def create( 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._post( @@ -499,12 +481,6 @@ async def update( """ if not uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -512,6 +488,9 @@ async def update( 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._put( @@ -561,12 +540,6 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -574,6 +547,9 @@ def list( 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_api_list( @@ -618,12 +594,6 @@ async def delete( """ if not uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -631,6 +601,9 @@ async def delete( 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( @@ -678,12 +651,6 @@ async def get( """ if not uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -691,6 +658,9 @@ async def get( 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( diff --git a/src/cloudflare/resources/zero_trust/access/certificates/settings.py b/src/cloudflare/resources/zero_trust/access/certificates/settings.py index a63763c5df6..73ce58feeff 100644 --- a/src/cloudflare/resources/zero_trust/access/certificates/settings.py +++ b/src/cloudflare/resources/zero_trust/access/certificates/settings.py @@ -71,12 +71,6 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -84,6 +78,9 @@ def update( 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._put( @@ -127,12 +124,6 @@ def get( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -140,6 +131,9 @@ def get( 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( @@ -193,12 +187,6 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -206,6 +194,9 @@ async def update( 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._put( @@ -249,12 +240,6 @@ async def get( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -262,6 +247,9 @@ async def get( 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( diff --git a/src/cloudflare/resources/zero_trust/access/groups.py b/src/cloudflare/resources/zero_trust/access/groups.py index cb28d32ebf9..32e631c5505 100644 --- a/src/cloudflare/resources/zero_trust/access/groups.py +++ b/src/cloudflare/resources/zero_trust/access/groups.py @@ -86,12 +86,6 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -99,6 +93,9 @@ def create( 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._post( @@ -174,12 +171,6 @@ def update( """ if not uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -187,6 +178,9 @@ def update( 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._put( @@ -239,12 +233,6 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -252,6 +240,9 @@ def list( 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_api_list( @@ -296,12 +287,6 @@ def delete( """ if not uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -309,6 +294,9 @@ def delete( 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( @@ -356,12 +344,6 @@ def get( """ if not uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -369,6 +351,9 @@ def get( 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( @@ -439,12 +424,6 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -452,6 +431,9 @@ async def create( 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._post( @@ -527,12 +509,6 @@ async def update( """ if not uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -540,6 +516,9 @@ async def update( 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._put( @@ -592,12 +571,6 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -605,6 +578,9 @@ def list( 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_api_list( @@ -649,12 +625,6 @@ async def delete( """ if not uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -662,6 +632,9 @@ async def delete( 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( @@ -709,12 +682,6 @@ async def get( """ if not uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -722,6 +689,9 @@ async def get( 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( diff --git a/src/cloudflare/resources/zero_trust/access/service_tokens.py b/src/cloudflare/resources/zero_trust/access/service_tokens.py index 49ecb7332b9..31a09535c3a 100644 --- a/src/cloudflare/resources/zero_trust/access/service_tokens.py +++ b/src/cloudflare/resources/zero_trust/access/service_tokens.py @@ -84,12 +84,6 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -97,6 +91,9 @@ def create( 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._post( @@ -159,12 +156,6 @@ def update( """ if not uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -172,6 +163,9 @@ def update( 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._put( @@ -221,12 +215,6 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -234,6 +222,9 @@ def list( 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_api_list( @@ -278,12 +269,6 @@ def delete( """ if not uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -291,6 +276,9 @@ def delete( 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( @@ -442,12 +430,6 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -455,6 +437,9 @@ async def create( 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._post( @@ -517,12 +502,6 @@ async def update( """ if not uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -530,6 +509,9 @@ async def update( 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._put( @@ -579,12 +561,6 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -592,6 +568,9 @@ def list( 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_api_list( @@ -636,12 +615,6 @@ async def delete( """ if not uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -649,6 +622,9 @@ async def delete( 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( diff --git a/src/cloudflare/resources/zero_trust/identity_providers.py b/src/cloudflare/resources/zero_trust/identity_providers.py index 6565d6ecd5f..43fd0749d75 100644 --- a/src/cloudflare/resources/zero_trust/identity_providers.py +++ b/src/cloudflare/resources/zero_trust/identity_providers.py @@ -763,12 +763,6 @@ def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> IdentityProvider: - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -776,6 +770,9 @@ def create( 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 cast( @@ -1563,12 +1560,6 @@ def update( ) -> IdentityProvider: if not uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -1576,6 +1567,9 @@ def update( 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 cast( @@ -1632,12 +1626,6 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -1645,6 +1633,9 @@ def list( 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_api_list( @@ -1691,12 +1682,6 @@ def delete( """ if not uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -1704,6 +1689,9 @@ def delete( 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( @@ -1751,12 +1739,6 @@ def get( """ if not uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -1764,6 +1746,9 @@ def get( 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 cast( @@ -2507,12 +2492,6 @@ async def create( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> IdentityProvider: - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -2520,6 +2499,9 @@ async def create( 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 cast( @@ -3307,12 +3289,6 @@ async def update( ) -> IdentityProvider: if not uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -3320,6 +3296,9 @@ async def update( 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 cast( @@ -3376,12 +3355,6 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -3389,6 +3362,9 @@ def list( 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_api_list( @@ -3435,12 +3411,6 @@ async def delete( """ if not uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -3448,6 +3418,9 @@ async def delete( 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( @@ -3495,12 +3468,6 @@ async def get( """ if not uuid: raise ValueError(f"Expected a non-empty value for `uuid` but received {uuid!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -3508,6 +3475,9 @@ async def get( 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 cast( diff --git a/src/cloudflare/resources/zero_trust/organizations.py b/src/cloudflare/resources/zero_trust/organizations.py index a065a59d9c3..b1bd15fdfd8 100644 --- a/src/cloudflare/resources/zero_trust/organizations.py +++ b/src/cloudflare/resources/zero_trust/organizations.py @@ -109,12 +109,6 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -122,6 +116,9 @@ def create( 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._post( @@ -217,12 +214,6 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -230,6 +221,9 @@ def update( 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._put( @@ -288,12 +282,6 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -301,6 +289,9 @@ def list( 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( @@ -346,12 +337,6 @@ def revoke_users( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -359,6 +344,9 @@ def revoke_users( 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._post( @@ -451,12 +439,6 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -464,6 +446,9 @@ async def create( 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._post( @@ -559,12 +544,6 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -572,6 +551,9 @@ async def update( 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._put( @@ -630,12 +612,6 @@ async def list( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -643,6 +619,9 @@ async def list( 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( @@ -688,12 +667,6 @@ async def revoke_users( timeout: Override the client-level default timeout for this request, in seconds """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") if account_id and zone_id: raise ValueError("You cannot provide both account_id and zone_id") @@ -701,6 +674,9 @@ async def revoke_users( 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._post(