From c5e97ae2d1062ddc7758f793da07d82921249fd8 Mon Sep 17 00:00:00 2001 From: stainless-bot Date: Mon, 11 Nov 2024 22:33:39 +0000 Subject: [PATCH] feat(zero_trust_device): reshuffle structure to allow use of custom and default --- .stats.yml | 2 +- README.md | 12 +- api.md | 132 ++- .../zero_trust/devices/policies/__init__.py | 94 +- .../devices/policies/custom/__init__.py | 61 ++ .../devices/policies/custom/custom.py | 957 +++++++++++++++++ .../devices/policies/{ => custom}/excludes.py | 122 +-- .../policies/{ => custom}/fallback_domains.py | 106 +- .../devices/policies/{ => custom}/includes.py | 122 +-- .../devices/policies/default/__init__.py | 75 ++ .../policies/{ => default}/certificates.py | 62 +- .../devices/policies/default/default.py | 494 +++++++++ .../devices/policies/default/excludes.py | 270 +++++ .../policies/default/fallback_domains.py | 278 +++++ .../devices/policies/default/includes.py | 270 +++++ .../devices/policies/default_policy.py | 174 ---- .../zero_trust/devices/policies/policies.py | 965 +----------------- .../types/zero_trust/devices/__init__.py | 9 +- .../devices/{policies => }/fallback_domain.py | 2 +- .../{policies => }/fallback_domain_param.py | 0 .../zero_trust/devices/policies/__init__.py | 25 +- .../devices/policies/custom/__init__.py | 13 + .../{ => custom}/exclude_get_response.py | 2 +- .../{ => custom}/exclude_update_params.py | 2 +- .../{ => custom}/exclude_update_response.py | 2 +- .../fallback_domain_get_response.py | 2 +- .../fallback_domain_update_params.py | 2 +- .../fallback_domain_update_response.py | 2 +- .../{ => custom}/include_get_response.py | 2 +- .../{ => custom}/include_update_params.py | 2 +- .../{ => custom}/include_update_response.py | 2 +- .../custom_create_params.py} | 4 +- .../custom_delete_response.py} | 6 +- .../custom_edit_params.py} | 4 +- .../devices/policies/default/__init__.py | 16 + .../certificate_edit_params.py} | 4 +- .../certificate_edit_response.py} | 4 +- .../{ => default}/certificate_get_response.py | 0 .../policies/default/exclude_get_response.py | 10 + .../policies/default/exclude_update_params.py | 16 + .../default/exclude_update_response.py | 10 + .../default/fallback_domain_get_response.py | 10 + .../default/fallback_domain_update_params.py | 16 + .../fallback_domain_update_response.py | 10 + .../policies/default/include_get_response.py | 10 + .../policies/default/include_update_params.py | 16 + .../default/include_update_response.py | 10 + .../devices/policies/default_edit_params.py | 60 ++ ...t_response.py => default_edit_response.py} | 10 +- .../devices/policies/default_get_response.py | 75 ++ .../zero_trust/devices/settings_policy.py | 6 +- .../{policies => }/split_tunnel_exclude.py | 2 +- .../split_tunnel_exclude_param.py | 0 .../{policies => }/split_tunnel_include.py | 2 +- .../split_tunnel_include_param.py | 0 .../devices/policies/custom/__init__.py | 1 + .../policies/{ => custom}/test_excludes.py | 156 ++- .../{ => custom}/test_fallback_domains.py | 120 +-- .../policies/{ => custom}/test_includes.py | 156 ++- .../devices/policies/default/__init__.py | 1 + .../{ => default}/test_certificates.py | 64 +- .../devices/policies/default/test_excludes.py | 289 ++++++ .../policies/default/test_fallback_domains.py | 185 ++++ .../devices/policies/default/test_includes.py | 289 ++++++ .../test_custom.py} | 218 ++-- .../devices/policies/test_default.py | 216 ++++ .../devices/policies/test_default_policy.py | 98 -- 67 files changed, 4245 insertions(+), 2112 deletions(-) create mode 100644 src/cloudflare/resources/zero_trust/devices/policies/custom/__init__.py create mode 100644 src/cloudflare/resources/zero_trust/devices/policies/custom/custom.py rename src/cloudflare/resources/zero_trust/devices/policies/{ => custom}/excludes.py (71%) rename src/cloudflare/resources/zero_trust/devices/policies/{ => custom}/fallback_domains.py (73%) rename src/cloudflare/resources/zero_trust/devices/policies/{ => custom}/includes.py (71%) create mode 100644 src/cloudflare/resources/zero_trust/devices/policies/default/__init__.py rename src/cloudflare/resources/zero_trust/devices/policies/{ => default}/certificates.py (86%) mode change 100755 => 100644 create mode 100644 src/cloudflare/resources/zero_trust/devices/policies/default/default.py create mode 100644 src/cloudflare/resources/zero_trust/devices/policies/default/excludes.py create mode 100644 src/cloudflare/resources/zero_trust/devices/policies/default/fallback_domains.py create mode 100644 src/cloudflare/resources/zero_trust/devices/policies/default/includes.py delete mode 100644 src/cloudflare/resources/zero_trust/devices/policies/default_policy.py rename src/cloudflare/types/zero_trust/devices/{policies => }/fallback_domain.py (93%) rename src/cloudflare/types/zero_trust/devices/{policies => }/fallback_domain_param.py (100%) create mode 100644 src/cloudflare/types/zero_trust/devices/policies/custom/__init__.py rename src/cloudflare/types/zero_trust/devices/policies/{ => custom}/exclude_get_response.py (81%) rename src/cloudflare/types/zero_trust/devices/policies/{ => custom}/exclude_update_params.py (85%) rename src/cloudflare/types/zero_trust/devices/policies/{ => custom}/exclude_update_response.py (81%) rename src/cloudflare/types/zero_trust/devices/policies/{ => custom}/fallback_domain_get_response.py (84%) rename src/cloudflare/types/zero_trust/devices/policies/{ => custom}/fallback_domain_update_params.py (87%) rename src/cloudflare/types/zero_trust/devices/policies/{ => custom}/fallback_domain_update_response.py (84%) rename src/cloudflare/types/zero_trust/devices/policies/{ => custom}/include_get_response.py (81%) rename src/cloudflare/types/zero_trust/devices/policies/{ => custom}/include_update_params.py (85%) rename src/cloudflare/types/zero_trust/devices/policies/{ => custom}/include_update_response.py (81%) rename src/cloudflare/types/zero_trust/devices/{policy_create_params.py => policies/custom_create_params.py} (96%) rename src/cloudflare/types/zero_trust/devices/{policy_delete_response.py => policies/custom_delete_response.py} (53%) rename src/cloudflare/types/zero_trust/devices/{policy_edit_params.py => policies/custom_edit_params.py} (95%) create mode 100644 src/cloudflare/types/zero_trust/devices/policies/default/__init__.py rename src/cloudflare/types/zero_trust/devices/policies/{certificate_update_params.py => default/certificate_edit_params.py} (77%) mode change 100755 => 100644 rename src/cloudflare/types/zero_trust/devices/policies/{certificate_update_response.py => default/certificate_edit_response.py} (58%) mode change 100755 => 100644 rename src/cloudflare/types/zero_trust/devices/policies/{ => default}/certificate_get_response.py (100%) mode change 100755 => 100644 create mode 100644 src/cloudflare/types/zero_trust/devices/policies/default/exclude_get_response.py create mode 100644 src/cloudflare/types/zero_trust/devices/policies/default/exclude_update_params.py create mode 100644 src/cloudflare/types/zero_trust/devices/policies/default/exclude_update_response.py create mode 100644 src/cloudflare/types/zero_trust/devices/policies/default/fallback_domain_get_response.py create mode 100644 src/cloudflare/types/zero_trust/devices/policies/default/fallback_domain_update_params.py create mode 100644 src/cloudflare/types/zero_trust/devices/policies/default/fallback_domain_update_response.py create mode 100644 src/cloudflare/types/zero_trust/devices/policies/default/include_get_response.py create mode 100644 src/cloudflare/types/zero_trust/devices/policies/default/include_update_params.py create mode 100644 src/cloudflare/types/zero_trust/devices/policies/default/include_update_response.py create mode 100644 src/cloudflare/types/zero_trust/devices/policies/default_edit_params.py rename src/cloudflare/types/zero_trust/devices/policies/{default_policy_get_response.py => default_edit_response.py} (89%) create mode 100644 src/cloudflare/types/zero_trust/devices/policies/default_get_response.py rename src/cloudflare/types/zero_trust/devices/{policies => }/split_tunnel_exclude.py (94%) rename src/cloudflare/types/zero_trust/devices/{policies => }/split_tunnel_exclude_param.py (100%) rename src/cloudflare/types/zero_trust/devices/{policies => }/split_tunnel_include.py (94%) rename src/cloudflare/types/zero_trust/devices/{policies => }/split_tunnel_include_param.py (100%) create mode 100644 tests/api_resources/zero_trust/devices/policies/custom/__init__.py rename tests/api_resources/zero_trust/devices/policies/{ => custom}/test_excludes.py (71%) rename tests/api_resources/zero_trust/devices/policies/{ => custom}/test_fallback_domains.py (64%) rename tests/api_resources/zero_trust/devices/policies/{ => custom}/test_includes.py (71%) create mode 100644 tests/api_resources/zero_trust/devices/policies/default/__init__.py rename tests/api_resources/zero_trust/devices/policies/{ => default}/test_certificates.py (68%) mode change 100755 => 100644 create mode 100644 tests/api_resources/zero_trust/devices/policies/default/test_excludes.py create mode 100644 tests/api_resources/zero_trust/devices/policies/default/test_fallback_domains.py create mode 100644 tests/api_resources/zero_trust/devices/policies/default/test_includes.py rename tests/api_resources/zero_trust/devices/{test_policies.py => policies/test_custom.py} (75%) create mode 100644 tests/api_resources/zero_trust/devices/policies/test_default.py delete mode 100644 tests/api_resources/zero_trust/devices/policies/test_default_policy.py diff --git a/.stats.yml b/.stats.yml index fdf051588bd..f17384f70ce 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 1397 +configured_endpoints: 1401 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1f3a5920b5590a1e7f4df129cc299fe3d4aaa7bf4ef6915b015dd898b1a1813c.yml diff --git a/README.md b/README.md index 17dfb884acf..27c36dd940b 100644 --- a/README.md +++ b/README.md @@ -28,10 +28,8 @@ import os from cloudflare import Cloudflare client = Cloudflare( - # This is the default and can be omitted - api_email=os.environ.get("CLOUDFLARE_EMAIL"), - # This is the default and can be omitted - api_key=os.environ.get("CLOUDFLARE_API_KEY"), + api_email=os.environ.get("CLOUDFLARE_EMAIL"), # This is the default and can be omitted + api_key=os.environ.get("CLOUDFLARE_API_KEY"), # This is the default and can be omitted ) zone = client.zones.create( @@ -57,10 +55,8 @@ import asyncio from cloudflare import AsyncCloudflare client = AsyncCloudflare( - # This is the default and can be omitted - api_email=os.environ.get("CLOUDFLARE_EMAIL"), - # This is the default and can be omitted - api_key=os.environ.get("CLOUDFLARE_API_KEY"), + api_email=os.environ.get("CLOUDFLARE_EMAIL"), # This is the default and can be omitted + api_key=os.environ.get("CLOUDFLARE_API_KEY"), # This is the default and can be omitted ) diff --git a/api.md b/api.md index 882481365ec..98a284741b3 100644 --- a/api.md +++ b/api.md @@ -4726,53 +4726,115 @@ Methods: Types: ```python -from cloudflare.types.zero_trust.devices import SettingsPolicy, PolicyDeleteResponse +from cloudflare.types.zero_trust.devices import ( + DevicePolicyCertificates, + FallbackDomain, + FallbackDomainPolicy, + SettingsPolicy, + SplitTunnelExclude, + SplitTunnelInclude, +) +``` + +#### Default + +Types: + +```python +from cloudflare.types.zero_trust.devices.policies import DefaultEditResponse, DefaultGetResponse ``` Methods: -- client.zero_trust.devices.policies.create(\*, account_id, \*\*params) -> Optional -- client.zero_trust.devices.policies.list(\*, account_id) -> SyncSinglePage[SettingsPolicy] -- client.zero_trust.devices.policies.delete(policy_id, \*, account_id) -> Optional -- client.zero_trust.devices.policies.edit(policy_id, \*, account_id, \*\*params) -> Optional -- client.zero_trust.devices.policies.get(policy_id, \*, account_id) -> Optional +- client.zero_trust.devices.policies.default.edit(\*, account_id, \*\*params) -> Optional +- client.zero_trust.devices.policies.default.get(\*, account_id) -> Optional -#### Certificates +##### Excludes Types: ```python -from cloudflare.types.zero_trust.devices.policies import ( - DevicePolicyCertificates, - CertificateUpdateResponse, +from cloudflare.types.zero_trust.devices.policies.default import ( + ExcludeUpdateResponse, + ExcludeGetResponse, +) +``` + +Methods: + +- client.zero_trust.devices.policies.default.excludes.update(\*, account_id, \*\*params) -> Optional +- client.zero_trust.devices.policies.default.excludes.get(\*, account_id) -> Optional + +##### Includes + +Types: + +```python +from cloudflare.types.zero_trust.devices.policies.default import ( + IncludeUpdateResponse, + IncludeGetResponse, +) +``` + +Methods: + +- client.zero_trust.devices.policies.default.includes.update(\*, account_id, \*\*params) -> Optional +- client.zero_trust.devices.policies.default.includes.get(\*, account_id) -> Optional + +##### FallbackDomains + +Types: + +```python +from cloudflare.types.zero_trust.devices.policies.default import ( + FallbackDomainUpdateResponse, + FallbackDomainGetResponse, +) +``` + +Methods: + +- client.zero_trust.devices.policies.default.fallback_domains.update(\*, account_id, \*\*params) -> Optional +- client.zero_trust.devices.policies.default.fallback_domains.get(\*, account_id) -> Optional + +##### Certificates + +Types: + +```python +from cloudflare.types.zero_trust.devices.policies.default import ( + CertificateEditResponse, CertificateGetResponse, ) ``` Methods: -- client.zero_trust.devices.policies.certificates.update(zone_tag, \*\*params) -> CertificateUpdateResponse -- client.zero_trust.devices.policies.certificates.get(zone_tag) -> CertificateGetResponse +- client.zero_trust.devices.policies.default.certificates.edit(zone_tag, \*\*params) -> CertificateEditResponse +- client.zero_trust.devices.policies.default.certificates.get(zone_tag) -> CertificateGetResponse -#### DefaultPolicy +#### Custom Types: ```python -from cloudflare.types.zero_trust.devices.policies import DefaultPolicyGetResponse +from cloudflare.types.zero_trust.devices.policies import CustomDeleteResponse ``` Methods: -- client.zero_trust.devices.policies.default_policy.get(\*, account_id) -> Optional +- client.zero_trust.devices.policies.custom.create(\*, account_id, \*\*params) -> Optional +- client.zero_trust.devices.policies.custom.list(\*, account_id) -> SyncSinglePage[SettingsPolicy] +- client.zero_trust.devices.policies.custom.delete(policy_id, \*, account_id) -> Optional +- client.zero_trust.devices.policies.custom.edit(policy_id, \*, account_id, \*\*params) -> Optional +- client.zero_trust.devices.policies.custom.get(policy_id, \*, account_id) -> Optional -#### Excludes +##### Excludes Types: ```python -from cloudflare.types.zero_trust.devices.policies import ( - SplitTunnelExclude, +from cloudflare.types.zero_trust.devices.policies.custom import ( ExcludeUpdateResponse, ExcludeGetResponse, ) @@ -4780,46 +4842,40 @@ from cloudflare.types.zero_trust.devices.policies import ( Methods: -- client.zero_trust.devices.policies.excludes.update(\*, account_id, \*\*params) -> Optional -- client.zero_trust.devices.policies.excludes.list(\*, account_id) -> SyncSinglePage[SplitTunnelExclude] -- client.zero_trust.devices.policies.excludes.get(policy_id, \*, account_id) -> Optional +- client.zero_trust.devices.policies.custom.excludes.update(policy_id, \*, account_id, \*\*params) -> Optional +- client.zero_trust.devices.policies.custom.excludes.get(policy_id, \*, account_id) -> Optional -#### FallbackDomains +##### Includes Types: ```python -from cloudflare.types.zero_trust.devices.policies import ( - FallbackDomain, - FallbackDomainPolicy, - FallbackDomainUpdateResponse, - FallbackDomainGetResponse, +from cloudflare.types.zero_trust.devices.policies.custom import ( + IncludeUpdateResponse, + IncludeGetResponse, ) ``` Methods: -- client.zero_trust.devices.policies.fallback_domains.update(policy_id, \*, account_id, \*\*params) -> Optional -- client.zero_trust.devices.policies.fallback_domains.list(\*, account_id) -> SyncSinglePage[FallbackDomain] -- client.zero_trust.devices.policies.fallback_domains.get(policy_id, \*, account_id) -> Optional +- client.zero_trust.devices.policies.custom.includes.update(policy_id, \*, account_id, \*\*params) -> Optional +- client.zero_trust.devices.policies.custom.includes.get(policy_id, \*, account_id) -> Optional -#### Includes +##### FallbackDomains Types: ```python -from cloudflare.types.zero_trust.devices.policies import ( - SplitTunnelInclude, - IncludeUpdateResponse, - IncludeGetResponse, +from cloudflare.types.zero_trust.devices.policies.custom import ( + FallbackDomainUpdateResponse, + FallbackDomainGetResponse, ) ``` Methods: -- client.zero_trust.devices.policies.includes.update(\*, account_id, \*\*params) -> Optional -- client.zero_trust.devices.policies.includes.list(\*, account_id) -> SyncSinglePage[SplitTunnelInclude] -- client.zero_trust.devices.policies.includes.get(policy_id, \*, account_id) -> Optional +- client.zero_trust.devices.policies.custom.fallback_domains.update(policy_id, \*, account_id, \*\*params) -> Optional +- client.zero_trust.devices.policies.custom.fallback_domains.get(policy_id, \*, account_id) -> Optional ### Posture diff --git a/src/cloudflare/resources/zero_trust/devices/policies/__init__.py b/src/cloudflare/resources/zero_trust/devices/policies/__init__.py index d2ee86ffe70..e9b3fafb157 100644 --- a/src/cloudflare/resources/zero_trust/devices/policies/__init__.py +++ b/src/cloudflare/resources/zero_trust/devices/policies/__init__.py @@ -1,20 +1,20 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from .excludes import ( - ExcludesResource, - AsyncExcludesResource, - ExcludesResourceWithRawResponse, - AsyncExcludesResourceWithRawResponse, - ExcludesResourceWithStreamingResponse, - AsyncExcludesResourceWithStreamingResponse, +from .custom import ( + CustomResource, + AsyncCustomResource, + CustomResourceWithRawResponse, + AsyncCustomResourceWithRawResponse, + CustomResourceWithStreamingResponse, + AsyncCustomResourceWithStreamingResponse, ) -from .includes import ( - IncludesResource, - AsyncIncludesResource, - IncludesResourceWithRawResponse, - AsyncIncludesResourceWithRawResponse, - IncludesResourceWithStreamingResponse, - AsyncIncludesResourceWithStreamingResponse, +from .default import ( + DefaultResource, + AsyncDefaultResource, + DefaultResourceWithRawResponse, + AsyncDefaultResourceWithRawResponse, + DefaultResourceWithStreamingResponse, + AsyncDefaultResourceWithStreamingResponse, ) from .policies import ( PoliciesResource, @@ -24,62 +24,20 @@ PoliciesResourceWithStreamingResponse, AsyncPoliciesResourceWithStreamingResponse, ) -from .certificates import ( - CertificatesResource, - AsyncCertificatesResource, - CertificatesResourceWithRawResponse, - AsyncCertificatesResourceWithRawResponse, - CertificatesResourceWithStreamingResponse, - AsyncCertificatesResourceWithStreamingResponse, -) -from .default_policy import ( - DefaultPolicyResource, - AsyncDefaultPolicyResource, - DefaultPolicyResourceWithRawResponse, - AsyncDefaultPolicyResourceWithRawResponse, - DefaultPolicyResourceWithStreamingResponse, - AsyncDefaultPolicyResourceWithStreamingResponse, -) -from .fallback_domains import ( - FallbackDomainsResource, - AsyncFallbackDomainsResource, - FallbackDomainsResourceWithRawResponse, - AsyncFallbackDomainsResourceWithRawResponse, - FallbackDomainsResourceWithStreamingResponse, - AsyncFallbackDomainsResourceWithStreamingResponse, -) __all__ = [ - "CertificatesResource", - "AsyncCertificatesResource", - "CertificatesResourceWithRawResponse", - "AsyncCertificatesResourceWithRawResponse", - "CertificatesResourceWithStreamingResponse", - "AsyncCertificatesResourceWithStreamingResponse", - "DefaultPolicyResource", - "AsyncDefaultPolicyResource", - "DefaultPolicyResourceWithRawResponse", - "AsyncDefaultPolicyResourceWithRawResponse", - "DefaultPolicyResourceWithStreamingResponse", - "AsyncDefaultPolicyResourceWithStreamingResponse", - "ExcludesResource", - "AsyncExcludesResource", - "ExcludesResourceWithRawResponse", - "AsyncExcludesResourceWithRawResponse", - "ExcludesResourceWithStreamingResponse", - "AsyncExcludesResourceWithStreamingResponse", - "FallbackDomainsResource", - "AsyncFallbackDomainsResource", - "FallbackDomainsResourceWithRawResponse", - "AsyncFallbackDomainsResourceWithRawResponse", - "FallbackDomainsResourceWithStreamingResponse", - "AsyncFallbackDomainsResourceWithStreamingResponse", - "IncludesResource", - "AsyncIncludesResource", - "IncludesResourceWithRawResponse", - "AsyncIncludesResourceWithRawResponse", - "IncludesResourceWithStreamingResponse", - "AsyncIncludesResourceWithStreamingResponse", + "DefaultResource", + "AsyncDefaultResource", + "DefaultResourceWithRawResponse", + "AsyncDefaultResourceWithRawResponse", + "DefaultResourceWithStreamingResponse", + "AsyncDefaultResourceWithStreamingResponse", + "CustomResource", + "AsyncCustomResource", + "CustomResourceWithRawResponse", + "AsyncCustomResourceWithRawResponse", + "CustomResourceWithStreamingResponse", + "AsyncCustomResourceWithStreamingResponse", "PoliciesResource", "AsyncPoliciesResource", "PoliciesResourceWithRawResponse", diff --git a/src/cloudflare/resources/zero_trust/devices/policies/custom/__init__.py b/src/cloudflare/resources/zero_trust/devices/policies/custom/__init__.py new file mode 100644 index 00000000000..34d4c820354 --- /dev/null +++ b/src/cloudflare/resources/zero_trust/devices/policies/custom/__init__.py @@ -0,0 +1,61 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .custom import ( + CustomResource, + AsyncCustomResource, + CustomResourceWithRawResponse, + AsyncCustomResourceWithRawResponse, + CustomResourceWithStreamingResponse, + AsyncCustomResourceWithStreamingResponse, +) +from .excludes import ( + ExcludesResource, + AsyncExcludesResource, + ExcludesResourceWithRawResponse, + AsyncExcludesResourceWithRawResponse, + ExcludesResourceWithStreamingResponse, + AsyncExcludesResourceWithStreamingResponse, +) +from .includes import ( + IncludesResource, + AsyncIncludesResource, + IncludesResourceWithRawResponse, + AsyncIncludesResourceWithRawResponse, + IncludesResourceWithStreamingResponse, + AsyncIncludesResourceWithStreamingResponse, +) +from .fallback_domains import ( + FallbackDomainsResource, + AsyncFallbackDomainsResource, + FallbackDomainsResourceWithRawResponse, + AsyncFallbackDomainsResourceWithRawResponse, + FallbackDomainsResourceWithStreamingResponse, + AsyncFallbackDomainsResourceWithStreamingResponse, +) + +__all__ = [ + "ExcludesResource", + "AsyncExcludesResource", + "ExcludesResourceWithRawResponse", + "AsyncExcludesResourceWithRawResponse", + "ExcludesResourceWithStreamingResponse", + "AsyncExcludesResourceWithStreamingResponse", + "IncludesResource", + "AsyncIncludesResource", + "IncludesResourceWithRawResponse", + "AsyncIncludesResourceWithRawResponse", + "IncludesResourceWithStreamingResponse", + "AsyncIncludesResourceWithStreamingResponse", + "FallbackDomainsResource", + "AsyncFallbackDomainsResource", + "FallbackDomainsResourceWithRawResponse", + "AsyncFallbackDomainsResourceWithRawResponse", + "FallbackDomainsResourceWithStreamingResponse", + "AsyncFallbackDomainsResourceWithStreamingResponse", + "CustomResource", + "AsyncCustomResource", + "CustomResourceWithRawResponse", + "AsyncCustomResourceWithRawResponse", + "CustomResourceWithStreamingResponse", + "AsyncCustomResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/zero_trust/devices/policies/custom/custom.py b/src/cloudflare/resources/zero_trust/devices/policies/custom/custom.py new file mode 100644 index 00000000000..c8c35645b59 --- /dev/null +++ b/src/cloudflare/resources/zero_trust/devices/policies/custom/custom.py @@ -0,0 +1,957 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Optional, cast + +import httpx + +from .excludes import ( + ExcludesResource, + AsyncExcludesResource, + ExcludesResourceWithRawResponse, + AsyncExcludesResourceWithRawResponse, + ExcludesResourceWithStreamingResponse, + AsyncExcludesResourceWithStreamingResponse, +) +from .includes import ( + IncludesResource, + AsyncIncludesResource, + IncludesResourceWithRawResponse, + AsyncIncludesResourceWithRawResponse, + IncludesResourceWithStreamingResponse, + AsyncIncludesResourceWithStreamingResponse, +) +from ......_types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ......_utils import ( + maybe_transform, + async_maybe_transform, +) +from ......_compat import cached_property +from ......_resource import SyncAPIResource, AsyncAPIResource +from ......_response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ......_wrappers import ResultWrapper +from ......pagination import SyncSinglePage, AsyncSinglePage +from .fallback_domains import ( + FallbackDomainsResource, + AsyncFallbackDomainsResource, + FallbackDomainsResourceWithRawResponse, + AsyncFallbackDomainsResourceWithRawResponse, + FallbackDomainsResourceWithStreamingResponse, + AsyncFallbackDomainsResourceWithStreamingResponse, +) +from ......_base_client import AsyncPaginator, make_request_options +from ......types.zero_trust.devices.policies import custom_edit_params, custom_create_params +from ......types.zero_trust.devices.settings_policy import SettingsPolicy +from ......types.zero_trust.devices.policies.custom_delete_response import CustomDeleteResponse + +__all__ = ["CustomResource", "AsyncCustomResource"] + + +class CustomResource(SyncAPIResource): + @cached_property + def excludes(self) -> ExcludesResource: + return ExcludesResource(self._client) + + @cached_property + def includes(self) -> IncludesResource: + return IncludesResource(self._client) + + @cached_property + def fallback_domains(self) -> FallbackDomainsResource: + return FallbackDomainsResource(self._client) + + @cached_property + def with_raw_response(self) -> CustomResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return the + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return CustomResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> CustomResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return CustomResourceWithStreamingResponse(self) + + def create( + self, + *, + account_id: str, + match: str, + name: str, + precedence: float, + allow_mode_switch: bool | NotGiven = NOT_GIVEN, + allow_updates: bool | NotGiven = NOT_GIVEN, + allowed_to_leave: bool | NotGiven = NOT_GIVEN, + auto_connect: float | NotGiven = NOT_GIVEN, + captive_portal: float | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + disable_auto_fallback: bool | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + exclude_office_ips: bool | NotGiven = NOT_GIVEN, + lan_allow_minutes: float | NotGiven = NOT_GIVEN, + lan_allow_subnet_size: float | NotGiven = NOT_GIVEN, + service_mode_v2: custom_create_params.ServiceModeV2 | NotGiven = NOT_GIVEN, + support_url: str | NotGiven = NOT_GIVEN, + switch_locked: bool | NotGiven = NOT_GIVEN, + tunnel_protocol: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[SettingsPolicy]: + """ + Creates a device settings profile to be applied to certain devices matching the + criteria. + + Args: + match: The wirefilter expression to match devices. + + name: The name of the device settings profile. + + precedence: The precedence of the policy. Lower values indicate higher precedence. Policies + will be evaluated in ascending order of this field. + + allow_mode_switch: Whether to allow the user to switch WARP between modes. + + allow_updates: Whether to receive update notifications when a new version of the client is + available. + + allowed_to_leave: Whether to allow devices to leave the organization. + + auto_connect: The amount of time in minutes to reconnect after having been disabled. + + captive_portal: Turn on the captive portal after the specified amount of time. + + description: A description of the policy. + + disable_auto_fallback: If the `dns_server` field of a fallback domain is not present, the client will + fall back to a best guess of the default/system DNS resolvers unless this policy + option is set to `true`. + + enabled: Whether the policy will be applied to matching devices. + + exclude_office_ips: Whether to add Microsoft IPs to Split Tunnel exclusions. + + lan_allow_minutes: The amount of time in minutes a user is allowed access to their LAN. A value of + 0 will allow LAN access until the next WARP reconnection, such as a reboot or a + laptop waking from sleep. Note that this field is omitted from the response if + null or unset. + + lan_allow_subnet_size: The size of the subnet for the local access network. Note that this field is + omitted from the response if null or unset. + + support_url: The URL to launch when the Send Feedback button is clicked. + + switch_locked: Whether to allow the user to turn off the WARP switch and disconnect the client. + + tunnel_protocol: Determines which tunnel protocol to use. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._post( + f"/accounts/{account_id}/devices/policy", + body=maybe_transform( + { + "match": match, + "name": name, + "precedence": precedence, + "allow_mode_switch": allow_mode_switch, + "allow_updates": allow_updates, + "allowed_to_leave": allowed_to_leave, + "auto_connect": auto_connect, + "captive_portal": captive_portal, + "description": description, + "disable_auto_fallback": disable_auto_fallback, + "enabled": enabled, + "exclude_office_ips": exclude_office_ips, + "lan_allow_minutes": lan_allow_minutes, + "lan_allow_subnet_size": lan_allow_subnet_size, + "service_mode_v2": service_mode_v2, + "support_url": support_url, + "switch_locked": switch_locked, + "tunnel_protocol": tunnel_protocol, + }, + custom_create_params.CustomCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[SettingsPolicy]]._unwrapper, + ), + cast_to=cast(Type[Optional[SettingsPolicy]], ResultWrapper[SettingsPolicy]), + ) + + def list( + self, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> SyncSinglePage[SettingsPolicy]: + """ + Fetches a list of the device settings profiles for an account. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/devices/policies", + page=SyncSinglePage[SettingsPolicy], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=SettingsPolicy, + ) + + def delete( + self, + policy_id: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[CustomDeleteResponse]: + """ + Deletes a device settings profile and fetches a list of the remaining profiles + for an account. + + Args: + policy_id: Device ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not policy_id: + raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") + return self._delete( + f"/accounts/{account_id}/devices/policy/{policy_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[CustomDeleteResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[CustomDeleteResponse]], ResultWrapper[CustomDeleteResponse]), + ) + + def edit( + self, + policy_id: str, + *, + account_id: str, + allow_mode_switch: bool | NotGiven = NOT_GIVEN, + allow_updates: bool | NotGiven = NOT_GIVEN, + allowed_to_leave: bool | NotGiven = NOT_GIVEN, + auto_connect: float | NotGiven = NOT_GIVEN, + captive_portal: float | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + disable_auto_fallback: bool | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + exclude_office_ips: bool | NotGiven = NOT_GIVEN, + match: str | NotGiven = NOT_GIVEN, + name: str | NotGiven = NOT_GIVEN, + precedence: float | NotGiven = NOT_GIVEN, + service_mode_v2: custom_edit_params.ServiceModeV2 | NotGiven = NOT_GIVEN, + support_url: str | NotGiven = NOT_GIVEN, + switch_locked: bool | NotGiven = NOT_GIVEN, + tunnel_protocol: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[SettingsPolicy]: + """ + Updates a configured device settings profile. + + Args: + policy_id: Device ID. + + allow_mode_switch: Whether to allow the user to switch WARP between modes. + + allow_updates: Whether to receive update notifications when a new version of the client is + available. + + allowed_to_leave: Whether to allow devices to leave the organization. + + auto_connect: The amount of time in minutes to reconnect after having been disabled. + + captive_portal: Turn on the captive portal after the specified amount of time. + + description: A description of the policy. + + disable_auto_fallback: If the `dns_server` field of a fallback domain is not present, the client will + fall back to a best guess of the default/system DNS resolvers unless this policy + option is set to `true`. + + enabled: Whether the policy will be applied to matching devices. + + exclude_office_ips: Whether to add Microsoft IPs to Split Tunnel exclusions. + + match: The wirefilter expression to match devices. + + name: The name of the device settings profile. + + precedence: The precedence of the policy. Lower values indicate higher precedence. Policies + will be evaluated in ascending order of this field. + + support_url: The URL to launch when the Send Feedback button is clicked. + + switch_locked: Whether to allow the user to turn off the WARP switch and disconnect the client. + + tunnel_protocol: Determines which tunnel protocol to use. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not policy_id: + raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") + return self._patch( + f"/accounts/{account_id}/devices/policy/{policy_id}", + body=maybe_transform( + { + "allow_mode_switch": allow_mode_switch, + "allow_updates": allow_updates, + "allowed_to_leave": allowed_to_leave, + "auto_connect": auto_connect, + "captive_portal": captive_portal, + "description": description, + "disable_auto_fallback": disable_auto_fallback, + "enabled": enabled, + "exclude_office_ips": exclude_office_ips, + "match": match, + "name": name, + "precedence": precedence, + "service_mode_v2": service_mode_v2, + "support_url": support_url, + "switch_locked": switch_locked, + "tunnel_protocol": tunnel_protocol, + }, + custom_edit_params.CustomEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[SettingsPolicy]]._unwrapper, + ), + cast_to=cast(Type[Optional[SettingsPolicy]], ResultWrapper[SettingsPolicy]), + ) + + def get( + self, + policy_id: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[SettingsPolicy]: + """ + Fetches a device settings profile by ID. + + Args: + policy_id: Device ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not policy_id: + raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") + return self._get( + f"/accounts/{account_id}/devices/policy/{policy_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[SettingsPolicy]]._unwrapper, + ), + cast_to=cast(Type[Optional[SettingsPolicy]], ResultWrapper[SettingsPolicy]), + ) + + +class AsyncCustomResource(AsyncAPIResource): + @cached_property + def excludes(self) -> AsyncExcludesResource: + return AsyncExcludesResource(self._client) + + @cached_property + def includes(self) -> AsyncIncludesResource: + return AsyncIncludesResource(self._client) + + @cached_property + def fallback_domains(self) -> AsyncFallbackDomainsResource: + return AsyncFallbackDomainsResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncCustomResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return the + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncCustomResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncCustomResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncCustomResourceWithStreamingResponse(self) + + async def create( + self, + *, + account_id: str, + match: str, + name: str, + precedence: float, + allow_mode_switch: bool | NotGiven = NOT_GIVEN, + allow_updates: bool | NotGiven = NOT_GIVEN, + allowed_to_leave: bool | NotGiven = NOT_GIVEN, + auto_connect: float | NotGiven = NOT_GIVEN, + captive_portal: float | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + disable_auto_fallback: bool | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + exclude_office_ips: bool | NotGiven = NOT_GIVEN, + lan_allow_minutes: float | NotGiven = NOT_GIVEN, + lan_allow_subnet_size: float | NotGiven = NOT_GIVEN, + service_mode_v2: custom_create_params.ServiceModeV2 | NotGiven = NOT_GIVEN, + support_url: str | NotGiven = NOT_GIVEN, + switch_locked: bool | NotGiven = NOT_GIVEN, + tunnel_protocol: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[SettingsPolicy]: + """ + Creates a device settings profile to be applied to certain devices matching the + criteria. + + Args: + match: The wirefilter expression to match devices. + + name: The name of the device settings profile. + + precedence: The precedence of the policy. Lower values indicate higher precedence. Policies + will be evaluated in ascending order of this field. + + allow_mode_switch: Whether to allow the user to switch WARP between modes. + + allow_updates: Whether to receive update notifications when a new version of the client is + available. + + allowed_to_leave: Whether to allow devices to leave the organization. + + auto_connect: The amount of time in minutes to reconnect after having been disabled. + + captive_portal: Turn on the captive portal after the specified amount of time. + + description: A description of the policy. + + disable_auto_fallback: If the `dns_server` field of a fallback domain is not present, the client will + fall back to a best guess of the default/system DNS resolvers unless this policy + option is set to `true`. + + enabled: Whether the policy will be applied to matching devices. + + exclude_office_ips: Whether to add Microsoft IPs to Split Tunnel exclusions. + + lan_allow_minutes: The amount of time in minutes a user is allowed access to their LAN. A value of + 0 will allow LAN access until the next WARP reconnection, such as a reboot or a + laptop waking from sleep. Note that this field is omitted from the response if + null or unset. + + lan_allow_subnet_size: The size of the subnet for the local access network. Note that this field is + omitted from the response if null or unset. + + support_url: The URL to launch when the Send Feedback button is clicked. + + switch_locked: Whether to allow the user to turn off the WARP switch and disconnect the client. + + tunnel_protocol: Determines which tunnel protocol to use. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._post( + f"/accounts/{account_id}/devices/policy", + body=await async_maybe_transform( + { + "match": match, + "name": name, + "precedence": precedence, + "allow_mode_switch": allow_mode_switch, + "allow_updates": allow_updates, + "allowed_to_leave": allowed_to_leave, + "auto_connect": auto_connect, + "captive_portal": captive_portal, + "description": description, + "disable_auto_fallback": disable_auto_fallback, + "enabled": enabled, + "exclude_office_ips": exclude_office_ips, + "lan_allow_minutes": lan_allow_minutes, + "lan_allow_subnet_size": lan_allow_subnet_size, + "service_mode_v2": service_mode_v2, + "support_url": support_url, + "switch_locked": switch_locked, + "tunnel_protocol": tunnel_protocol, + }, + custom_create_params.CustomCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[SettingsPolicy]]._unwrapper, + ), + cast_to=cast(Type[Optional[SettingsPolicy]], ResultWrapper[SettingsPolicy]), + ) + + def list( + self, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> AsyncPaginator[SettingsPolicy, AsyncSinglePage[SettingsPolicy]]: + """ + Fetches a list of the device settings profiles for an account. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get_api_list( + f"/accounts/{account_id}/devices/policies", + page=AsyncSinglePage[SettingsPolicy], + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=SettingsPolicy, + ) + + async def delete( + self, + policy_id: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[CustomDeleteResponse]: + """ + Deletes a device settings profile and fetches a list of the remaining profiles + for an account. + + Args: + policy_id: Device ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not policy_id: + raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") + return await self._delete( + f"/accounts/{account_id}/devices/policy/{policy_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[CustomDeleteResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[CustomDeleteResponse]], ResultWrapper[CustomDeleteResponse]), + ) + + async def edit( + self, + policy_id: str, + *, + account_id: str, + allow_mode_switch: bool | NotGiven = NOT_GIVEN, + allow_updates: bool | NotGiven = NOT_GIVEN, + allowed_to_leave: bool | NotGiven = NOT_GIVEN, + auto_connect: float | NotGiven = NOT_GIVEN, + captive_portal: float | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + disable_auto_fallback: bool | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + exclude_office_ips: bool | NotGiven = NOT_GIVEN, + match: str | NotGiven = NOT_GIVEN, + name: str | NotGiven = NOT_GIVEN, + precedence: float | NotGiven = NOT_GIVEN, + service_mode_v2: custom_edit_params.ServiceModeV2 | NotGiven = NOT_GIVEN, + support_url: str | NotGiven = NOT_GIVEN, + switch_locked: bool | NotGiven = NOT_GIVEN, + tunnel_protocol: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[SettingsPolicy]: + """ + Updates a configured device settings profile. + + Args: + policy_id: Device ID. + + allow_mode_switch: Whether to allow the user to switch WARP between modes. + + allow_updates: Whether to receive update notifications when a new version of the client is + available. + + allowed_to_leave: Whether to allow devices to leave the organization. + + auto_connect: The amount of time in minutes to reconnect after having been disabled. + + captive_portal: Turn on the captive portal after the specified amount of time. + + description: A description of the policy. + + disable_auto_fallback: If the `dns_server` field of a fallback domain is not present, the client will + fall back to a best guess of the default/system DNS resolvers unless this policy + option is set to `true`. + + enabled: Whether the policy will be applied to matching devices. + + exclude_office_ips: Whether to add Microsoft IPs to Split Tunnel exclusions. + + match: The wirefilter expression to match devices. + + name: The name of the device settings profile. + + precedence: The precedence of the policy. Lower values indicate higher precedence. Policies + will be evaluated in ascending order of this field. + + support_url: The URL to launch when the Send Feedback button is clicked. + + switch_locked: Whether to allow the user to turn off the WARP switch and disconnect the client. + + tunnel_protocol: Determines which tunnel protocol to use. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not policy_id: + raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") + return await self._patch( + f"/accounts/{account_id}/devices/policy/{policy_id}", + body=await async_maybe_transform( + { + "allow_mode_switch": allow_mode_switch, + "allow_updates": allow_updates, + "allowed_to_leave": allowed_to_leave, + "auto_connect": auto_connect, + "captive_portal": captive_portal, + "description": description, + "disable_auto_fallback": disable_auto_fallback, + "enabled": enabled, + "exclude_office_ips": exclude_office_ips, + "match": match, + "name": name, + "precedence": precedence, + "service_mode_v2": service_mode_v2, + "support_url": support_url, + "switch_locked": switch_locked, + "tunnel_protocol": tunnel_protocol, + }, + custom_edit_params.CustomEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[SettingsPolicy]]._unwrapper, + ), + cast_to=cast(Type[Optional[SettingsPolicy]], ResultWrapper[SettingsPolicy]), + ) + + async def get( + self, + policy_id: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[SettingsPolicy]: + """ + Fetches a device settings profile by ID. + + Args: + policy_id: Device ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not policy_id: + raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") + return await self._get( + f"/accounts/{account_id}/devices/policy/{policy_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[SettingsPolicy]]._unwrapper, + ), + cast_to=cast(Type[Optional[SettingsPolicy]], ResultWrapper[SettingsPolicy]), + ) + + +class CustomResourceWithRawResponse: + def __init__(self, custom: CustomResource) -> None: + self._custom = custom + + self.create = to_raw_response_wrapper( + custom.create, + ) + self.list = to_raw_response_wrapper( + custom.list, + ) + self.delete = to_raw_response_wrapper( + custom.delete, + ) + self.edit = to_raw_response_wrapper( + custom.edit, + ) + self.get = to_raw_response_wrapper( + custom.get, + ) + + @cached_property + def excludes(self) -> ExcludesResourceWithRawResponse: + return ExcludesResourceWithRawResponse(self._custom.excludes) + + @cached_property + def includes(self) -> IncludesResourceWithRawResponse: + return IncludesResourceWithRawResponse(self._custom.includes) + + @cached_property + def fallback_domains(self) -> FallbackDomainsResourceWithRawResponse: + return FallbackDomainsResourceWithRawResponse(self._custom.fallback_domains) + + +class AsyncCustomResourceWithRawResponse: + def __init__(self, custom: AsyncCustomResource) -> None: + self._custom = custom + + self.create = async_to_raw_response_wrapper( + custom.create, + ) + self.list = async_to_raw_response_wrapper( + custom.list, + ) + self.delete = async_to_raw_response_wrapper( + custom.delete, + ) + self.edit = async_to_raw_response_wrapper( + custom.edit, + ) + self.get = async_to_raw_response_wrapper( + custom.get, + ) + + @cached_property + def excludes(self) -> AsyncExcludesResourceWithRawResponse: + return AsyncExcludesResourceWithRawResponse(self._custom.excludes) + + @cached_property + def includes(self) -> AsyncIncludesResourceWithRawResponse: + return AsyncIncludesResourceWithRawResponse(self._custom.includes) + + @cached_property + def fallback_domains(self) -> AsyncFallbackDomainsResourceWithRawResponse: + return AsyncFallbackDomainsResourceWithRawResponse(self._custom.fallback_domains) + + +class CustomResourceWithStreamingResponse: + def __init__(self, custom: CustomResource) -> None: + self._custom = custom + + self.create = to_streamed_response_wrapper( + custom.create, + ) + self.list = to_streamed_response_wrapper( + custom.list, + ) + self.delete = to_streamed_response_wrapper( + custom.delete, + ) + self.edit = to_streamed_response_wrapper( + custom.edit, + ) + self.get = to_streamed_response_wrapper( + custom.get, + ) + + @cached_property + def excludes(self) -> ExcludesResourceWithStreamingResponse: + return ExcludesResourceWithStreamingResponse(self._custom.excludes) + + @cached_property + def includes(self) -> IncludesResourceWithStreamingResponse: + return IncludesResourceWithStreamingResponse(self._custom.includes) + + @cached_property + def fallback_domains(self) -> FallbackDomainsResourceWithStreamingResponse: + return FallbackDomainsResourceWithStreamingResponse(self._custom.fallback_domains) + + +class AsyncCustomResourceWithStreamingResponse: + def __init__(self, custom: AsyncCustomResource) -> None: + self._custom = custom + + self.create = async_to_streamed_response_wrapper( + custom.create, + ) + self.list = async_to_streamed_response_wrapper( + custom.list, + ) + self.delete = async_to_streamed_response_wrapper( + custom.delete, + ) + self.edit = async_to_streamed_response_wrapper( + custom.edit, + ) + self.get = async_to_streamed_response_wrapper( + custom.get, + ) + + @cached_property + def excludes(self) -> AsyncExcludesResourceWithStreamingResponse: + return AsyncExcludesResourceWithStreamingResponse(self._custom.excludes) + + @cached_property + def includes(self) -> AsyncIncludesResourceWithStreamingResponse: + return AsyncIncludesResourceWithStreamingResponse(self._custom.includes) + + @cached_property + def fallback_domains(self) -> AsyncFallbackDomainsResourceWithStreamingResponse: + return AsyncFallbackDomainsResourceWithStreamingResponse(self._custom.fallback_domains) diff --git a/src/cloudflare/resources/zero_trust/devices/policies/excludes.py b/src/cloudflare/resources/zero_trust/devices/policies/custom/excludes.py similarity index 71% rename from src/cloudflare/resources/zero_trust/devices/policies/excludes.py rename to src/cloudflare/resources/zero_trust/devices/policies/custom/excludes.py index cb9f92f7693..5d8b3663ae4 100644 --- a/src/cloudflare/resources/zero_trust/devices/policies/excludes.py +++ b/src/cloudflare/resources/zero_trust/devices/policies/custom/excludes.py @@ -6,26 +6,24 @@ import httpx -from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ....._utils import ( +from ......_types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ......_utils import ( maybe_transform, async_maybe_transform, ) -from ....._compat import cached_property -from ....._resource import SyncAPIResource, AsyncAPIResource -from ....._response import ( +from ......_compat import cached_property +from ......_resource import SyncAPIResource, AsyncAPIResource +from ......_response import ( to_raw_response_wrapper, to_streamed_response_wrapper, async_to_raw_response_wrapper, async_to_streamed_response_wrapper, ) -from ....._wrappers import ResultWrapper -from .....pagination import SyncSinglePage, AsyncSinglePage -from ....._base_client import AsyncPaginator, make_request_options -from .....types.zero_trust.devices.policies.exclude_get_response import ExcludeGetResponse -from .....types.zero_trust.devices.policies.split_tunnel_exclude import SplitTunnelExclude -from .....types.zero_trust.devices.policies.exclude_update_response import ExcludeUpdateResponse -from .....types.zero_trust.devices.policies.split_tunnel_exclude_param import SplitTunnelExcludeParam +from ......_wrappers import ResultWrapper +from ......_base_client import make_request_options +from ......types.zero_trust.devices.split_tunnel_exclude_param import SplitTunnelExcludeParam +from ......types.zero_trust.devices.policies.custom.exclude_get_response import ExcludeGetResponse +from ......types.zero_trust.devices.policies.custom.exclude_update_response import ExcludeUpdateResponse __all__ = ["ExcludesResource", "AsyncExcludesResource"] @@ -52,6 +50,7 @@ def with_streaming_response(self) -> ExcludesResourceWithStreamingResponse: def update( self, + policy_id: str, *, account_id: str, body: Iterable[SplitTunnelExcludeParam], @@ -63,9 +62,12 @@ def update( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> Optional[ExcludeUpdateResponse]: """ - Sets the list of routes excluded from the WARP client's tunnel. + Sets the list of routes excluded from the WARP client's tunnel for a specific + device settings profile. Args: + policy_id: Device ID. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -76,8 +78,10 @@ def update( """ if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not policy_id: + raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") return self._put( - f"/accounts/{account_id}/devices/policy/exclude", + f"/accounts/{account_id}/devices/policy/{policy_id}/exclude", body=maybe_transform(body, Iterable[SplitTunnelExcludeParam]), options=make_request_options( extra_headers=extra_headers, @@ -89,40 +93,6 @@ def update( cast_to=cast(Type[Optional[ExcludeUpdateResponse]], ResultWrapper[ExcludeUpdateResponse]), ) - def list( - self, - *, - account_id: str, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncSinglePage[SplitTunnelExclude]: - """ - Fetches the list of routes excluded from the WARP client's tunnel. - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return self._get_api_list( - f"/accounts/{account_id}/devices/policy/exclude", - page=SyncSinglePage[SplitTunnelExclude], - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - model=SplitTunnelExclude, - ) - def get( self, policy_id: str, @@ -189,6 +159,7 @@ def with_streaming_response(self) -> AsyncExcludesResourceWithStreamingResponse: async def update( self, + policy_id: str, *, account_id: str, body: Iterable[SplitTunnelExcludeParam], @@ -200,9 +171,12 @@ async def update( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> Optional[ExcludeUpdateResponse]: """ - Sets the list of routes excluded from the WARP client's tunnel. + Sets the list of routes excluded from the WARP client's tunnel for a specific + device settings profile. Args: + policy_id: Device ID. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -213,8 +187,10 @@ async def update( """ if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not policy_id: + raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") return await self._put( - f"/accounts/{account_id}/devices/policy/exclude", + f"/accounts/{account_id}/devices/policy/{policy_id}/exclude", body=await async_maybe_transform(body, Iterable[SplitTunnelExcludeParam]), options=make_request_options( extra_headers=extra_headers, @@ -226,40 +202,6 @@ async def update( cast_to=cast(Type[Optional[ExcludeUpdateResponse]], ResultWrapper[ExcludeUpdateResponse]), ) - def list( - self, - *, - account_id: str, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[SplitTunnelExclude, AsyncSinglePage[SplitTunnelExclude]]: - """ - Fetches the list of routes excluded from the WARP client's tunnel. - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return self._get_api_list( - f"/accounts/{account_id}/devices/policy/exclude", - page=AsyncSinglePage[SplitTunnelExclude], - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - model=SplitTunnelExclude, - ) - async def get( self, policy_id: str, @@ -311,9 +253,6 @@ def __init__(self, excludes: ExcludesResource) -> None: self.update = to_raw_response_wrapper( excludes.update, ) - self.list = to_raw_response_wrapper( - excludes.list, - ) self.get = to_raw_response_wrapper( excludes.get, ) @@ -326,9 +265,6 @@ def __init__(self, excludes: AsyncExcludesResource) -> None: self.update = async_to_raw_response_wrapper( excludes.update, ) - self.list = async_to_raw_response_wrapper( - excludes.list, - ) self.get = async_to_raw_response_wrapper( excludes.get, ) @@ -341,9 +277,6 @@ def __init__(self, excludes: ExcludesResource) -> None: self.update = to_streamed_response_wrapper( excludes.update, ) - self.list = to_streamed_response_wrapper( - excludes.list, - ) self.get = to_streamed_response_wrapper( excludes.get, ) @@ -356,9 +289,6 @@ def __init__(self, excludes: AsyncExcludesResource) -> None: self.update = async_to_streamed_response_wrapper( excludes.update, ) - self.list = async_to_streamed_response_wrapper( - excludes.list, - ) self.get = async_to_streamed_response_wrapper( excludes.get, ) diff --git a/src/cloudflare/resources/zero_trust/devices/policies/fallback_domains.py b/src/cloudflare/resources/zero_trust/devices/policies/custom/fallback_domains.py similarity index 73% rename from src/cloudflare/resources/zero_trust/devices/policies/fallback_domains.py rename to src/cloudflare/resources/zero_trust/devices/policies/custom/fallback_domains.py index f8d0b089599..612fbb20dae 100644 --- a/src/cloudflare/resources/zero_trust/devices/policies/fallback_domains.py +++ b/src/cloudflare/resources/zero_trust/devices/policies/custom/fallback_domains.py @@ -6,26 +6,24 @@ import httpx -from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ....._utils import ( +from ......_types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ......_utils import ( maybe_transform, async_maybe_transform, ) -from ....._compat import cached_property -from ....._resource import SyncAPIResource, AsyncAPIResource -from ....._response import ( +from ......_compat import cached_property +from ......_resource import SyncAPIResource, AsyncAPIResource +from ......_response import ( to_raw_response_wrapper, to_streamed_response_wrapper, async_to_raw_response_wrapper, async_to_streamed_response_wrapper, ) -from ....._wrappers import ResultWrapper -from .....pagination import SyncSinglePage, AsyncSinglePage -from ....._base_client import AsyncPaginator, make_request_options -from .....types.zero_trust.devices.policies.fallback_domain import FallbackDomain -from .....types.zero_trust.devices.policies.fallback_domain_param import FallbackDomainParam -from .....types.zero_trust.devices.policies.fallback_domain_get_response import FallbackDomainGetResponse -from .....types.zero_trust.devices.policies.fallback_domain_update_response import FallbackDomainUpdateResponse +from ......_wrappers import ResultWrapper +from ......_base_client import make_request_options +from ......types.zero_trust.devices.fallback_domain_param import FallbackDomainParam +from ......types.zero_trust.devices.policies.custom.fallback_domain_get_response import FallbackDomainGetResponse +from ......types.zero_trust.devices.policies.custom.fallback_domain_update_response import FallbackDomainUpdateResponse __all__ = ["FallbackDomainsResource", "AsyncFallbackDomainsResource"] @@ -97,42 +95,6 @@ def update( cast_to=cast(Type[Optional[FallbackDomainUpdateResponse]], ResultWrapper[FallbackDomainUpdateResponse]), ) - def list( - self, - *, - account_id: str, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncSinglePage[FallbackDomain]: - """Fetches a list of domains to bypass Gateway DNS resolution. - - These domains will - use the specified local DNS resolver instead. - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return self._get_api_list( - f"/accounts/{account_id}/devices/policy/fallback_domains", - page=SyncSinglePage[FallbackDomain], - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - model=FallbackDomain, - ) - def get( self, policy_id: str, @@ -245,42 +207,6 @@ async def update( cast_to=cast(Type[Optional[FallbackDomainUpdateResponse]], ResultWrapper[FallbackDomainUpdateResponse]), ) - def list( - self, - *, - account_id: str, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[FallbackDomain, AsyncSinglePage[FallbackDomain]]: - """Fetches a list of domains to bypass Gateway DNS resolution. - - These domains will - use the specified local DNS resolver instead. - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return self._get_api_list( - f"/accounts/{account_id}/devices/policy/fallback_domains", - page=AsyncSinglePage[FallbackDomain], - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - model=FallbackDomain, - ) - async def get( self, policy_id: str, @@ -333,9 +259,6 @@ def __init__(self, fallback_domains: FallbackDomainsResource) -> None: self.update = to_raw_response_wrapper( fallback_domains.update, ) - self.list = to_raw_response_wrapper( - fallback_domains.list, - ) self.get = to_raw_response_wrapper( fallback_domains.get, ) @@ -348,9 +271,6 @@ def __init__(self, fallback_domains: AsyncFallbackDomainsResource) -> None: self.update = async_to_raw_response_wrapper( fallback_domains.update, ) - self.list = async_to_raw_response_wrapper( - fallback_domains.list, - ) self.get = async_to_raw_response_wrapper( fallback_domains.get, ) @@ -363,9 +283,6 @@ def __init__(self, fallback_domains: FallbackDomainsResource) -> None: self.update = to_streamed_response_wrapper( fallback_domains.update, ) - self.list = to_streamed_response_wrapper( - fallback_domains.list, - ) self.get = to_streamed_response_wrapper( fallback_domains.get, ) @@ -378,9 +295,6 @@ def __init__(self, fallback_domains: AsyncFallbackDomainsResource) -> None: self.update = async_to_streamed_response_wrapper( fallback_domains.update, ) - self.list = async_to_streamed_response_wrapper( - fallback_domains.list, - ) self.get = async_to_streamed_response_wrapper( fallback_domains.get, ) diff --git a/src/cloudflare/resources/zero_trust/devices/policies/includes.py b/src/cloudflare/resources/zero_trust/devices/policies/custom/includes.py similarity index 71% rename from src/cloudflare/resources/zero_trust/devices/policies/includes.py rename to src/cloudflare/resources/zero_trust/devices/policies/custom/includes.py index e60026ac3d1..3254afbe0cc 100644 --- a/src/cloudflare/resources/zero_trust/devices/policies/includes.py +++ b/src/cloudflare/resources/zero_trust/devices/policies/custom/includes.py @@ -6,26 +6,24 @@ import httpx -from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ....._utils import ( +from ......_types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ......_utils import ( maybe_transform, async_maybe_transform, ) -from ....._compat import cached_property -from ....._resource import SyncAPIResource, AsyncAPIResource -from ....._response import ( +from ......_compat import cached_property +from ......_resource import SyncAPIResource, AsyncAPIResource +from ......_response import ( to_raw_response_wrapper, to_streamed_response_wrapper, async_to_raw_response_wrapper, async_to_streamed_response_wrapper, ) -from ....._wrappers import ResultWrapper -from .....pagination import SyncSinglePage, AsyncSinglePage -from ....._base_client import AsyncPaginator, make_request_options -from .....types.zero_trust.devices.policies.include_get_response import IncludeGetResponse -from .....types.zero_trust.devices.policies.split_tunnel_include import SplitTunnelInclude -from .....types.zero_trust.devices.policies.include_update_response import IncludeUpdateResponse -from .....types.zero_trust.devices.policies.split_tunnel_include_param import SplitTunnelIncludeParam +from ......_wrappers import ResultWrapper +from ......_base_client import make_request_options +from ......types.zero_trust.devices.split_tunnel_include_param import SplitTunnelIncludeParam +from ......types.zero_trust.devices.policies.custom.include_get_response import IncludeGetResponse +from ......types.zero_trust.devices.policies.custom.include_update_response import IncludeUpdateResponse __all__ = ["IncludesResource", "AsyncIncludesResource"] @@ -52,6 +50,7 @@ def with_streaming_response(self) -> IncludesResourceWithStreamingResponse: def update( self, + policy_id: str, *, account_id: str, body: Iterable[SplitTunnelIncludeParam], @@ -63,9 +62,12 @@ def update( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> Optional[IncludeUpdateResponse]: """ - Sets the list of routes included in the WARP client's tunnel. + Sets the list of routes included in the WARP client's tunnel for a specific + device settings profile. Args: + policy_id: Device ID. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -76,8 +78,10 @@ def update( """ if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not policy_id: + raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") return self._put( - f"/accounts/{account_id}/devices/policy/include", + f"/accounts/{account_id}/devices/policy/{policy_id}/include", body=maybe_transform(body, Iterable[SplitTunnelIncludeParam]), options=make_request_options( extra_headers=extra_headers, @@ -89,40 +93,6 @@ def update( cast_to=cast(Type[Optional[IncludeUpdateResponse]], ResultWrapper[IncludeUpdateResponse]), ) - def list( - self, - *, - account_id: str, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncSinglePage[SplitTunnelInclude]: - """ - Fetches the list of routes included in the WARP client's tunnel. - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return self._get_api_list( - f"/accounts/{account_id}/devices/policy/include", - page=SyncSinglePage[SplitTunnelInclude], - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - model=SplitTunnelInclude, - ) - def get( self, policy_id: str, @@ -189,6 +159,7 @@ def with_streaming_response(self) -> AsyncIncludesResourceWithStreamingResponse: async def update( self, + policy_id: str, *, account_id: str, body: Iterable[SplitTunnelIncludeParam], @@ -200,9 +171,12 @@ async def update( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> Optional[IncludeUpdateResponse]: """ - Sets the list of routes included in the WARP client's tunnel. + Sets the list of routes included in the WARP client's tunnel for a specific + device settings profile. Args: + policy_id: Device ID. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -213,8 +187,10 @@ async def update( """ if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not policy_id: + raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") return await self._put( - f"/accounts/{account_id}/devices/policy/include", + f"/accounts/{account_id}/devices/policy/{policy_id}/include", body=await async_maybe_transform(body, Iterable[SplitTunnelIncludeParam]), options=make_request_options( extra_headers=extra_headers, @@ -226,40 +202,6 @@ async def update( cast_to=cast(Type[Optional[IncludeUpdateResponse]], ResultWrapper[IncludeUpdateResponse]), ) - def list( - self, - *, - account_id: str, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[SplitTunnelInclude, AsyncSinglePage[SplitTunnelInclude]]: - """ - Fetches the list of routes included in the WARP client's tunnel. - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return self._get_api_list( - f"/accounts/{account_id}/devices/policy/include", - page=AsyncSinglePage[SplitTunnelInclude], - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - model=SplitTunnelInclude, - ) - async def get( self, policy_id: str, @@ -311,9 +253,6 @@ def __init__(self, includes: IncludesResource) -> None: self.update = to_raw_response_wrapper( includes.update, ) - self.list = to_raw_response_wrapper( - includes.list, - ) self.get = to_raw_response_wrapper( includes.get, ) @@ -326,9 +265,6 @@ def __init__(self, includes: AsyncIncludesResource) -> None: self.update = async_to_raw_response_wrapper( includes.update, ) - self.list = async_to_raw_response_wrapper( - includes.list, - ) self.get = async_to_raw_response_wrapper( includes.get, ) @@ -341,9 +277,6 @@ def __init__(self, includes: IncludesResource) -> None: self.update = to_streamed_response_wrapper( includes.update, ) - self.list = to_streamed_response_wrapper( - includes.list, - ) self.get = to_streamed_response_wrapper( includes.get, ) @@ -356,9 +289,6 @@ def __init__(self, includes: AsyncIncludesResource) -> None: self.update = async_to_streamed_response_wrapper( includes.update, ) - self.list = async_to_streamed_response_wrapper( - includes.list, - ) self.get = async_to_streamed_response_wrapper( includes.get, ) diff --git a/src/cloudflare/resources/zero_trust/devices/policies/default/__init__.py b/src/cloudflare/resources/zero_trust/devices/policies/default/__init__.py new file mode 100644 index 00000000000..c22a715e1e2 --- /dev/null +++ b/src/cloudflare/resources/zero_trust/devices/policies/default/__init__.py @@ -0,0 +1,75 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .default import ( + DefaultResource, + AsyncDefaultResource, + DefaultResourceWithRawResponse, + AsyncDefaultResourceWithRawResponse, + DefaultResourceWithStreamingResponse, + AsyncDefaultResourceWithStreamingResponse, +) +from .excludes import ( + ExcludesResource, + AsyncExcludesResource, + ExcludesResourceWithRawResponse, + AsyncExcludesResourceWithRawResponse, + ExcludesResourceWithStreamingResponse, + AsyncExcludesResourceWithStreamingResponse, +) +from .includes import ( + IncludesResource, + AsyncIncludesResource, + IncludesResourceWithRawResponse, + AsyncIncludesResourceWithRawResponse, + IncludesResourceWithStreamingResponse, + AsyncIncludesResourceWithStreamingResponse, +) +from .certificates import ( + CertificatesResource, + AsyncCertificatesResource, + CertificatesResourceWithRawResponse, + AsyncCertificatesResourceWithRawResponse, + CertificatesResourceWithStreamingResponse, + AsyncCertificatesResourceWithStreamingResponse, +) +from .fallback_domains import ( + FallbackDomainsResource, + AsyncFallbackDomainsResource, + FallbackDomainsResourceWithRawResponse, + AsyncFallbackDomainsResourceWithRawResponse, + FallbackDomainsResourceWithStreamingResponse, + AsyncFallbackDomainsResourceWithStreamingResponse, +) + +__all__ = [ + "ExcludesResource", + "AsyncExcludesResource", + "ExcludesResourceWithRawResponse", + "AsyncExcludesResourceWithRawResponse", + "ExcludesResourceWithStreamingResponse", + "AsyncExcludesResourceWithStreamingResponse", + "IncludesResource", + "AsyncIncludesResource", + "IncludesResourceWithRawResponse", + "AsyncIncludesResourceWithRawResponse", + "IncludesResourceWithStreamingResponse", + "AsyncIncludesResourceWithStreamingResponse", + "FallbackDomainsResource", + "AsyncFallbackDomainsResource", + "FallbackDomainsResourceWithRawResponse", + "AsyncFallbackDomainsResourceWithRawResponse", + "FallbackDomainsResourceWithStreamingResponse", + "AsyncFallbackDomainsResourceWithStreamingResponse", + "CertificatesResource", + "AsyncCertificatesResource", + "CertificatesResourceWithRawResponse", + "AsyncCertificatesResourceWithRawResponse", + "CertificatesResourceWithStreamingResponse", + "AsyncCertificatesResourceWithStreamingResponse", + "DefaultResource", + "AsyncDefaultResource", + "DefaultResourceWithRawResponse", + "AsyncDefaultResourceWithRawResponse", + "DefaultResourceWithStreamingResponse", + "AsyncDefaultResourceWithStreamingResponse", +] diff --git a/src/cloudflare/resources/zero_trust/devices/policies/certificates.py b/src/cloudflare/resources/zero_trust/devices/policies/default/certificates.py old mode 100755 new mode 100644 similarity index 86% rename from src/cloudflare/resources/zero_trust/devices/policies/certificates.py rename to src/cloudflare/resources/zero_trust/devices/policies/default/certificates.py index 6f361f32938..d90227d8475 --- a/src/cloudflare/resources/zero_trust/devices/policies/certificates.py +++ b/src/cloudflare/resources/zero_trust/devices/policies/default/certificates.py @@ -6,24 +6,24 @@ import httpx -from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ....._utils import ( +from ......_types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ......_utils import ( maybe_transform, async_maybe_transform, ) -from ....._compat import cached_property -from ....._resource import SyncAPIResource, AsyncAPIResource -from ....._response import ( +from ......_compat import cached_property +from ......_resource import SyncAPIResource, AsyncAPIResource +from ......_response import ( to_raw_response_wrapper, to_streamed_response_wrapper, async_to_raw_response_wrapper, async_to_streamed_response_wrapper, ) -from ....._wrappers import ResultWrapper -from ....._base_client import make_request_options -from .....types.zero_trust.devices.policies import certificate_update_params -from .....types.zero_trust.devices.policies.certificate_get_response import CertificateGetResponse -from .....types.zero_trust.devices.policies.certificate_update_response import CertificateUpdateResponse +from ......_wrappers import ResultWrapper +from ......_base_client import make_request_options +from ......types.zero_trust.devices.policies.default import certificate_edit_params +from ......types.zero_trust.devices.policies.default.certificate_get_response import CertificateGetResponse +from ......types.zero_trust.devices.policies.default.certificate_edit_response import CertificateEditResponse __all__ = ["CertificatesResource", "AsyncCertificatesResource"] @@ -48,7 +48,7 @@ def with_streaming_response(self) -> CertificatesResourceWithStreamingResponse: """ return CertificatesResourceWithStreamingResponse(self) - def update( + def edit( self, zone_tag: str, *, @@ -59,7 +59,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> CertificateUpdateResponse: + ) -> CertificateEditResponse: """ Enable Zero Trust Clients to provision a certificate, containing a x509 subject, and referenced by Access device posture policies when the client visits MTLS @@ -80,19 +80,19 @@ def update( if not zone_tag: raise ValueError(f"Expected a non-empty value for `zone_tag` but received {zone_tag!r}") return cast( - CertificateUpdateResponse, + CertificateEditResponse, self._patch( f"/zones/{zone_tag}/devices/policy/certificates", - body=maybe_transform({"enabled": enabled}, certificate_update_params.CertificateUpdateParams), + body=maybe_transform({"enabled": enabled}, certificate_edit_params.CertificateEditParams), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[CertificateUpdateResponse]._unwrapper, + post_parser=ResultWrapper[CertificateEditResponse]._unwrapper, ), cast_to=cast( - Any, ResultWrapper[CertificateUpdateResponse] + Any, ResultWrapper[CertificateEditResponse] ), # Union types cannot be passed in as arguments in the type system ), ) @@ -160,7 +160,7 @@ def with_streaming_response(self) -> AsyncCertificatesResourceWithStreamingRespo """ return AsyncCertificatesResourceWithStreamingResponse(self) - async def update( + async def edit( self, zone_tag: str, *, @@ -171,7 +171,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> CertificateUpdateResponse: + ) -> CertificateEditResponse: """ Enable Zero Trust Clients to provision a certificate, containing a x509 subject, and referenced by Access device posture policies when the client visits MTLS @@ -192,21 +192,19 @@ async def update( if not zone_tag: raise ValueError(f"Expected a non-empty value for `zone_tag` but received {zone_tag!r}") return cast( - CertificateUpdateResponse, + CertificateEditResponse, await self._patch( f"/zones/{zone_tag}/devices/policy/certificates", - body=await async_maybe_transform( - {"enabled": enabled}, certificate_update_params.CertificateUpdateParams - ), + body=await async_maybe_transform({"enabled": enabled}, certificate_edit_params.CertificateEditParams), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[CertificateUpdateResponse]._unwrapper, + post_parser=ResultWrapper[CertificateEditResponse]._unwrapper, ), cast_to=cast( - Any, ResultWrapper[CertificateUpdateResponse] + Any, ResultWrapper[CertificateEditResponse] ), # Union types cannot be passed in as arguments in the type system ), ) @@ -258,8 +256,8 @@ class CertificatesResourceWithRawResponse: def __init__(self, certificates: CertificatesResource) -> None: self._certificates = certificates - self.update = to_raw_response_wrapper( - certificates.update, + self.edit = to_raw_response_wrapper( + certificates.edit, ) self.get = to_raw_response_wrapper( certificates.get, @@ -270,8 +268,8 @@ class AsyncCertificatesResourceWithRawResponse: def __init__(self, certificates: AsyncCertificatesResource) -> None: self._certificates = certificates - self.update = async_to_raw_response_wrapper( - certificates.update, + self.edit = async_to_raw_response_wrapper( + certificates.edit, ) self.get = async_to_raw_response_wrapper( certificates.get, @@ -282,8 +280,8 @@ class CertificatesResourceWithStreamingResponse: def __init__(self, certificates: CertificatesResource) -> None: self._certificates = certificates - self.update = to_streamed_response_wrapper( - certificates.update, + self.edit = to_streamed_response_wrapper( + certificates.edit, ) self.get = to_streamed_response_wrapper( certificates.get, @@ -294,8 +292,8 @@ class AsyncCertificatesResourceWithStreamingResponse: def __init__(self, certificates: AsyncCertificatesResource) -> None: self._certificates = certificates - self.update = async_to_streamed_response_wrapper( - certificates.update, + self.edit = async_to_streamed_response_wrapper( + certificates.edit, ) self.get = async_to_streamed_response_wrapper( certificates.get, diff --git a/src/cloudflare/resources/zero_trust/devices/policies/default/default.py b/src/cloudflare/resources/zero_trust/devices/policies/default/default.py new file mode 100644 index 00000000000..5c0f7e71e53 --- /dev/null +++ b/src/cloudflare/resources/zero_trust/devices/policies/default/default.py @@ -0,0 +1,494 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Optional, cast + +import httpx + +from .excludes import ( + ExcludesResource, + AsyncExcludesResource, + ExcludesResourceWithRawResponse, + AsyncExcludesResourceWithRawResponse, + ExcludesResourceWithStreamingResponse, + AsyncExcludesResourceWithStreamingResponse, +) +from .includes import ( + IncludesResource, + AsyncIncludesResource, + IncludesResourceWithRawResponse, + AsyncIncludesResourceWithRawResponse, + IncludesResourceWithStreamingResponse, + AsyncIncludesResourceWithStreamingResponse, +) +from ......_types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ......_utils import ( + maybe_transform, + async_maybe_transform, +) +from ......_compat import cached_property +from .certificates import ( + CertificatesResource, + AsyncCertificatesResource, + CertificatesResourceWithRawResponse, + AsyncCertificatesResourceWithRawResponse, + CertificatesResourceWithStreamingResponse, + AsyncCertificatesResourceWithStreamingResponse, +) +from ......_resource import SyncAPIResource, AsyncAPIResource +from ......_response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ......_wrappers import ResultWrapper +from .fallback_domains import ( + FallbackDomainsResource, + AsyncFallbackDomainsResource, + FallbackDomainsResourceWithRawResponse, + AsyncFallbackDomainsResourceWithRawResponse, + FallbackDomainsResourceWithStreamingResponse, + AsyncFallbackDomainsResourceWithStreamingResponse, +) +from ......_base_client import make_request_options +from ......types.zero_trust.devices.policies import default_edit_params +from ......types.zero_trust.devices.policies.default_get_response import DefaultGetResponse +from ......types.zero_trust.devices.policies.default_edit_response import DefaultEditResponse + +__all__ = ["DefaultResource", "AsyncDefaultResource"] + + +class DefaultResource(SyncAPIResource): + @cached_property + def excludes(self) -> ExcludesResource: + return ExcludesResource(self._client) + + @cached_property + def includes(self) -> IncludesResource: + return IncludesResource(self._client) + + @cached_property + def fallback_domains(self) -> FallbackDomainsResource: + return FallbackDomainsResource(self._client) + + @cached_property + def certificates(self) -> CertificatesResource: + return CertificatesResource(self._client) + + @cached_property + def with_raw_response(self) -> DefaultResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return the + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return DefaultResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> DefaultResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return DefaultResourceWithStreamingResponse(self) + + def edit( + self, + *, + account_id: str, + allow_mode_switch: bool | NotGiven = NOT_GIVEN, + allow_updates: bool | NotGiven = NOT_GIVEN, + allowed_to_leave: bool | NotGiven = NOT_GIVEN, + auto_connect: float | NotGiven = NOT_GIVEN, + captive_portal: float | NotGiven = NOT_GIVEN, + disable_auto_fallback: bool | NotGiven = NOT_GIVEN, + exclude_office_ips: bool | NotGiven = NOT_GIVEN, + service_mode_v2: default_edit_params.ServiceModeV2 | NotGiven = NOT_GIVEN, + support_url: str | NotGiven = NOT_GIVEN, + switch_locked: bool | NotGiven = NOT_GIVEN, + tunnel_protocol: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[DefaultEditResponse]: + """ + Updates the default device settings profile for an account. + + Args: + allow_mode_switch: Whether to allow the user to switch WARP between modes. + + allow_updates: Whether to receive update notifications when a new version of the client is + available. + + allowed_to_leave: Whether to allow devices to leave the organization. + + auto_connect: The amount of time in minutes to reconnect after having been disabled. + + captive_portal: Turn on the captive portal after the specified amount of time. + + disable_auto_fallback: If the `dns_server` field of a fallback domain is not present, the client will + fall back to a best guess of the default/system DNS resolvers unless this policy + option is set to `true`. + + exclude_office_ips: Whether to add Microsoft IPs to Split Tunnel exclusions. + + support_url: The URL to launch when the Send Feedback button is clicked. + + switch_locked: Whether to allow the user to turn off the WARP switch and disconnect the client. + + tunnel_protocol: Determines which tunnel protocol to use. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._patch( + f"/accounts/{account_id}/devices/policy", + body=maybe_transform( + { + "allow_mode_switch": allow_mode_switch, + "allow_updates": allow_updates, + "allowed_to_leave": allowed_to_leave, + "auto_connect": auto_connect, + "captive_portal": captive_portal, + "disable_auto_fallback": disable_auto_fallback, + "exclude_office_ips": exclude_office_ips, + "service_mode_v2": service_mode_v2, + "support_url": support_url, + "switch_locked": switch_locked, + "tunnel_protocol": tunnel_protocol, + }, + default_edit_params.DefaultEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[DefaultEditResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[DefaultEditResponse]], ResultWrapper[DefaultEditResponse]), + ) + + def get( + self, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[DefaultGetResponse]: + """ + Fetches the default device settings profile for an account. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get( + f"/accounts/{account_id}/devices/policy", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[DefaultGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[DefaultGetResponse]], ResultWrapper[DefaultGetResponse]), + ) + + +class AsyncDefaultResource(AsyncAPIResource): + @cached_property + def excludes(self) -> AsyncExcludesResource: + return AsyncExcludesResource(self._client) + + @cached_property + def includes(self) -> AsyncIncludesResource: + return AsyncIncludesResource(self._client) + + @cached_property + def fallback_domains(self) -> AsyncFallbackDomainsResource: + return AsyncFallbackDomainsResource(self._client) + + @cached_property + def certificates(self) -> AsyncCertificatesResource: + return AsyncCertificatesResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncDefaultResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return the + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncDefaultResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncDefaultResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncDefaultResourceWithStreamingResponse(self) + + async def edit( + self, + *, + account_id: str, + allow_mode_switch: bool | NotGiven = NOT_GIVEN, + allow_updates: bool | NotGiven = NOT_GIVEN, + allowed_to_leave: bool | NotGiven = NOT_GIVEN, + auto_connect: float | NotGiven = NOT_GIVEN, + captive_portal: float | NotGiven = NOT_GIVEN, + disable_auto_fallback: bool | NotGiven = NOT_GIVEN, + exclude_office_ips: bool | NotGiven = NOT_GIVEN, + service_mode_v2: default_edit_params.ServiceModeV2 | NotGiven = NOT_GIVEN, + support_url: str | NotGiven = NOT_GIVEN, + switch_locked: bool | NotGiven = NOT_GIVEN, + tunnel_protocol: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[DefaultEditResponse]: + """ + Updates the default device settings profile for an account. + + Args: + allow_mode_switch: Whether to allow the user to switch WARP between modes. + + allow_updates: Whether to receive update notifications when a new version of the client is + available. + + allowed_to_leave: Whether to allow devices to leave the organization. + + auto_connect: The amount of time in minutes to reconnect after having been disabled. + + captive_portal: Turn on the captive portal after the specified amount of time. + + disable_auto_fallback: If the `dns_server` field of a fallback domain is not present, the client will + fall back to a best guess of the default/system DNS resolvers unless this policy + option is set to `true`. + + exclude_office_ips: Whether to add Microsoft IPs to Split Tunnel exclusions. + + support_url: The URL to launch when the Send Feedback button is clicked. + + switch_locked: Whether to allow the user to turn off the WARP switch and disconnect the client. + + tunnel_protocol: Determines which tunnel protocol to use. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._patch( + f"/accounts/{account_id}/devices/policy", + body=await async_maybe_transform( + { + "allow_mode_switch": allow_mode_switch, + "allow_updates": allow_updates, + "allowed_to_leave": allowed_to_leave, + "auto_connect": auto_connect, + "captive_portal": captive_portal, + "disable_auto_fallback": disable_auto_fallback, + "exclude_office_ips": exclude_office_ips, + "service_mode_v2": service_mode_v2, + "support_url": support_url, + "switch_locked": switch_locked, + "tunnel_protocol": tunnel_protocol, + }, + default_edit_params.DefaultEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[DefaultEditResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[DefaultEditResponse]], ResultWrapper[DefaultEditResponse]), + ) + + async def get( + self, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[DefaultGetResponse]: + """ + Fetches the default device settings profile for an account. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._get( + f"/accounts/{account_id}/devices/policy", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[DefaultGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[DefaultGetResponse]], ResultWrapper[DefaultGetResponse]), + ) + + +class DefaultResourceWithRawResponse: + def __init__(self, default: DefaultResource) -> None: + self._default = default + + self.edit = to_raw_response_wrapper( + default.edit, + ) + self.get = to_raw_response_wrapper( + default.get, + ) + + @cached_property + def excludes(self) -> ExcludesResourceWithRawResponse: + return ExcludesResourceWithRawResponse(self._default.excludes) + + @cached_property + def includes(self) -> IncludesResourceWithRawResponse: + return IncludesResourceWithRawResponse(self._default.includes) + + @cached_property + def fallback_domains(self) -> FallbackDomainsResourceWithRawResponse: + return FallbackDomainsResourceWithRawResponse(self._default.fallback_domains) + + @cached_property + def certificates(self) -> CertificatesResourceWithRawResponse: + return CertificatesResourceWithRawResponse(self._default.certificates) + + +class AsyncDefaultResourceWithRawResponse: + def __init__(self, default: AsyncDefaultResource) -> None: + self._default = default + + self.edit = async_to_raw_response_wrapper( + default.edit, + ) + self.get = async_to_raw_response_wrapper( + default.get, + ) + + @cached_property + def excludes(self) -> AsyncExcludesResourceWithRawResponse: + return AsyncExcludesResourceWithRawResponse(self._default.excludes) + + @cached_property + def includes(self) -> AsyncIncludesResourceWithRawResponse: + return AsyncIncludesResourceWithRawResponse(self._default.includes) + + @cached_property + def fallback_domains(self) -> AsyncFallbackDomainsResourceWithRawResponse: + return AsyncFallbackDomainsResourceWithRawResponse(self._default.fallback_domains) + + @cached_property + def certificates(self) -> AsyncCertificatesResourceWithRawResponse: + return AsyncCertificatesResourceWithRawResponse(self._default.certificates) + + +class DefaultResourceWithStreamingResponse: + def __init__(self, default: DefaultResource) -> None: + self._default = default + + self.edit = to_streamed_response_wrapper( + default.edit, + ) + self.get = to_streamed_response_wrapper( + default.get, + ) + + @cached_property + def excludes(self) -> ExcludesResourceWithStreamingResponse: + return ExcludesResourceWithStreamingResponse(self._default.excludes) + + @cached_property + def includes(self) -> IncludesResourceWithStreamingResponse: + return IncludesResourceWithStreamingResponse(self._default.includes) + + @cached_property + def fallback_domains(self) -> FallbackDomainsResourceWithStreamingResponse: + return FallbackDomainsResourceWithStreamingResponse(self._default.fallback_domains) + + @cached_property + def certificates(self) -> CertificatesResourceWithStreamingResponse: + return CertificatesResourceWithStreamingResponse(self._default.certificates) + + +class AsyncDefaultResourceWithStreamingResponse: + def __init__(self, default: AsyncDefaultResource) -> None: + self._default = default + + self.edit = async_to_streamed_response_wrapper( + default.edit, + ) + self.get = async_to_streamed_response_wrapper( + default.get, + ) + + @cached_property + def excludes(self) -> AsyncExcludesResourceWithStreamingResponse: + return AsyncExcludesResourceWithStreamingResponse(self._default.excludes) + + @cached_property + def includes(self) -> AsyncIncludesResourceWithStreamingResponse: + return AsyncIncludesResourceWithStreamingResponse(self._default.includes) + + @cached_property + def fallback_domains(self) -> AsyncFallbackDomainsResourceWithStreamingResponse: + return AsyncFallbackDomainsResourceWithStreamingResponse(self._default.fallback_domains) + + @cached_property + def certificates(self) -> AsyncCertificatesResourceWithStreamingResponse: + return AsyncCertificatesResourceWithStreamingResponse(self._default.certificates) diff --git a/src/cloudflare/resources/zero_trust/devices/policies/default/excludes.py b/src/cloudflare/resources/zero_trust/devices/policies/default/excludes.py new file mode 100644 index 00000000000..802eaf9a62a --- /dev/null +++ b/src/cloudflare/resources/zero_trust/devices/policies/default/excludes.py @@ -0,0 +1,270 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Iterable, Optional, cast + +import httpx + +from ......_types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ......_utils import ( + maybe_transform, + async_maybe_transform, +) +from ......_compat import cached_property +from ......_resource import SyncAPIResource, AsyncAPIResource +from ......_response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ......_wrappers import ResultWrapper +from ......_base_client import make_request_options +from ......types.zero_trust.devices.split_tunnel_exclude_param import SplitTunnelExcludeParam +from ......types.zero_trust.devices.policies.default.exclude_get_response import ExcludeGetResponse +from ......types.zero_trust.devices.policies.default.exclude_update_response import ExcludeUpdateResponse + +__all__ = ["ExcludesResource", "AsyncExcludesResource"] + + +class ExcludesResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> ExcludesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return the + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return ExcludesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ExcludesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return ExcludesResourceWithStreamingResponse(self) + + def update( + self, + *, + account_id: str, + body: Iterable[SplitTunnelExcludeParam], + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[ExcludeUpdateResponse]: + """ + Sets the list of routes excluded from the WARP client's tunnel. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._put( + f"/accounts/{account_id}/devices/policy/exclude", + body=maybe_transform(body, Iterable[SplitTunnelExcludeParam]), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ExcludeUpdateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[ExcludeUpdateResponse]], ResultWrapper[ExcludeUpdateResponse]), + ) + + def get( + self, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[ExcludeGetResponse]: + """ + Fetches the list of routes excluded from the WARP client's tunnel. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get( + f"/accounts/{account_id}/devices/policy/exclude", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ExcludeGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[ExcludeGetResponse]], ResultWrapper[ExcludeGetResponse]), + ) + + +class AsyncExcludesResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncExcludesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return the + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncExcludesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncExcludesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncExcludesResourceWithStreamingResponse(self) + + async def update( + self, + *, + account_id: str, + body: Iterable[SplitTunnelExcludeParam], + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[ExcludeUpdateResponse]: + """ + Sets the list of routes excluded from the WARP client's tunnel. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._put( + f"/accounts/{account_id}/devices/policy/exclude", + body=await async_maybe_transform(body, Iterable[SplitTunnelExcludeParam]), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ExcludeUpdateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[ExcludeUpdateResponse]], ResultWrapper[ExcludeUpdateResponse]), + ) + + async def get( + self, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[ExcludeGetResponse]: + """ + Fetches the list of routes excluded from the WARP client's tunnel. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._get( + f"/accounts/{account_id}/devices/policy/exclude", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[ExcludeGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[ExcludeGetResponse]], ResultWrapper[ExcludeGetResponse]), + ) + + +class ExcludesResourceWithRawResponse: + def __init__(self, excludes: ExcludesResource) -> None: + self._excludes = excludes + + self.update = to_raw_response_wrapper( + excludes.update, + ) + self.get = to_raw_response_wrapper( + excludes.get, + ) + + +class AsyncExcludesResourceWithRawResponse: + def __init__(self, excludes: AsyncExcludesResource) -> None: + self._excludes = excludes + + self.update = async_to_raw_response_wrapper( + excludes.update, + ) + self.get = async_to_raw_response_wrapper( + excludes.get, + ) + + +class ExcludesResourceWithStreamingResponse: + def __init__(self, excludes: ExcludesResource) -> None: + self._excludes = excludes + + self.update = to_streamed_response_wrapper( + excludes.update, + ) + self.get = to_streamed_response_wrapper( + excludes.get, + ) + + +class AsyncExcludesResourceWithStreamingResponse: + def __init__(self, excludes: AsyncExcludesResource) -> None: + self._excludes = excludes + + self.update = async_to_streamed_response_wrapper( + excludes.update, + ) + self.get = async_to_streamed_response_wrapper( + excludes.get, + ) diff --git a/src/cloudflare/resources/zero_trust/devices/policies/default/fallback_domains.py b/src/cloudflare/resources/zero_trust/devices/policies/default/fallback_domains.py new file mode 100644 index 00000000000..8ad04e35ea1 --- /dev/null +++ b/src/cloudflare/resources/zero_trust/devices/policies/default/fallback_domains.py @@ -0,0 +1,278 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Iterable, Optional, cast + +import httpx + +from ......_types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ......_utils import ( + maybe_transform, + async_maybe_transform, +) +from ......_compat import cached_property +from ......_resource import SyncAPIResource, AsyncAPIResource +from ......_response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ......_wrappers import ResultWrapper +from ......_base_client import make_request_options +from ......types.zero_trust.devices.fallback_domain_param import FallbackDomainParam +from ......types.zero_trust.devices.policies.default.fallback_domain_get_response import FallbackDomainGetResponse +from ......types.zero_trust.devices.policies.default.fallback_domain_update_response import FallbackDomainUpdateResponse + +__all__ = ["FallbackDomainsResource", "AsyncFallbackDomainsResource"] + + +class FallbackDomainsResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> FallbackDomainsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return the + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return FallbackDomainsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> FallbackDomainsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return FallbackDomainsResourceWithStreamingResponse(self) + + def update( + self, + *, + account_id: str, + domains: Iterable[FallbackDomainParam], + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[FallbackDomainUpdateResponse]: + """Sets the list of domains to bypass Gateway DNS resolution. + + These domains will + use the specified local DNS resolver instead. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._put( + f"/accounts/{account_id}/devices/policy/fallback_domains", + body=maybe_transform(domains, Iterable[FallbackDomainParam]), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[FallbackDomainUpdateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[FallbackDomainUpdateResponse]], ResultWrapper[FallbackDomainUpdateResponse]), + ) + + def get( + self, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[FallbackDomainGetResponse]: + """Fetches a list of domains to bypass Gateway DNS resolution. + + These domains will + use the specified local DNS resolver instead. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get( + f"/accounts/{account_id}/devices/policy/fallback_domains", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[FallbackDomainGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[FallbackDomainGetResponse]], ResultWrapper[FallbackDomainGetResponse]), + ) + + +class AsyncFallbackDomainsResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncFallbackDomainsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return the + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncFallbackDomainsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncFallbackDomainsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncFallbackDomainsResourceWithStreamingResponse(self) + + async def update( + self, + *, + account_id: str, + domains: Iterable[FallbackDomainParam], + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[FallbackDomainUpdateResponse]: + """Sets the list of domains to bypass Gateway DNS resolution. + + These domains will + use the specified local DNS resolver instead. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._put( + f"/accounts/{account_id}/devices/policy/fallback_domains", + body=await async_maybe_transform(domains, Iterable[FallbackDomainParam]), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[FallbackDomainUpdateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[FallbackDomainUpdateResponse]], ResultWrapper[FallbackDomainUpdateResponse]), + ) + + async def get( + self, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[FallbackDomainGetResponse]: + """Fetches a list of domains to bypass Gateway DNS resolution. + + These domains will + use the specified local DNS resolver instead. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._get( + f"/accounts/{account_id}/devices/policy/fallback_domains", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[FallbackDomainGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[FallbackDomainGetResponse]], ResultWrapper[FallbackDomainGetResponse]), + ) + + +class FallbackDomainsResourceWithRawResponse: + def __init__(self, fallback_domains: FallbackDomainsResource) -> None: + self._fallback_domains = fallback_domains + + self.update = to_raw_response_wrapper( + fallback_domains.update, + ) + self.get = to_raw_response_wrapper( + fallback_domains.get, + ) + + +class AsyncFallbackDomainsResourceWithRawResponse: + def __init__(self, fallback_domains: AsyncFallbackDomainsResource) -> None: + self._fallback_domains = fallback_domains + + self.update = async_to_raw_response_wrapper( + fallback_domains.update, + ) + self.get = async_to_raw_response_wrapper( + fallback_domains.get, + ) + + +class FallbackDomainsResourceWithStreamingResponse: + def __init__(self, fallback_domains: FallbackDomainsResource) -> None: + self._fallback_domains = fallback_domains + + self.update = to_streamed_response_wrapper( + fallback_domains.update, + ) + self.get = to_streamed_response_wrapper( + fallback_domains.get, + ) + + +class AsyncFallbackDomainsResourceWithStreamingResponse: + def __init__(self, fallback_domains: AsyncFallbackDomainsResource) -> None: + self._fallback_domains = fallback_domains + + self.update = async_to_streamed_response_wrapper( + fallback_domains.update, + ) + self.get = async_to_streamed_response_wrapper( + fallback_domains.get, + ) diff --git a/src/cloudflare/resources/zero_trust/devices/policies/default/includes.py b/src/cloudflare/resources/zero_trust/devices/policies/default/includes.py new file mode 100644 index 00000000000..d8383257476 --- /dev/null +++ b/src/cloudflare/resources/zero_trust/devices/policies/default/includes.py @@ -0,0 +1,270 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Iterable, Optional, cast + +import httpx + +from ......_types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ......_utils import ( + maybe_transform, + async_maybe_transform, +) +from ......_compat import cached_property +from ......_resource import SyncAPIResource, AsyncAPIResource +from ......_response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ......_wrappers import ResultWrapper +from ......_base_client import make_request_options +from ......types.zero_trust.devices.split_tunnel_include_param import SplitTunnelIncludeParam +from ......types.zero_trust.devices.policies.default.include_get_response import IncludeGetResponse +from ......types.zero_trust.devices.policies.default.include_update_response import IncludeUpdateResponse + +__all__ = ["IncludesResource", "AsyncIncludesResource"] + + +class IncludesResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> IncludesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return the + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return IncludesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> IncludesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return IncludesResourceWithStreamingResponse(self) + + def update( + self, + *, + account_id: str, + body: Iterable[SplitTunnelIncludeParam], + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[IncludeUpdateResponse]: + """ + Sets the list of routes included in the WARP client's tunnel. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._put( + f"/accounts/{account_id}/devices/policy/include", + body=maybe_transform(body, Iterable[SplitTunnelIncludeParam]), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[IncludeUpdateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[IncludeUpdateResponse]], ResultWrapper[IncludeUpdateResponse]), + ) + + def get( + self, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[IncludeGetResponse]: + """ + Fetches the list of routes included in the WARP client's tunnel. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return self._get( + f"/accounts/{account_id}/devices/policy/include", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[IncludeGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[IncludeGetResponse]], ResultWrapper[IncludeGetResponse]), + ) + + +class AsyncIncludesResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncIncludesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return the + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncIncludesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncIncludesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncIncludesResourceWithStreamingResponse(self) + + async def update( + self, + *, + account_id: str, + body: Iterable[SplitTunnelIncludeParam], + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[IncludeUpdateResponse]: + """ + Sets the list of routes included in the WARP client's tunnel. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._put( + f"/accounts/{account_id}/devices/policy/include", + body=await async_maybe_transform(body, Iterable[SplitTunnelIncludeParam]), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[IncludeUpdateResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[IncludeUpdateResponse]], ResultWrapper[IncludeUpdateResponse]), + ) + + async def get( + self, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[IncludeGetResponse]: + """ + Fetches the list of routes included in the WARP client's tunnel. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + return await self._get( + f"/accounts/{account_id}/devices/policy/include", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[IncludeGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[IncludeGetResponse]], ResultWrapper[IncludeGetResponse]), + ) + + +class IncludesResourceWithRawResponse: + def __init__(self, includes: IncludesResource) -> None: + self._includes = includes + + self.update = to_raw_response_wrapper( + includes.update, + ) + self.get = to_raw_response_wrapper( + includes.get, + ) + + +class AsyncIncludesResourceWithRawResponse: + def __init__(self, includes: AsyncIncludesResource) -> None: + self._includes = includes + + self.update = async_to_raw_response_wrapper( + includes.update, + ) + self.get = async_to_raw_response_wrapper( + includes.get, + ) + + +class IncludesResourceWithStreamingResponse: + def __init__(self, includes: IncludesResource) -> None: + self._includes = includes + + self.update = to_streamed_response_wrapper( + includes.update, + ) + self.get = to_streamed_response_wrapper( + includes.get, + ) + + +class AsyncIncludesResourceWithStreamingResponse: + def __init__(self, includes: AsyncIncludesResource) -> None: + self._includes = includes + + self.update = async_to_streamed_response_wrapper( + includes.update, + ) + self.get = async_to_streamed_response_wrapper( + includes.get, + ) diff --git a/src/cloudflare/resources/zero_trust/devices/policies/default_policy.py b/src/cloudflare/resources/zero_trust/devices/policies/default_policy.py deleted file mode 100644 index ffbae56c820..00000000000 --- a/src/cloudflare/resources/zero_trust/devices/policies/default_policy.py +++ /dev/null @@ -1,174 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Type, Optional, cast - -import httpx - -from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ....._compat import cached_property -from ....._resource import SyncAPIResource, AsyncAPIResource -from ....._response import ( - to_raw_response_wrapper, - to_streamed_response_wrapper, - async_to_raw_response_wrapper, - async_to_streamed_response_wrapper, -) -from ....._wrappers import ResultWrapper -from ....._base_client import make_request_options -from .....types.zero_trust.devices.policies.default_policy_get_response import DefaultPolicyGetResponse - -__all__ = ["DefaultPolicyResource", "AsyncDefaultPolicyResource"] - - -class DefaultPolicyResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> DefaultPolicyResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return the - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers - """ - return DefaultPolicyResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> DefaultPolicyResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response - """ - return DefaultPolicyResourceWithStreamingResponse(self) - - def get( - self, - *, - account_id: str, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[DefaultPolicyGetResponse]: - """ - Fetches the default device settings profile for an account. - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return self._get( - f"/accounts/{account_id}/devices/policy", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[DefaultPolicyGetResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[DefaultPolicyGetResponse]], ResultWrapper[DefaultPolicyGetResponse]), - ) - - -class AsyncDefaultPolicyResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncDefaultPolicyResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return the - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers - """ - return AsyncDefaultPolicyResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncDefaultPolicyResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response - """ - return AsyncDefaultPolicyResourceWithStreamingResponse(self) - - async def get( - self, - *, - account_id: str, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[DefaultPolicyGetResponse]: - """ - Fetches the default device settings profile for an account. - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return await self._get( - f"/accounts/{account_id}/devices/policy", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[DefaultPolicyGetResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[DefaultPolicyGetResponse]], ResultWrapper[DefaultPolicyGetResponse]), - ) - - -class DefaultPolicyResourceWithRawResponse: - def __init__(self, default_policy: DefaultPolicyResource) -> None: - self._default_policy = default_policy - - self.get = to_raw_response_wrapper( - default_policy.get, - ) - - -class AsyncDefaultPolicyResourceWithRawResponse: - def __init__(self, default_policy: AsyncDefaultPolicyResource) -> None: - self._default_policy = default_policy - - self.get = async_to_raw_response_wrapper( - default_policy.get, - ) - - -class DefaultPolicyResourceWithStreamingResponse: - def __init__(self, default_policy: DefaultPolicyResource) -> None: - self._default_policy = default_policy - - self.get = to_streamed_response_wrapper( - default_policy.get, - ) - - -class AsyncDefaultPolicyResourceWithStreamingResponse: - def __init__(self, default_policy: AsyncDefaultPolicyResource) -> None: - self._default_policy = default_policy - - self.get = async_to_streamed_response_wrapper( - default_policy.get, - ) diff --git a/src/cloudflare/resources/zero_trust/devices/policies/policies.py b/src/cloudflare/resources/zero_trust/devices/policies/policies.py index 4464fb1f4ce..5a0511a4ac6 100644 --- a/src/cloudflare/resources/zero_trust/devices/policies/policies.py +++ b/src/cloudflare/resources/zero_trust/devices/policies/policies.py @@ -2,93 +2,38 @@ from __future__ import annotations -from typing import Type, Optional, cast - -import httpx - -from .excludes import ( - ExcludesResource, - AsyncExcludesResource, - ExcludesResourceWithRawResponse, - AsyncExcludesResourceWithRawResponse, - ExcludesResourceWithStreamingResponse, - AsyncExcludesResourceWithStreamingResponse, -) -from .includes import ( - IncludesResource, - AsyncIncludesResource, - IncludesResourceWithRawResponse, - AsyncIncludesResourceWithRawResponse, - IncludesResourceWithStreamingResponse, - AsyncIncludesResourceWithStreamingResponse, +from .custom import ( + CustomResource, + AsyncCustomResource, + CustomResourceWithRawResponse, + AsyncCustomResourceWithRawResponse, + CustomResourceWithStreamingResponse, + AsyncCustomResourceWithStreamingResponse, ) -from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ....._utils import ( - maybe_transform, - async_maybe_transform, +from .default import ( + DefaultResource, + AsyncDefaultResource, + DefaultResourceWithRawResponse, + AsyncDefaultResourceWithRawResponse, + DefaultResourceWithStreamingResponse, + AsyncDefaultResourceWithStreamingResponse, ) from ....._compat import cached_property -from .certificates import ( - CertificatesResource, - AsyncCertificatesResource, - CertificatesResourceWithRawResponse, - AsyncCertificatesResourceWithRawResponse, - CertificatesResourceWithStreamingResponse, - AsyncCertificatesResourceWithStreamingResponse, -) from ....._resource import SyncAPIResource, AsyncAPIResource -from ....._response import ( - to_raw_response_wrapper, - to_streamed_response_wrapper, - async_to_raw_response_wrapper, - async_to_streamed_response_wrapper, -) -from ....._wrappers import ResultWrapper -from .....pagination import SyncSinglePage, AsyncSinglePage -from .default_policy import ( - DefaultPolicyResource, - AsyncDefaultPolicyResource, - DefaultPolicyResourceWithRawResponse, - AsyncDefaultPolicyResourceWithRawResponse, - DefaultPolicyResourceWithStreamingResponse, - AsyncDefaultPolicyResourceWithStreamingResponse, -) -from ....._base_client import AsyncPaginator, make_request_options -from .fallback_domains import ( - FallbackDomainsResource, - AsyncFallbackDomainsResource, - FallbackDomainsResourceWithRawResponse, - AsyncFallbackDomainsResourceWithRawResponse, - FallbackDomainsResourceWithStreamingResponse, - AsyncFallbackDomainsResourceWithStreamingResponse, -) -from .....types.zero_trust.devices import policy_edit_params, policy_create_params -from .....types.zero_trust.devices.settings_policy import SettingsPolicy -from .....types.zero_trust.devices.policy_delete_response import PolicyDeleteResponse +from .custom.custom import CustomResource, AsyncCustomResource +from .default.default import DefaultResource, AsyncDefaultResource __all__ = ["PoliciesResource", "AsyncPoliciesResource"] class PoliciesResource(SyncAPIResource): @cached_property - def certificates(self) -> CertificatesResource: - return CertificatesResource(self._client) - - @cached_property - def default_policy(self) -> DefaultPolicyResource: - return DefaultPolicyResource(self._client) + def default(self) -> DefaultResource: + return DefaultResource(self._client) @cached_property - def excludes(self) -> ExcludesResource: - return ExcludesResource(self._client) - - @cached_property - def fallback_domains(self) -> FallbackDomainsResource: - return FallbackDomainsResource(self._client) - - @cached_property - def includes(self) -> IncludesResource: - return IncludesResource(self._client) + def custom(self) -> CustomResource: + return CustomResource(self._client) @cached_property def with_raw_response(self) -> PoliciesResourceWithRawResponse: @@ -109,380 +54,15 @@ def with_streaming_response(self) -> PoliciesResourceWithStreamingResponse: """ return PoliciesResourceWithStreamingResponse(self) - def create( - self, - *, - account_id: str, - match: str, - name: str, - precedence: float, - allow_mode_switch: bool | NotGiven = NOT_GIVEN, - allow_updates: bool | NotGiven = NOT_GIVEN, - allowed_to_leave: bool | NotGiven = NOT_GIVEN, - auto_connect: float | NotGiven = NOT_GIVEN, - captive_portal: float | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - disable_auto_fallback: bool | NotGiven = NOT_GIVEN, - enabled: bool | NotGiven = NOT_GIVEN, - exclude_office_ips: bool | NotGiven = NOT_GIVEN, - lan_allow_minutes: float | NotGiven = NOT_GIVEN, - lan_allow_subnet_size: float | NotGiven = NOT_GIVEN, - service_mode_v2: policy_create_params.ServiceModeV2 | NotGiven = NOT_GIVEN, - support_url: str | NotGiven = NOT_GIVEN, - switch_locked: bool | NotGiven = NOT_GIVEN, - tunnel_protocol: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[SettingsPolicy]: - """ - Creates a device settings profile to be applied to certain devices matching the - criteria. - - Args: - match: The wirefilter expression to match devices. - - name: The name of the device settings profile. - - precedence: The precedence of the policy. Lower values indicate higher precedence. Policies - will be evaluated in ascending order of this field. - - allow_mode_switch: Whether to allow the user to switch WARP between modes. - - allow_updates: Whether to receive update notifications when a new version of the client is - available. - - allowed_to_leave: Whether to allow devices to leave the organization. - - auto_connect: The amount of time in minutes to reconnect after having been disabled. - - captive_portal: Turn on the captive portal after the specified amount of time. - - description: A description of the policy. - - disable_auto_fallback: If the `dns_server` field of a fallback domain is not present, the client will - fall back to a best guess of the default/system DNS resolvers unless this policy - option is set to `true`. - - enabled: Whether the policy will be applied to matching devices. - - exclude_office_ips: Whether to add Microsoft IPs to Split Tunnel exclusions. - - lan_allow_minutes: The amount of time in minutes a user is allowed access to their LAN. A value of - 0 will allow LAN access until the next WARP reconnection, such as a reboot or a - laptop waking from sleep. Note that this field is omitted from the response if - null or unset. - - lan_allow_subnet_size: The size of the subnet for the local access network. Note that this field is - omitted from the response if null or unset. - - support_url: The URL to launch when the Send Feedback button is clicked. - - switch_locked: Whether to allow the user to turn off the WARP switch and disconnect the client. - - tunnel_protocol: Determines which tunnel protocol to use. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return self._post( - f"/accounts/{account_id}/devices/policy", - body=maybe_transform( - { - "match": match, - "name": name, - "precedence": precedence, - "allow_mode_switch": allow_mode_switch, - "allow_updates": allow_updates, - "allowed_to_leave": allowed_to_leave, - "auto_connect": auto_connect, - "captive_portal": captive_portal, - "description": description, - "disable_auto_fallback": disable_auto_fallback, - "enabled": enabled, - "exclude_office_ips": exclude_office_ips, - "lan_allow_minutes": lan_allow_minutes, - "lan_allow_subnet_size": lan_allow_subnet_size, - "service_mode_v2": service_mode_v2, - "support_url": support_url, - "switch_locked": switch_locked, - "tunnel_protocol": tunnel_protocol, - }, - policy_create_params.PolicyCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[SettingsPolicy]]._unwrapper, - ), - cast_to=cast(Type[Optional[SettingsPolicy]], ResultWrapper[SettingsPolicy]), - ) - - def list( - self, - *, - account_id: str, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncSinglePage[SettingsPolicy]: - """ - Fetches a list of the device settings profiles for an account. - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return self._get_api_list( - f"/accounts/{account_id}/devices/policies", - page=SyncSinglePage[SettingsPolicy], - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - model=SettingsPolicy, - ) - - def delete( - self, - policy_id: str, - *, - account_id: str, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[PolicyDeleteResponse]: - """ - Deletes a device settings profile and fetches a list of the remaining profiles - for an account. - - Args: - policy_id: Device ID. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not policy_id: - raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") - return self._delete( - f"/accounts/{account_id}/devices/policy/{policy_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[PolicyDeleteResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[PolicyDeleteResponse]], ResultWrapper[PolicyDeleteResponse]), - ) - - def edit( - self, - policy_id: str, - *, - account_id: str, - allow_mode_switch: bool | NotGiven = NOT_GIVEN, - allow_updates: bool | NotGiven = NOT_GIVEN, - allowed_to_leave: bool | NotGiven = NOT_GIVEN, - auto_connect: float | NotGiven = NOT_GIVEN, - captive_portal: float | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - disable_auto_fallback: bool | NotGiven = NOT_GIVEN, - enabled: bool | NotGiven = NOT_GIVEN, - exclude_office_ips: bool | NotGiven = NOT_GIVEN, - match: str | NotGiven = NOT_GIVEN, - name: str | NotGiven = NOT_GIVEN, - precedence: float | NotGiven = NOT_GIVEN, - service_mode_v2: policy_edit_params.ServiceModeV2 | NotGiven = NOT_GIVEN, - support_url: str | NotGiven = NOT_GIVEN, - switch_locked: bool | NotGiven = NOT_GIVEN, - tunnel_protocol: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[SettingsPolicy]: - """ - Updates a configured device settings profile. - - Args: - policy_id: Device ID. - - allow_mode_switch: Whether to allow the user to switch WARP between modes. - - allow_updates: Whether to receive update notifications when a new version of the client is - available. - - allowed_to_leave: Whether to allow devices to leave the organization. - - auto_connect: The amount of time in minutes to reconnect after having been disabled. - - captive_portal: Turn on the captive portal after the specified amount of time. - - description: A description of the policy. - - disable_auto_fallback: If the `dns_server` field of a fallback domain is not present, the client will - fall back to a best guess of the default/system DNS resolvers unless this policy - option is set to `true`. - - enabled: Whether the policy will be applied to matching devices. - - exclude_office_ips: Whether to add Microsoft IPs to Split Tunnel exclusions. - - match: The wirefilter expression to match devices. - - name: The name of the device settings profile. - - precedence: The precedence of the policy. Lower values indicate higher precedence. Policies - will be evaluated in ascending order of this field. - - support_url: The URL to launch when the Send Feedback button is clicked. - - switch_locked: Whether to allow the user to turn off the WARP switch and disconnect the client. - - tunnel_protocol: Determines which tunnel protocol to use. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not policy_id: - raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") - return self._patch( - f"/accounts/{account_id}/devices/policy/{policy_id}", - body=maybe_transform( - { - "allow_mode_switch": allow_mode_switch, - "allow_updates": allow_updates, - "allowed_to_leave": allowed_to_leave, - "auto_connect": auto_connect, - "captive_portal": captive_portal, - "description": description, - "disable_auto_fallback": disable_auto_fallback, - "enabled": enabled, - "exclude_office_ips": exclude_office_ips, - "match": match, - "name": name, - "precedence": precedence, - "service_mode_v2": service_mode_v2, - "support_url": support_url, - "switch_locked": switch_locked, - "tunnel_protocol": tunnel_protocol, - }, - policy_edit_params.PolicyEditParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[SettingsPolicy]]._unwrapper, - ), - cast_to=cast(Type[Optional[SettingsPolicy]], ResultWrapper[SettingsPolicy]), - ) - - def get( - self, - policy_id: str, - *, - account_id: str, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[SettingsPolicy]: - """ - Fetches a device settings profile by ID. - - Args: - policy_id: Device ID. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not policy_id: - raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") - return self._get( - f"/accounts/{account_id}/devices/policy/{policy_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[SettingsPolicy]]._unwrapper, - ), - cast_to=cast(Type[Optional[SettingsPolicy]], ResultWrapper[SettingsPolicy]), - ) - class AsyncPoliciesResource(AsyncAPIResource): @cached_property - def certificates(self) -> AsyncCertificatesResource: - return AsyncCertificatesResource(self._client) + def default(self) -> AsyncDefaultResource: + return AsyncDefaultResource(self._client) @cached_property - def default_policy(self) -> AsyncDefaultPolicyResource: - return AsyncDefaultPolicyResource(self._client) - - @cached_property - def excludes(self) -> AsyncExcludesResource: - return AsyncExcludesResource(self._client) - - @cached_property - def fallback_domains(self) -> AsyncFallbackDomainsResource: - return AsyncFallbackDomainsResource(self._client) - - @cached_property - def includes(self) -> AsyncIncludesResource: - return AsyncIncludesResource(self._client) + def custom(self) -> AsyncCustomResource: + return AsyncCustomResource(self._client) @cached_property def with_raw_response(self) -> AsyncPoliciesResourceWithRawResponse: @@ -503,519 +83,54 @@ def with_streaming_response(self) -> AsyncPoliciesResourceWithStreamingResponse: """ return AsyncPoliciesResourceWithStreamingResponse(self) - async def create( - self, - *, - account_id: str, - match: str, - name: str, - precedence: float, - allow_mode_switch: bool | NotGiven = NOT_GIVEN, - allow_updates: bool | NotGiven = NOT_GIVEN, - allowed_to_leave: bool | NotGiven = NOT_GIVEN, - auto_connect: float | NotGiven = NOT_GIVEN, - captive_portal: float | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - disable_auto_fallback: bool | NotGiven = NOT_GIVEN, - enabled: bool | NotGiven = NOT_GIVEN, - exclude_office_ips: bool | NotGiven = NOT_GIVEN, - lan_allow_minutes: float | NotGiven = NOT_GIVEN, - lan_allow_subnet_size: float | NotGiven = NOT_GIVEN, - service_mode_v2: policy_create_params.ServiceModeV2 | NotGiven = NOT_GIVEN, - support_url: str | NotGiven = NOT_GIVEN, - switch_locked: bool | NotGiven = NOT_GIVEN, - tunnel_protocol: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[SettingsPolicy]: - """ - Creates a device settings profile to be applied to certain devices matching the - criteria. - - Args: - match: The wirefilter expression to match devices. - - name: The name of the device settings profile. - - precedence: The precedence of the policy. Lower values indicate higher precedence. Policies - will be evaluated in ascending order of this field. - - allow_mode_switch: Whether to allow the user to switch WARP between modes. - - allow_updates: Whether to receive update notifications when a new version of the client is - available. - - allowed_to_leave: Whether to allow devices to leave the organization. - - auto_connect: The amount of time in minutes to reconnect after having been disabled. - - captive_portal: Turn on the captive portal after the specified amount of time. - - description: A description of the policy. - - disable_auto_fallback: If the `dns_server` field of a fallback domain is not present, the client will - fall back to a best guess of the default/system DNS resolvers unless this policy - option is set to `true`. - - enabled: Whether the policy will be applied to matching devices. - - exclude_office_ips: Whether to add Microsoft IPs to Split Tunnel exclusions. - - lan_allow_minutes: The amount of time in minutes a user is allowed access to their LAN. A value of - 0 will allow LAN access until the next WARP reconnection, such as a reboot or a - laptop waking from sleep. Note that this field is omitted from the response if - null or unset. - - lan_allow_subnet_size: The size of the subnet for the local access network. Note that this field is - omitted from the response if null or unset. - - support_url: The URL to launch when the Send Feedback button is clicked. - - switch_locked: Whether to allow the user to turn off the WARP switch and disconnect the client. - - tunnel_protocol: Determines which tunnel protocol to use. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return await self._post( - f"/accounts/{account_id}/devices/policy", - body=await async_maybe_transform( - { - "match": match, - "name": name, - "precedence": precedence, - "allow_mode_switch": allow_mode_switch, - "allow_updates": allow_updates, - "allowed_to_leave": allowed_to_leave, - "auto_connect": auto_connect, - "captive_portal": captive_portal, - "description": description, - "disable_auto_fallback": disable_auto_fallback, - "enabled": enabled, - "exclude_office_ips": exclude_office_ips, - "lan_allow_minutes": lan_allow_minutes, - "lan_allow_subnet_size": lan_allow_subnet_size, - "service_mode_v2": service_mode_v2, - "support_url": support_url, - "switch_locked": switch_locked, - "tunnel_protocol": tunnel_protocol, - }, - policy_create_params.PolicyCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[SettingsPolicy]]._unwrapper, - ), - cast_to=cast(Type[Optional[SettingsPolicy]], ResultWrapper[SettingsPolicy]), - ) - - def list( - self, - *, - account_id: str, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[SettingsPolicy, AsyncSinglePage[SettingsPolicy]]: - """ - Fetches a list of the device settings profiles for an account. - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return self._get_api_list( - f"/accounts/{account_id}/devices/policies", - page=AsyncSinglePage[SettingsPolicy], - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - model=SettingsPolicy, - ) - - async def delete( - self, - policy_id: str, - *, - account_id: str, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[PolicyDeleteResponse]: - """ - Deletes a device settings profile and fetches a list of the remaining profiles - for an account. - - Args: - policy_id: Device ID. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not policy_id: - raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") - return await self._delete( - f"/accounts/{account_id}/devices/policy/{policy_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[PolicyDeleteResponse]]._unwrapper, - ), - cast_to=cast(Type[Optional[PolicyDeleteResponse]], ResultWrapper[PolicyDeleteResponse]), - ) - - async def edit( - self, - policy_id: str, - *, - account_id: str, - allow_mode_switch: bool | NotGiven = NOT_GIVEN, - allow_updates: bool | NotGiven = NOT_GIVEN, - allowed_to_leave: bool | NotGiven = NOT_GIVEN, - auto_connect: float | NotGiven = NOT_GIVEN, - captive_portal: float | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - disable_auto_fallback: bool | NotGiven = NOT_GIVEN, - enabled: bool | NotGiven = NOT_GIVEN, - exclude_office_ips: bool | NotGiven = NOT_GIVEN, - match: str | NotGiven = NOT_GIVEN, - name: str | NotGiven = NOT_GIVEN, - precedence: float | NotGiven = NOT_GIVEN, - service_mode_v2: policy_edit_params.ServiceModeV2 | NotGiven = NOT_GIVEN, - support_url: str | NotGiven = NOT_GIVEN, - switch_locked: bool | NotGiven = NOT_GIVEN, - tunnel_protocol: str | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[SettingsPolicy]: - """ - Updates a configured device settings profile. - - Args: - policy_id: Device ID. - - allow_mode_switch: Whether to allow the user to switch WARP between modes. - - allow_updates: Whether to receive update notifications when a new version of the client is - available. - - allowed_to_leave: Whether to allow devices to leave the organization. - - auto_connect: The amount of time in minutes to reconnect after having been disabled. - - captive_portal: Turn on the captive portal after the specified amount of time. - - description: A description of the policy. - - disable_auto_fallback: If the `dns_server` field of a fallback domain is not present, the client will - fall back to a best guess of the default/system DNS resolvers unless this policy - option is set to `true`. - - enabled: Whether the policy will be applied to matching devices. - - exclude_office_ips: Whether to add Microsoft IPs to Split Tunnel exclusions. - - match: The wirefilter expression to match devices. - - name: The name of the device settings profile. - - precedence: The precedence of the policy. Lower values indicate higher precedence. Policies - will be evaluated in ascending order of this field. - - support_url: The URL to launch when the Send Feedback button is clicked. - - switch_locked: Whether to allow the user to turn off the WARP switch and disconnect the client. - - tunnel_protocol: Determines which tunnel protocol to use. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not policy_id: - raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") - return await self._patch( - f"/accounts/{account_id}/devices/policy/{policy_id}", - body=await async_maybe_transform( - { - "allow_mode_switch": allow_mode_switch, - "allow_updates": allow_updates, - "allowed_to_leave": allowed_to_leave, - "auto_connect": auto_connect, - "captive_portal": captive_portal, - "description": description, - "disable_auto_fallback": disable_auto_fallback, - "enabled": enabled, - "exclude_office_ips": exclude_office_ips, - "match": match, - "name": name, - "precedence": precedence, - "service_mode_v2": service_mode_v2, - "support_url": support_url, - "switch_locked": switch_locked, - "tunnel_protocol": tunnel_protocol, - }, - policy_edit_params.PolicyEditParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[SettingsPolicy]]._unwrapper, - ), - cast_to=cast(Type[Optional[SettingsPolicy]], ResultWrapper[SettingsPolicy]), - ) - - async def get( - self, - policy_id: str, - *, - account_id: str, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[SettingsPolicy]: - """ - Fetches a device settings profile by ID. - - Args: - policy_id: Device ID. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not policy_id: - raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") - return await self._get( - f"/accounts/{account_id}/devices/policy/{policy_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[Optional[SettingsPolicy]]._unwrapper, - ), - cast_to=cast(Type[Optional[SettingsPolicy]], ResultWrapper[SettingsPolicy]), - ) - class PoliciesResourceWithRawResponse: def __init__(self, policies: PoliciesResource) -> None: self._policies = policies - self.create = to_raw_response_wrapper( - policies.create, - ) - self.list = to_raw_response_wrapper( - policies.list, - ) - self.delete = to_raw_response_wrapper( - policies.delete, - ) - self.edit = to_raw_response_wrapper( - policies.edit, - ) - self.get = to_raw_response_wrapper( - policies.get, - ) - - @cached_property - def certificates(self) -> CertificatesResourceWithRawResponse: - return CertificatesResourceWithRawResponse(self._policies.certificates) - - @cached_property - def default_policy(self) -> DefaultPolicyResourceWithRawResponse: - return DefaultPolicyResourceWithRawResponse(self._policies.default_policy) - - @cached_property - def excludes(self) -> ExcludesResourceWithRawResponse: - return ExcludesResourceWithRawResponse(self._policies.excludes) - @cached_property - def fallback_domains(self) -> FallbackDomainsResourceWithRawResponse: - return FallbackDomainsResourceWithRawResponse(self._policies.fallback_domains) + def default(self) -> DefaultResourceWithRawResponse: + return DefaultResourceWithRawResponse(self._policies.default) @cached_property - def includes(self) -> IncludesResourceWithRawResponse: - return IncludesResourceWithRawResponse(self._policies.includes) + def custom(self) -> CustomResourceWithRawResponse: + return CustomResourceWithRawResponse(self._policies.custom) class AsyncPoliciesResourceWithRawResponse: def __init__(self, policies: AsyncPoliciesResource) -> None: self._policies = policies - self.create = async_to_raw_response_wrapper( - policies.create, - ) - self.list = async_to_raw_response_wrapper( - policies.list, - ) - self.delete = async_to_raw_response_wrapper( - policies.delete, - ) - self.edit = async_to_raw_response_wrapper( - policies.edit, - ) - self.get = async_to_raw_response_wrapper( - policies.get, - ) - - @cached_property - def certificates(self) -> AsyncCertificatesResourceWithRawResponse: - return AsyncCertificatesResourceWithRawResponse(self._policies.certificates) - @cached_property - def default_policy(self) -> AsyncDefaultPolicyResourceWithRawResponse: - return AsyncDefaultPolicyResourceWithRawResponse(self._policies.default_policy) + def default(self) -> AsyncDefaultResourceWithRawResponse: + return AsyncDefaultResourceWithRawResponse(self._policies.default) @cached_property - def excludes(self) -> AsyncExcludesResourceWithRawResponse: - return AsyncExcludesResourceWithRawResponse(self._policies.excludes) - - @cached_property - def fallback_domains(self) -> AsyncFallbackDomainsResourceWithRawResponse: - return AsyncFallbackDomainsResourceWithRawResponse(self._policies.fallback_domains) - - @cached_property - def includes(self) -> AsyncIncludesResourceWithRawResponse: - return AsyncIncludesResourceWithRawResponse(self._policies.includes) + def custom(self) -> AsyncCustomResourceWithRawResponse: + return AsyncCustomResourceWithRawResponse(self._policies.custom) class PoliciesResourceWithStreamingResponse: def __init__(self, policies: PoliciesResource) -> None: self._policies = policies - self.create = to_streamed_response_wrapper( - policies.create, - ) - self.list = to_streamed_response_wrapper( - policies.list, - ) - self.delete = to_streamed_response_wrapper( - policies.delete, - ) - self.edit = to_streamed_response_wrapper( - policies.edit, - ) - self.get = to_streamed_response_wrapper( - policies.get, - ) - - @cached_property - def certificates(self) -> CertificatesResourceWithStreamingResponse: - return CertificatesResourceWithStreamingResponse(self._policies.certificates) - @cached_property - def default_policy(self) -> DefaultPolicyResourceWithStreamingResponse: - return DefaultPolicyResourceWithStreamingResponse(self._policies.default_policy) + def default(self) -> DefaultResourceWithStreamingResponse: + return DefaultResourceWithStreamingResponse(self._policies.default) @cached_property - def excludes(self) -> ExcludesResourceWithStreamingResponse: - return ExcludesResourceWithStreamingResponse(self._policies.excludes) - - @cached_property - def fallback_domains(self) -> FallbackDomainsResourceWithStreamingResponse: - return FallbackDomainsResourceWithStreamingResponse(self._policies.fallback_domains) - - @cached_property - def includes(self) -> IncludesResourceWithStreamingResponse: - return IncludesResourceWithStreamingResponse(self._policies.includes) + def custom(self) -> CustomResourceWithStreamingResponse: + return CustomResourceWithStreamingResponse(self._policies.custom) class AsyncPoliciesResourceWithStreamingResponse: def __init__(self, policies: AsyncPoliciesResource) -> None: self._policies = policies - self.create = async_to_streamed_response_wrapper( - policies.create, - ) - self.list = async_to_streamed_response_wrapper( - policies.list, - ) - self.delete = async_to_streamed_response_wrapper( - policies.delete, - ) - self.edit = async_to_streamed_response_wrapper( - policies.edit, - ) - self.get = async_to_streamed_response_wrapper( - policies.get, - ) - - @cached_property - def certificates(self) -> AsyncCertificatesResourceWithStreamingResponse: - return AsyncCertificatesResourceWithStreamingResponse(self._policies.certificates) - - @cached_property - def default_policy(self) -> AsyncDefaultPolicyResourceWithStreamingResponse: - return AsyncDefaultPolicyResourceWithStreamingResponse(self._policies.default_policy) - - @cached_property - def excludes(self) -> AsyncExcludesResourceWithStreamingResponse: - return AsyncExcludesResourceWithStreamingResponse(self._policies.excludes) - @cached_property - def fallback_domains(self) -> AsyncFallbackDomainsResourceWithStreamingResponse: - return AsyncFallbackDomainsResourceWithStreamingResponse(self._policies.fallback_domains) + def default(self) -> AsyncDefaultResourceWithStreamingResponse: + return AsyncDefaultResourceWithStreamingResponse(self._policies.default) @cached_property - def includes(self) -> AsyncIncludesResourceWithStreamingResponse: - return AsyncIncludesResourceWithStreamingResponse(self._policies.includes) + def custom(self) -> AsyncCustomResourceWithStreamingResponse: + return AsyncCustomResourceWithStreamingResponse(self._policies.custom) diff --git a/src/cloudflare/types/zero_trust/devices/__init__.py b/src/cloudflare/types/zero_trust/devices/__init__.py index 2ff931fdcc1..831df46d499 100644 --- a/src/cloudflare/types/zero_trust/devices/__init__.py +++ b/src/cloudflare/types/zero_trust/devices/__init__.py @@ -13,6 +13,7 @@ from .device_network import DeviceNetwork as DeviceNetwork from .firewall_input import FirewallInput as FirewallInput from .device_settings import DeviceSettings as DeviceSettings +from .fallback_domain import FallbackDomain as FallbackDomain from .settings_policy import SettingsPolicy as SettingsPolicy from .file_input_param import FileInputParam as FileInputParam from .os_version_input import OSVersionInput as OSVersionInput @@ -24,16 +25,17 @@ from .device_match_param import DeviceMatchParam as DeviceMatchParam from .intune_input_param import IntuneInputParam as IntuneInputParam from .kolide_input_param import KolideInputParam as KolideInputParam -from .policy_edit_params import PolicyEditParams as PolicyEditParams from .tanium_input_param import TaniumInputParam as TaniumInputParam from .device_posture_rule import DevicePostureRule as DevicePostureRule from .domain_joined_input import DomainJoinedInput as DomainJoinedInput from .setting_edit_params import SettingEditParams as SettingEditParams from .workspace_one_input import WorkspaceOneInput as WorkspaceOneInput from .firewall_input_param import FirewallInputParam as FirewallInputParam -from .policy_create_params import PolicyCreateParams as PolicyCreateParams from .revoke_create_params import RevokeCreateParams as RevokeCreateParams +from .split_tunnel_exclude import SplitTunnelExclude as SplitTunnelExclude +from .split_tunnel_include import SplitTunnelInclude as SplitTunnelInclude from .disk_encryption_input import DiskEncryptionInput as DiskEncryptionInput +from .fallback_domain_param import FallbackDomainParam as FallbackDomainParam from .network_create_params import NetworkCreateParams as NetworkCreateParams from .network_update_params import NetworkUpdateParams as NetworkUpdateParams from .posture_create_params import PostureCreateParams as PostureCreateParams @@ -43,7 +45,6 @@ from .dex_test_create_params import DEXTestCreateParams as DEXTestCreateParams from .dex_test_update_params import DEXTestUpdateParams as DEXTestUpdateParams from .os_version_input_param import OSVersionInputParam as OSVersionInputParam -from .policy_delete_response import PolicyDeleteResponse as PolicyDeleteResponse from .revoke_create_response import RevokeCreateResponse as RevokeCreateResponse from .unique_client_id_input import UniqueClientIDInput as UniqueClientIDInput from .unrevoke_create_params import UnrevokeCreateParams as UnrevokeCreateParams @@ -56,6 +57,8 @@ from .unrevoke_create_response import UnrevokeCreateResponse as UnrevokeCreateResponse from .domain_joined_input_param import DomainJoinedInputParam as DomainJoinedInputParam from .workspace_one_input_param import WorkspaceOneInputParam as WorkspaceOneInputParam +from .split_tunnel_exclude_param import SplitTunnelExcludeParam as SplitTunnelExcludeParam +from .split_tunnel_include_param import SplitTunnelIncludeParam as SplitTunnelIncludeParam from .disk_encryption_input_param import DiskEncryptionInputParam as DiskEncryptionInputParam from .override_code_list_response import OverrideCodeListResponse as OverrideCodeListResponse from .sentinelone_s2s_input_param import SentineloneS2sInputParam as SentineloneS2sInputParam diff --git a/src/cloudflare/types/zero_trust/devices/policies/fallback_domain.py b/src/cloudflare/types/zero_trust/devices/fallback_domain.py similarity index 93% rename from src/cloudflare/types/zero_trust/devices/policies/fallback_domain.py rename to src/cloudflare/types/zero_trust/devices/fallback_domain.py index 34d20ff9bb0..4ae2c3f4f73 100644 --- a/src/cloudflare/types/zero_trust/devices/policies/fallback_domain.py +++ b/src/cloudflare/types/zero_trust/devices/fallback_domain.py @@ -2,7 +2,7 @@ from typing import List, Optional -from ....._models import BaseModel +from ...._models import BaseModel __all__ = ["FallbackDomain"] diff --git a/src/cloudflare/types/zero_trust/devices/policies/fallback_domain_param.py b/src/cloudflare/types/zero_trust/devices/fallback_domain_param.py similarity index 100% rename from src/cloudflare/types/zero_trust/devices/policies/fallback_domain_param.py rename to src/cloudflare/types/zero_trust/devices/fallback_domain_param.py diff --git a/src/cloudflare/types/zero_trust/devices/policies/__init__.py b/src/cloudflare/types/zero_trust/devices/policies/__init__.py index ef7fe7d5157..7fd6acb2f1f 100644 --- a/src/cloudflare/types/zero_trust/devices/policies/__init__.py +++ b/src/cloudflare/types/zero_trust/devices/policies/__init__.py @@ -2,22 +2,9 @@ from __future__ import annotations -from .fallback_domain import FallbackDomain as FallbackDomain -from .exclude_get_response import ExcludeGetResponse as ExcludeGetResponse -from .include_get_response import IncludeGetResponse as IncludeGetResponse -from .split_tunnel_exclude import SplitTunnelExclude as SplitTunnelExclude -from .split_tunnel_include import SplitTunnelInclude as SplitTunnelInclude -from .exclude_update_params import ExcludeUpdateParams as ExcludeUpdateParams -from .fallback_domain_param import FallbackDomainParam as FallbackDomainParam -from .include_update_params import IncludeUpdateParams as IncludeUpdateParams -from .exclude_update_response import ExcludeUpdateResponse as ExcludeUpdateResponse -from .include_update_response import IncludeUpdateResponse as IncludeUpdateResponse -from .certificate_get_response import CertificateGetResponse as CertificateGetResponse -from .certificate_update_params import CertificateUpdateParams as CertificateUpdateParams -from .split_tunnel_exclude_param import SplitTunnelExcludeParam as SplitTunnelExcludeParam -from .split_tunnel_include_param import SplitTunnelIncludeParam as SplitTunnelIncludeParam -from .certificate_update_response import CertificateUpdateResponse as CertificateUpdateResponse -from .default_policy_get_response import DefaultPolicyGetResponse as DefaultPolicyGetResponse -from .fallback_domain_get_response import FallbackDomainGetResponse as FallbackDomainGetResponse -from .fallback_domain_update_params import FallbackDomainUpdateParams as FallbackDomainUpdateParams -from .fallback_domain_update_response import FallbackDomainUpdateResponse as FallbackDomainUpdateResponse +from .custom_edit_params import CustomEditParams as CustomEditParams +from .default_edit_params import DefaultEditParams as DefaultEditParams +from .custom_create_params import CustomCreateParams as CustomCreateParams +from .default_get_response import DefaultGetResponse as DefaultGetResponse +from .default_edit_response import DefaultEditResponse as DefaultEditResponse +from .custom_delete_response import CustomDeleteResponse as CustomDeleteResponse diff --git a/src/cloudflare/types/zero_trust/devices/policies/custom/__init__.py b/src/cloudflare/types/zero_trust/devices/policies/custom/__init__.py new file mode 100644 index 00000000000..cb8c3df70ca --- /dev/null +++ b/src/cloudflare/types/zero_trust/devices/policies/custom/__init__.py @@ -0,0 +1,13 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .exclude_get_response import ExcludeGetResponse as ExcludeGetResponse +from .include_get_response import IncludeGetResponse as IncludeGetResponse +from .exclude_update_params import ExcludeUpdateParams as ExcludeUpdateParams +from .include_update_params import IncludeUpdateParams as IncludeUpdateParams +from .exclude_update_response import ExcludeUpdateResponse as ExcludeUpdateResponse +from .include_update_response import IncludeUpdateResponse as IncludeUpdateResponse +from .fallback_domain_get_response import FallbackDomainGetResponse as FallbackDomainGetResponse +from .fallback_domain_update_params import FallbackDomainUpdateParams as FallbackDomainUpdateParams +from .fallback_domain_update_response import FallbackDomainUpdateResponse as FallbackDomainUpdateResponse diff --git a/src/cloudflare/types/zero_trust/devices/policies/exclude_get_response.py b/src/cloudflare/types/zero_trust/devices/policies/custom/exclude_get_response.py similarity index 81% rename from src/cloudflare/types/zero_trust/devices/policies/exclude_get_response.py rename to src/cloudflare/types/zero_trust/devices/policies/custom/exclude_get_response.py index e256e773581..58d2e0f96e4 100644 --- a/src/cloudflare/types/zero_trust/devices/policies/exclude_get_response.py +++ b/src/cloudflare/types/zero_trust/devices/policies/custom/exclude_get_response.py @@ -3,7 +3,7 @@ from typing import List from typing_extensions import TypeAlias -from .split_tunnel_exclude import SplitTunnelExclude +from ...split_tunnel_exclude import SplitTunnelExclude __all__ = ["ExcludeGetResponse"] diff --git a/src/cloudflare/types/zero_trust/devices/policies/exclude_update_params.py b/src/cloudflare/types/zero_trust/devices/policies/custom/exclude_update_params.py similarity index 85% rename from src/cloudflare/types/zero_trust/devices/policies/exclude_update_params.py rename to src/cloudflare/types/zero_trust/devices/policies/custom/exclude_update_params.py index 21ac467a9eb..3bdc54c4c9f 100644 --- a/src/cloudflare/types/zero_trust/devices/policies/exclude_update_params.py +++ b/src/cloudflare/types/zero_trust/devices/policies/custom/exclude_update_params.py @@ -5,7 +5,7 @@ from typing import Iterable from typing_extensions import Required, TypedDict -from .split_tunnel_exclude_param import SplitTunnelExcludeParam +from ...split_tunnel_exclude_param import SplitTunnelExcludeParam __all__ = ["ExcludeUpdateParams"] diff --git a/src/cloudflare/types/zero_trust/devices/policies/exclude_update_response.py b/src/cloudflare/types/zero_trust/devices/policies/custom/exclude_update_response.py similarity index 81% rename from src/cloudflare/types/zero_trust/devices/policies/exclude_update_response.py rename to src/cloudflare/types/zero_trust/devices/policies/custom/exclude_update_response.py index 9559d948739..bfafca3ec0a 100644 --- a/src/cloudflare/types/zero_trust/devices/policies/exclude_update_response.py +++ b/src/cloudflare/types/zero_trust/devices/policies/custom/exclude_update_response.py @@ -3,7 +3,7 @@ from typing import List from typing_extensions import TypeAlias -from .split_tunnel_exclude import SplitTunnelExclude +from ...split_tunnel_exclude import SplitTunnelExclude __all__ = ["ExcludeUpdateResponse"] diff --git a/src/cloudflare/types/zero_trust/devices/policies/fallback_domain_get_response.py b/src/cloudflare/types/zero_trust/devices/policies/custom/fallback_domain_get_response.py similarity index 84% rename from src/cloudflare/types/zero_trust/devices/policies/fallback_domain_get_response.py rename to src/cloudflare/types/zero_trust/devices/policies/custom/fallback_domain_get_response.py index 9dbedd1d77a..f5dee1a6e13 100644 --- a/src/cloudflare/types/zero_trust/devices/policies/fallback_domain_get_response.py +++ b/src/cloudflare/types/zero_trust/devices/policies/custom/fallback_domain_get_response.py @@ -3,7 +3,7 @@ from typing import List from typing_extensions import TypeAlias -from .fallback_domain import FallbackDomain +from ...fallback_domain import FallbackDomain __all__ = ["FallbackDomainGetResponse"] diff --git a/src/cloudflare/types/zero_trust/devices/policies/fallback_domain_update_params.py b/src/cloudflare/types/zero_trust/devices/policies/custom/fallback_domain_update_params.py similarity index 87% rename from src/cloudflare/types/zero_trust/devices/policies/fallback_domain_update_params.py rename to src/cloudflare/types/zero_trust/devices/policies/custom/fallback_domain_update_params.py index edef805ec0b..2c284e47aee 100644 --- a/src/cloudflare/types/zero_trust/devices/policies/fallback_domain_update_params.py +++ b/src/cloudflare/types/zero_trust/devices/policies/custom/fallback_domain_update_params.py @@ -5,7 +5,7 @@ from typing import Iterable from typing_extensions import Required, TypedDict -from .fallback_domain_param import FallbackDomainParam +from ...fallback_domain_param import FallbackDomainParam __all__ = ["FallbackDomainUpdateParams"] diff --git a/src/cloudflare/types/zero_trust/devices/policies/fallback_domain_update_response.py b/src/cloudflare/types/zero_trust/devices/policies/custom/fallback_domain_update_response.py similarity index 84% rename from src/cloudflare/types/zero_trust/devices/policies/fallback_domain_update_response.py rename to src/cloudflare/types/zero_trust/devices/policies/custom/fallback_domain_update_response.py index c7e0b137e35..a32c7889b93 100644 --- a/src/cloudflare/types/zero_trust/devices/policies/fallback_domain_update_response.py +++ b/src/cloudflare/types/zero_trust/devices/policies/custom/fallback_domain_update_response.py @@ -3,7 +3,7 @@ from typing import List from typing_extensions import TypeAlias -from .fallback_domain import FallbackDomain +from ...fallback_domain import FallbackDomain __all__ = ["FallbackDomainUpdateResponse"] diff --git a/src/cloudflare/types/zero_trust/devices/policies/include_get_response.py b/src/cloudflare/types/zero_trust/devices/policies/custom/include_get_response.py similarity index 81% rename from src/cloudflare/types/zero_trust/devices/policies/include_get_response.py rename to src/cloudflare/types/zero_trust/devices/policies/custom/include_get_response.py index 4cf962d2b98..9c4138141b9 100644 --- a/src/cloudflare/types/zero_trust/devices/policies/include_get_response.py +++ b/src/cloudflare/types/zero_trust/devices/policies/custom/include_get_response.py @@ -3,7 +3,7 @@ from typing import List from typing_extensions import TypeAlias -from .split_tunnel_include import SplitTunnelInclude +from ...split_tunnel_include import SplitTunnelInclude __all__ = ["IncludeGetResponse"] diff --git a/src/cloudflare/types/zero_trust/devices/policies/include_update_params.py b/src/cloudflare/types/zero_trust/devices/policies/custom/include_update_params.py similarity index 85% rename from src/cloudflare/types/zero_trust/devices/policies/include_update_params.py rename to src/cloudflare/types/zero_trust/devices/policies/custom/include_update_params.py index ac7f05b4141..6568d4ef985 100644 --- a/src/cloudflare/types/zero_trust/devices/policies/include_update_params.py +++ b/src/cloudflare/types/zero_trust/devices/policies/custom/include_update_params.py @@ -5,7 +5,7 @@ from typing import Iterable from typing_extensions import Required, TypedDict -from .split_tunnel_include_param import SplitTunnelIncludeParam +from ...split_tunnel_include_param import SplitTunnelIncludeParam __all__ = ["IncludeUpdateParams"] diff --git a/src/cloudflare/types/zero_trust/devices/policies/include_update_response.py b/src/cloudflare/types/zero_trust/devices/policies/custom/include_update_response.py similarity index 81% rename from src/cloudflare/types/zero_trust/devices/policies/include_update_response.py rename to src/cloudflare/types/zero_trust/devices/policies/custom/include_update_response.py index e0791aeed36..3b3a07a81c1 100644 --- a/src/cloudflare/types/zero_trust/devices/policies/include_update_response.py +++ b/src/cloudflare/types/zero_trust/devices/policies/custom/include_update_response.py @@ -3,7 +3,7 @@ from typing import List from typing_extensions import TypeAlias -from .split_tunnel_include import SplitTunnelInclude +from ...split_tunnel_include import SplitTunnelInclude __all__ = ["IncludeUpdateResponse"] diff --git a/src/cloudflare/types/zero_trust/devices/policy_create_params.py b/src/cloudflare/types/zero_trust/devices/policies/custom_create_params.py similarity index 96% rename from src/cloudflare/types/zero_trust/devices/policy_create_params.py rename to src/cloudflare/types/zero_trust/devices/policies/custom_create_params.py index 2ea3c58bbaa..0966e1f9ef4 100644 --- a/src/cloudflare/types/zero_trust/devices/policy_create_params.py +++ b/src/cloudflare/types/zero_trust/devices/policies/custom_create_params.py @@ -4,10 +4,10 @@ from typing_extensions import Required, TypedDict -__all__ = ["PolicyCreateParams", "ServiceModeV2"] +__all__ = ["CustomCreateParams", "ServiceModeV2"] -class PolicyCreateParams(TypedDict, total=False): +class CustomCreateParams(TypedDict, total=False): account_id: Required[str] match: Required[str] diff --git a/src/cloudflare/types/zero_trust/devices/policy_delete_response.py b/src/cloudflare/types/zero_trust/devices/policies/custom_delete_response.py similarity index 53% rename from src/cloudflare/types/zero_trust/devices/policy_delete_response.py rename to src/cloudflare/types/zero_trust/devices/policies/custom_delete_response.py index e782515d053..ac479c997ed 100644 --- a/src/cloudflare/types/zero_trust/devices/policy_delete_response.py +++ b/src/cloudflare/types/zero_trust/devices/policies/custom_delete_response.py @@ -3,8 +3,8 @@ from typing import List from typing_extensions import TypeAlias -from .settings_policy import SettingsPolicy +from ..settings_policy import SettingsPolicy -__all__ = ["PolicyDeleteResponse"] +__all__ = ["CustomDeleteResponse"] -PolicyDeleteResponse: TypeAlias = List[SettingsPolicy] +CustomDeleteResponse: TypeAlias = List[SettingsPolicy] diff --git a/src/cloudflare/types/zero_trust/devices/policy_edit_params.py b/src/cloudflare/types/zero_trust/devices/policies/custom_edit_params.py similarity index 95% rename from src/cloudflare/types/zero_trust/devices/policy_edit_params.py rename to src/cloudflare/types/zero_trust/devices/policies/custom_edit_params.py index d9cb742a4cc..0af314e554e 100644 --- a/src/cloudflare/types/zero_trust/devices/policy_edit_params.py +++ b/src/cloudflare/types/zero_trust/devices/policies/custom_edit_params.py @@ -4,10 +4,10 @@ from typing_extensions import Required, TypedDict -__all__ = ["PolicyEditParams", "ServiceModeV2"] +__all__ = ["CustomEditParams", "ServiceModeV2"] -class PolicyEditParams(TypedDict, total=False): +class CustomEditParams(TypedDict, total=False): account_id: Required[str] allow_mode_switch: bool diff --git a/src/cloudflare/types/zero_trust/devices/policies/default/__init__.py b/src/cloudflare/types/zero_trust/devices/policies/default/__init__.py new file mode 100644 index 00000000000..02bf1198370 --- /dev/null +++ b/src/cloudflare/types/zero_trust/devices/policies/default/__init__.py @@ -0,0 +1,16 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .exclude_get_response import ExcludeGetResponse as ExcludeGetResponse +from .include_get_response import IncludeGetResponse as IncludeGetResponse +from .exclude_update_params import ExcludeUpdateParams as ExcludeUpdateParams +from .include_update_params import IncludeUpdateParams as IncludeUpdateParams +from .certificate_edit_params import CertificateEditParams as CertificateEditParams +from .exclude_update_response import ExcludeUpdateResponse as ExcludeUpdateResponse +from .include_update_response import IncludeUpdateResponse as IncludeUpdateResponse +from .certificate_get_response import CertificateGetResponse as CertificateGetResponse +from .certificate_edit_response import CertificateEditResponse as CertificateEditResponse +from .fallback_domain_get_response import FallbackDomainGetResponse as FallbackDomainGetResponse +from .fallback_domain_update_params import FallbackDomainUpdateParams as FallbackDomainUpdateParams +from .fallback_domain_update_response import FallbackDomainUpdateResponse as FallbackDomainUpdateResponse diff --git a/src/cloudflare/types/zero_trust/devices/policies/certificate_update_params.py b/src/cloudflare/types/zero_trust/devices/policies/default/certificate_edit_params.py old mode 100755 new mode 100644 similarity index 77% rename from src/cloudflare/types/zero_trust/devices/policies/certificate_update_params.py rename to src/cloudflare/types/zero_trust/devices/policies/default/certificate_edit_params.py index 8f17fb358c7..489d724da51 --- a/src/cloudflare/types/zero_trust/devices/policies/certificate_update_params.py +++ b/src/cloudflare/types/zero_trust/devices/policies/default/certificate_edit_params.py @@ -4,10 +4,10 @@ from typing_extensions import Required, TypedDict -__all__ = ["CertificateUpdateParams"] +__all__ = ["CertificateEditParams"] -class CertificateUpdateParams(TypedDict, total=False): +class CertificateEditParams(TypedDict, total=False): enabled: Required[bool] """ The current status of the device policy certificate provisioning feature for diff --git a/src/cloudflare/types/zero_trust/devices/policies/certificate_update_response.py b/src/cloudflare/types/zero_trust/devices/policies/default/certificate_edit_response.py old mode 100755 new mode 100644 similarity index 58% rename from src/cloudflare/types/zero_trust/devices/policies/certificate_update_response.py rename to src/cloudflare/types/zero_trust/devices/policies/default/certificate_edit_response.py index 015f7860390..0cd113c6420 --- a/src/cloudflare/types/zero_trust/devices/policies/certificate_update_response.py +++ b/src/cloudflare/types/zero_trust/devices/policies/default/certificate_edit_response.py @@ -3,6 +3,6 @@ from typing import Union, Optional from typing_extensions import TypeAlias -__all__ = ["CertificateUpdateResponse"] +__all__ = ["CertificateEditResponse"] -CertificateUpdateResponse: TypeAlias = Union[Optional[str], Optional[object]] +CertificateEditResponse: TypeAlias = Union[Optional[str], Optional[object]] diff --git a/src/cloudflare/types/zero_trust/devices/policies/certificate_get_response.py b/src/cloudflare/types/zero_trust/devices/policies/default/certificate_get_response.py old mode 100755 new mode 100644 similarity index 100% rename from src/cloudflare/types/zero_trust/devices/policies/certificate_get_response.py rename to src/cloudflare/types/zero_trust/devices/policies/default/certificate_get_response.py diff --git a/src/cloudflare/types/zero_trust/devices/policies/default/exclude_get_response.py b/src/cloudflare/types/zero_trust/devices/policies/default/exclude_get_response.py new file mode 100644 index 00000000000..58d2e0f96e4 --- /dev/null +++ b/src/cloudflare/types/zero_trust/devices/policies/default/exclude_get_response.py @@ -0,0 +1,10 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List +from typing_extensions import TypeAlias + +from ...split_tunnel_exclude import SplitTunnelExclude + +__all__ = ["ExcludeGetResponse"] + +ExcludeGetResponse: TypeAlias = List[SplitTunnelExclude] diff --git a/src/cloudflare/types/zero_trust/devices/policies/default/exclude_update_params.py b/src/cloudflare/types/zero_trust/devices/policies/default/exclude_update_params.py new file mode 100644 index 00000000000..3bdc54c4c9f --- /dev/null +++ b/src/cloudflare/types/zero_trust/devices/policies/default/exclude_update_params.py @@ -0,0 +1,16 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Iterable +from typing_extensions import Required, TypedDict + +from ...split_tunnel_exclude_param import SplitTunnelExcludeParam + +__all__ = ["ExcludeUpdateParams"] + + +class ExcludeUpdateParams(TypedDict, total=False): + account_id: Required[str] + + body: Required[Iterable[SplitTunnelExcludeParam]] diff --git a/src/cloudflare/types/zero_trust/devices/policies/default/exclude_update_response.py b/src/cloudflare/types/zero_trust/devices/policies/default/exclude_update_response.py new file mode 100644 index 00000000000..bfafca3ec0a --- /dev/null +++ b/src/cloudflare/types/zero_trust/devices/policies/default/exclude_update_response.py @@ -0,0 +1,10 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List +from typing_extensions import TypeAlias + +from ...split_tunnel_exclude import SplitTunnelExclude + +__all__ = ["ExcludeUpdateResponse"] + +ExcludeUpdateResponse: TypeAlias = List[SplitTunnelExclude] diff --git a/src/cloudflare/types/zero_trust/devices/policies/default/fallback_domain_get_response.py b/src/cloudflare/types/zero_trust/devices/policies/default/fallback_domain_get_response.py new file mode 100644 index 00000000000..f5dee1a6e13 --- /dev/null +++ b/src/cloudflare/types/zero_trust/devices/policies/default/fallback_domain_get_response.py @@ -0,0 +1,10 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List +from typing_extensions import TypeAlias + +from ...fallback_domain import FallbackDomain + +__all__ = ["FallbackDomainGetResponse"] + +FallbackDomainGetResponse: TypeAlias = List[FallbackDomain] diff --git a/src/cloudflare/types/zero_trust/devices/policies/default/fallback_domain_update_params.py b/src/cloudflare/types/zero_trust/devices/policies/default/fallback_domain_update_params.py new file mode 100644 index 00000000000..2c284e47aee --- /dev/null +++ b/src/cloudflare/types/zero_trust/devices/policies/default/fallback_domain_update_params.py @@ -0,0 +1,16 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Iterable +from typing_extensions import Required, TypedDict + +from ...fallback_domain_param import FallbackDomainParam + +__all__ = ["FallbackDomainUpdateParams"] + + +class FallbackDomainUpdateParams(TypedDict, total=False): + account_id: Required[str] + + domains: Required[Iterable[FallbackDomainParam]] diff --git a/src/cloudflare/types/zero_trust/devices/policies/default/fallback_domain_update_response.py b/src/cloudflare/types/zero_trust/devices/policies/default/fallback_domain_update_response.py new file mode 100644 index 00000000000..a32c7889b93 --- /dev/null +++ b/src/cloudflare/types/zero_trust/devices/policies/default/fallback_domain_update_response.py @@ -0,0 +1,10 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List +from typing_extensions import TypeAlias + +from ...fallback_domain import FallbackDomain + +__all__ = ["FallbackDomainUpdateResponse"] + +FallbackDomainUpdateResponse: TypeAlias = List[FallbackDomain] diff --git a/src/cloudflare/types/zero_trust/devices/policies/default/include_get_response.py b/src/cloudflare/types/zero_trust/devices/policies/default/include_get_response.py new file mode 100644 index 00000000000..9c4138141b9 --- /dev/null +++ b/src/cloudflare/types/zero_trust/devices/policies/default/include_get_response.py @@ -0,0 +1,10 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List +from typing_extensions import TypeAlias + +from ...split_tunnel_include import SplitTunnelInclude + +__all__ = ["IncludeGetResponse"] + +IncludeGetResponse: TypeAlias = List[SplitTunnelInclude] diff --git a/src/cloudflare/types/zero_trust/devices/policies/default/include_update_params.py b/src/cloudflare/types/zero_trust/devices/policies/default/include_update_params.py new file mode 100644 index 00000000000..6568d4ef985 --- /dev/null +++ b/src/cloudflare/types/zero_trust/devices/policies/default/include_update_params.py @@ -0,0 +1,16 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Iterable +from typing_extensions import Required, TypedDict + +from ...split_tunnel_include_param import SplitTunnelIncludeParam + +__all__ = ["IncludeUpdateParams"] + + +class IncludeUpdateParams(TypedDict, total=False): + account_id: Required[str] + + body: Required[Iterable[SplitTunnelIncludeParam]] diff --git a/src/cloudflare/types/zero_trust/devices/policies/default/include_update_response.py b/src/cloudflare/types/zero_trust/devices/policies/default/include_update_response.py new file mode 100644 index 00000000000..3b3a07a81c1 --- /dev/null +++ b/src/cloudflare/types/zero_trust/devices/policies/default/include_update_response.py @@ -0,0 +1,10 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List +from typing_extensions import TypeAlias + +from ...split_tunnel_include import SplitTunnelInclude + +__all__ = ["IncludeUpdateResponse"] + +IncludeUpdateResponse: TypeAlias = List[SplitTunnelInclude] diff --git a/src/cloudflare/types/zero_trust/devices/policies/default_edit_params.py b/src/cloudflare/types/zero_trust/devices/policies/default_edit_params.py new file mode 100644 index 00000000000..ffe565848af --- /dev/null +++ b/src/cloudflare/types/zero_trust/devices/policies/default_edit_params.py @@ -0,0 +1,60 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["DefaultEditParams", "ServiceModeV2"] + + +class DefaultEditParams(TypedDict, total=False): + account_id: Required[str] + + allow_mode_switch: bool + """Whether to allow the user to switch WARP between modes.""" + + allow_updates: bool + """ + Whether to receive update notifications when a new version of the client is + available. + """ + + allowed_to_leave: bool + """Whether to allow devices to leave the organization.""" + + auto_connect: float + """The amount of time in minutes to reconnect after having been disabled.""" + + captive_portal: float + """Turn on the captive portal after the specified amount of time.""" + + disable_auto_fallback: bool + """ + If the `dns_server` field of a fallback domain is not present, the client will + fall back to a best guess of the default/system DNS resolvers unless this policy + option is set to `true`. + """ + + exclude_office_ips: bool + """Whether to add Microsoft IPs to Split Tunnel exclusions.""" + + service_mode_v2: ServiceModeV2 + + support_url: str + """The URL to launch when the Send Feedback button is clicked.""" + + switch_locked: bool + """ + Whether to allow the user to turn off the WARP switch and disconnect the client. + """ + + tunnel_protocol: str + """Determines which tunnel protocol to use.""" + + +class ServiceModeV2(TypedDict, total=False): + mode: str + """The mode to run the WARP client under.""" + + port: float + """The port number when used with proxy mode.""" diff --git a/src/cloudflare/types/zero_trust/devices/policies/default_policy_get_response.py b/src/cloudflare/types/zero_trust/devices/policies/default_edit_response.py similarity index 89% rename from src/cloudflare/types/zero_trust/devices/policies/default_policy_get_response.py rename to src/cloudflare/types/zero_trust/devices/policies/default_edit_response.py index d9a54220a28..81d01419835 100644 --- a/src/cloudflare/types/zero_trust/devices/policies/default_policy_get_response.py +++ b/src/cloudflare/types/zero_trust/devices/policies/default_edit_response.py @@ -3,11 +3,11 @@ from typing import List, Optional from ....._models import BaseModel -from .fallback_domain import FallbackDomain -from .split_tunnel_exclude import SplitTunnelExclude -from .split_tunnel_include import SplitTunnelInclude +from ..fallback_domain import FallbackDomain +from ..split_tunnel_exclude import SplitTunnelExclude +from ..split_tunnel_include import SplitTunnelInclude -__all__ = ["DefaultPolicyGetResponse", "ServiceModeV2"] +__all__ = ["DefaultEditResponse", "ServiceModeV2"] class ServiceModeV2(BaseModel): @@ -18,7 +18,7 @@ class ServiceModeV2(BaseModel): """The port number when used with proxy mode.""" -class DefaultPolicyGetResponse(BaseModel): +class DefaultEditResponse(BaseModel): allow_mode_switch: Optional[bool] = None """Whether to allow the user to switch WARP between modes.""" diff --git a/src/cloudflare/types/zero_trust/devices/policies/default_get_response.py b/src/cloudflare/types/zero_trust/devices/policies/default_get_response.py new file mode 100644 index 00000000000..858e398cbf9 --- /dev/null +++ b/src/cloudflare/types/zero_trust/devices/policies/default_get_response.py @@ -0,0 +1,75 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from ....._models import BaseModel +from ..fallback_domain import FallbackDomain +from ..split_tunnel_exclude import SplitTunnelExclude +from ..split_tunnel_include import SplitTunnelInclude + +__all__ = ["DefaultGetResponse", "ServiceModeV2"] + + +class ServiceModeV2(BaseModel): + mode: Optional[str] = None + """The mode to run the WARP client under.""" + + port: Optional[float] = None + """The port number when used with proxy mode.""" + + +class DefaultGetResponse(BaseModel): + allow_mode_switch: Optional[bool] = None + """Whether to allow the user to switch WARP between modes.""" + + allow_updates: Optional[bool] = None + """ + Whether to receive update notifications when a new version of the client is + available. + """ + + allowed_to_leave: Optional[bool] = None + """Whether to allow devices to leave the organization.""" + + auto_connect: Optional[float] = None + """The amount of time in minutes to reconnect after having been disabled.""" + + captive_portal: Optional[float] = None + """Turn on the captive portal after the specified amount of time.""" + + default: Optional[bool] = None + """Whether the policy will be applied to matching devices.""" + + disable_auto_fallback: Optional[bool] = None + """ + If the `dns_server` field of a fallback domain is not present, the client will + fall back to a best guess of the default/system DNS resolvers unless this policy + option is set to `true`. + """ + + enabled: Optional[bool] = None + """Whether the policy will be applied to matching devices.""" + + exclude: Optional[List[SplitTunnelExclude]] = None + + exclude_office_ips: Optional[bool] = None + """Whether to add Microsoft IPs to Split Tunnel exclusions.""" + + fallback_domains: Optional[List[FallbackDomain]] = None + + gateway_unique_id: Optional[str] = None + + include: Optional[List[SplitTunnelInclude]] = None + + service_mode_v2: Optional[ServiceModeV2] = None + + support_url: Optional[str] = None + """The URL to launch when the Send Feedback button is clicked.""" + + switch_locked: Optional[bool] = None + """ + Whether to allow the user to turn off the WARP switch and disconnect the client. + """ + + tunnel_protocol: Optional[str] = None + """Determines which tunnel protocol to use.""" diff --git a/src/cloudflare/types/zero_trust/devices/settings_policy.py b/src/cloudflare/types/zero_trust/devices/settings_policy.py index 33b4e6c2eeb..3ec41eef919 100644 --- a/src/cloudflare/types/zero_trust/devices/settings_policy.py +++ b/src/cloudflare/types/zero_trust/devices/settings_policy.py @@ -3,9 +3,9 @@ from typing import List, Optional from ...._models import BaseModel -from .policies.fallback_domain import FallbackDomain -from .policies.split_tunnel_exclude import SplitTunnelExclude -from .policies.split_tunnel_include import SplitTunnelInclude +from .fallback_domain import FallbackDomain +from .split_tunnel_exclude import SplitTunnelExclude +from .split_tunnel_include import SplitTunnelInclude __all__ = ["SettingsPolicy", "ServiceModeV2", "TargetTest"] diff --git a/src/cloudflare/types/zero_trust/devices/policies/split_tunnel_exclude.py b/src/cloudflare/types/zero_trust/devices/split_tunnel_exclude.py similarity index 94% rename from src/cloudflare/types/zero_trust/devices/policies/split_tunnel_exclude.py rename to src/cloudflare/types/zero_trust/devices/split_tunnel_exclude.py index cd78772008c..e141ec2d80b 100644 --- a/src/cloudflare/types/zero_trust/devices/policies/split_tunnel_exclude.py +++ b/src/cloudflare/types/zero_trust/devices/split_tunnel_exclude.py @@ -2,7 +2,7 @@ from typing import Optional -from ....._models import BaseModel +from ...._models import BaseModel __all__ = ["SplitTunnelExclude"] diff --git a/src/cloudflare/types/zero_trust/devices/policies/split_tunnel_exclude_param.py b/src/cloudflare/types/zero_trust/devices/split_tunnel_exclude_param.py similarity index 100% rename from src/cloudflare/types/zero_trust/devices/policies/split_tunnel_exclude_param.py rename to src/cloudflare/types/zero_trust/devices/split_tunnel_exclude_param.py diff --git a/src/cloudflare/types/zero_trust/devices/policies/split_tunnel_include.py b/src/cloudflare/types/zero_trust/devices/split_tunnel_include.py similarity index 94% rename from src/cloudflare/types/zero_trust/devices/policies/split_tunnel_include.py rename to src/cloudflare/types/zero_trust/devices/split_tunnel_include.py index 0791d7c0eda..a8f2d220e0e 100644 --- a/src/cloudflare/types/zero_trust/devices/policies/split_tunnel_include.py +++ b/src/cloudflare/types/zero_trust/devices/split_tunnel_include.py @@ -2,7 +2,7 @@ from typing import Optional -from ....._models import BaseModel +from ...._models import BaseModel __all__ = ["SplitTunnelInclude"] diff --git a/src/cloudflare/types/zero_trust/devices/policies/split_tunnel_include_param.py b/src/cloudflare/types/zero_trust/devices/split_tunnel_include_param.py similarity index 100% rename from src/cloudflare/types/zero_trust/devices/policies/split_tunnel_include_param.py rename to src/cloudflare/types/zero_trust/devices/split_tunnel_include_param.py diff --git a/tests/api_resources/zero_trust/devices/policies/custom/__init__.py b/tests/api_resources/zero_trust/devices/policies/custom/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/zero_trust/devices/policies/custom/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/zero_trust/devices/policies/test_excludes.py b/tests/api_resources/zero_trust/devices/policies/custom/test_excludes.py similarity index 71% rename from tests/api_resources/zero_trust/devices/policies/test_excludes.py rename to tests/api_resources/zero_trust/devices/policies/custom/test_excludes.py index 053960e74cf..3c8a6bdbb06 100644 --- a/tests/api_resources/zero_trust/devices/policies/test_excludes.py +++ b/tests/api_resources/zero_trust/devices/policies/custom/test_excludes.py @@ -9,10 +9,8 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type -from cloudflare.pagination import SyncSinglePage, AsyncSinglePage -from cloudflare.types.zero_trust.devices.policies import ( +from cloudflare.types.zero_trust.devices.policies.custom import ( ExcludeGetResponse, - SplitTunnelExclude, ExcludeUpdateResponse, ) @@ -24,7 +22,8 @@ class TestExcludes: @parametrize def test_method_update(self, client: Cloudflare) -> None: - exclude = client.zero_trust.devices.policies.excludes.update( + exclude = client.zero_trust.devices.policies.custom.excludes.update( + policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", body=[ { @@ -45,7 +44,8 @@ def test_method_update(self, client: Cloudflare) -> None: @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: - response = client.zero_trust.devices.policies.excludes.with_raw_response.update( + response = client.zero_trust.devices.policies.custom.excludes.with_raw_response.update( + policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", body=[ { @@ -70,7 +70,8 @@ def test_raw_response_update(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: - with client.zero_trust.devices.policies.excludes.with_streaming_response.update( + with client.zero_trust.devices.policies.custom.excludes.with_streaming_response.update( + policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", body=[ { @@ -98,7 +99,8 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: @parametrize def test_path_params_update(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.devices.policies.excludes.with_raw_response.update( + client.zero_trust.devices.policies.custom.excludes.with_raw_response.update( + policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", body=[ { @@ -116,47 +118,29 @@ def test_path_params_update(self, client: Cloudflare) -> None: ], ) - @parametrize - def test_method_list(self, client: Cloudflare) -> None: - exclude = client.zero_trust.devices.policies.excludes.list( - account_id="699d98642c564d2e855e9661899b7252", - ) - assert_matches_type(SyncSinglePage[SplitTunnelExclude], exclude, path=["response"]) - - @parametrize - def test_raw_response_list(self, client: Cloudflare) -> None: - response = client.zero_trust.devices.policies.excludes.with_raw_response.list( - account_id="699d98642c564d2e855e9661899b7252", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - exclude = response.parse() - assert_matches_type(SyncSinglePage[SplitTunnelExclude], exclude, path=["response"]) - - @parametrize - def test_streaming_response_list(self, client: Cloudflare) -> None: - with client.zero_trust.devices.policies.excludes.with_streaming_response.list( - account_id="699d98642c564d2e855e9661899b7252", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - exclude = response.parse() - assert_matches_type(SyncSinglePage[SplitTunnelExclude], exclude, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_list(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.devices.policies.excludes.with_raw_response.list( - account_id="", + with pytest.raises(ValueError, match=r"Expected a non-empty value for `policy_id` but received ''"): + client.zero_trust.devices.policies.custom.excludes.with_raw_response.update( + policy_id="", + account_id="699d98642c564d2e855e9661899b7252", + body=[ + { + "address": "192.0.2.0/24", + "description": "Exclude testing domains from the tunnel", + }, + { + "address": "192.0.2.0/24", + "description": "Exclude testing domains from the tunnel", + }, + { + "address": "192.0.2.0/24", + "description": "Exclude testing domains from the tunnel", + }, + ], ) @parametrize def test_method_get(self, client: Cloudflare) -> None: - exclude = client.zero_trust.devices.policies.excludes.get( + exclude = client.zero_trust.devices.policies.custom.excludes.get( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) @@ -164,7 +148,7 @@ def test_method_get(self, client: Cloudflare) -> None: @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: - response = client.zero_trust.devices.policies.excludes.with_raw_response.get( + response = client.zero_trust.devices.policies.custom.excludes.with_raw_response.get( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) @@ -176,7 +160,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: - with client.zero_trust.devices.policies.excludes.with_streaming_response.get( + with client.zero_trust.devices.policies.custom.excludes.with_streaming_response.get( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) as response: @@ -191,13 +175,13 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: @parametrize def test_path_params_get(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.devices.policies.excludes.with_raw_response.get( + client.zero_trust.devices.policies.custom.excludes.with_raw_response.get( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `policy_id` but received ''"): - client.zero_trust.devices.policies.excludes.with_raw_response.get( + client.zero_trust.devices.policies.custom.excludes.with_raw_response.get( policy_id="", account_id="699d98642c564d2e855e9661899b7252", ) @@ -208,7 +192,8 @@ class TestAsyncExcludes: @parametrize async def test_method_update(self, async_client: AsyncCloudflare) -> None: - exclude = await async_client.zero_trust.devices.policies.excludes.update( + exclude = await async_client.zero_trust.devices.policies.custom.excludes.update( + policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", body=[ { @@ -229,7 +214,8 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.devices.policies.excludes.with_raw_response.update( + response = await async_client.zero_trust.devices.policies.custom.excludes.with_raw_response.update( + policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", body=[ { @@ -254,7 +240,8 @@ async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.devices.policies.excludes.with_streaming_response.update( + async with async_client.zero_trust.devices.policies.custom.excludes.with_streaming_response.update( + policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", body=[ { @@ -282,7 +269,8 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> @parametrize async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.devices.policies.excludes.with_raw_response.update( + await async_client.zero_trust.devices.policies.custom.excludes.with_raw_response.update( + policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", body=[ { @@ -300,47 +288,29 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: ], ) - @parametrize - async def test_method_list(self, async_client: AsyncCloudflare) -> None: - exclude = await async_client.zero_trust.devices.policies.excludes.list( - account_id="699d98642c564d2e855e9661899b7252", - ) - assert_matches_type(AsyncSinglePage[SplitTunnelExclude], exclude, path=["response"]) - - @parametrize - async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.devices.policies.excludes.with_raw_response.list( - account_id="699d98642c564d2e855e9661899b7252", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - exclude = await response.parse() - assert_matches_type(AsyncSinglePage[SplitTunnelExclude], exclude, path=["response"]) - - @parametrize - async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.devices.policies.excludes.with_streaming_response.list( - account_id="699d98642c564d2e855e9661899b7252", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - exclude = await response.parse() - assert_matches_type(AsyncSinglePage[SplitTunnelExclude], exclude, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.devices.policies.excludes.with_raw_response.list( - account_id="", + with pytest.raises(ValueError, match=r"Expected a non-empty value for `policy_id` but received ''"): + await async_client.zero_trust.devices.policies.custom.excludes.with_raw_response.update( + policy_id="", + account_id="699d98642c564d2e855e9661899b7252", + body=[ + { + "address": "192.0.2.0/24", + "description": "Exclude testing domains from the tunnel", + }, + { + "address": "192.0.2.0/24", + "description": "Exclude testing domains from the tunnel", + }, + { + "address": "192.0.2.0/24", + "description": "Exclude testing domains from the tunnel", + }, + ], ) @parametrize async def test_method_get(self, async_client: AsyncCloudflare) -> None: - exclude = await async_client.zero_trust.devices.policies.excludes.get( + exclude = await async_client.zero_trust.devices.policies.custom.excludes.get( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) @@ -348,7 +318,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.devices.policies.excludes.with_raw_response.get( + response = await async_client.zero_trust.devices.policies.custom.excludes.with_raw_response.get( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) @@ -360,7 +330,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.devices.policies.excludes.with_streaming_response.get( + async with async_client.zero_trust.devices.policies.custom.excludes.with_streaming_response.get( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) as response: @@ -375,13 +345,13 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No @parametrize async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.devices.policies.excludes.with_raw_response.get( + await async_client.zero_trust.devices.policies.custom.excludes.with_raw_response.get( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `policy_id` but received ''"): - await async_client.zero_trust.devices.policies.excludes.with_raw_response.get( + await async_client.zero_trust.devices.policies.custom.excludes.with_raw_response.get( policy_id="", account_id="699d98642c564d2e855e9661899b7252", ) diff --git a/tests/api_resources/zero_trust/devices/policies/test_fallback_domains.py b/tests/api_resources/zero_trust/devices/policies/custom/test_fallback_domains.py similarity index 64% rename from tests/api_resources/zero_trust/devices/policies/test_fallback_domains.py rename to tests/api_resources/zero_trust/devices/policies/custom/test_fallback_domains.py index 6a426785ea2..43aacc9a5e8 100644 --- a/tests/api_resources/zero_trust/devices/policies/test_fallback_domains.py +++ b/tests/api_resources/zero_trust/devices/policies/custom/test_fallback_domains.py @@ -9,9 +9,7 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type -from cloudflare.pagination import SyncSinglePage, AsyncSinglePage -from cloudflare.types.zero_trust.devices.policies import ( - FallbackDomain, +from cloudflare.types.zero_trust.devices.policies.custom import ( FallbackDomainGetResponse, FallbackDomainUpdateResponse, ) @@ -24,7 +22,7 @@ class TestFallbackDomains: @parametrize def test_method_update(self, client: Cloudflare) -> None: - fallback_domain = client.zero_trust.devices.policies.fallback_domains.update( + fallback_domain = client.zero_trust.devices.policies.custom.fallback_domains.update( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", domains=[{"suffix": "example.com"}, {"suffix": "example.com"}, {"suffix": "example.com"}], @@ -33,7 +31,7 @@ def test_method_update(self, client: Cloudflare) -> None: @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: - response = client.zero_trust.devices.policies.fallback_domains.with_raw_response.update( + response = client.zero_trust.devices.policies.custom.fallback_domains.with_raw_response.update( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", domains=[{"suffix": "example.com"}, {"suffix": "example.com"}, {"suffix": "example.com"}], @@ -46,7 +44,7 @@ def test_raw_response_update(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: - with client.zero_trust.devices.policies.fallback_domains.with_streaming_response.update( + with client.zero_trust.devices.policies.custom.fallback_domains.with_streaming_response.update( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", domains=[{"suffix": "example.com"}, {"suffix": "example.com"}, {"suffix": "example.com"}], @@ -62,60 +60,22 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: @parametrize def test_path_params_update(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.devices.policies.fallback_domains.with_raw_response.update( + client.zero_trust.devices.policies.custom.fallback_domains.with_raw_response.update( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", domains=[{"suffix": "example.com"}, {"suffix": "example.com"}, {"suffix": "example.com"}], ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `policy_id` but received ''"): - client.zero_trust.devices.policies.fallback_domains.with_raw_response.update( + client.zero_trust.devices.policies.custom.fallback_domains.with_raw_response.update( policy_id="", account_id="699d98642c564d2e855e9661899b7252", domains=[{"suffix": "example.com"}, {"suffix": "example.com"}, {"suffix": "example.com"}], ) - @parametrize - def test_method_list(self, client: Cloudflare) -> None: - fallback_domain = client.zero_trust.devices.policies.fallback_domains.list( - account_id="699d98642c564d2e855e9661899b7252", - ) - assert_matches_type(SyncSinglePage[FallbackDomain], fallback_domain, path=["response"]) - - @parametrize - def test_raw_response_list(self, client: Cloudflare) -> None: - response = client.zero_trust.devices.policies.fallback_domains.with_raw_response.list( - account_id="699d98642c564d2e855e9661899b7252", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - fallback_domain = response.parse() - assert_matches_type(SyncSinglePage[FallbackDomain], fallback_domain, path=["response"]) - - @parametrize - def test_streaming_response_list(self, client: Cloudflare) -> None: - with client.zero_trust.devices.policies.fallback_domains.with_streaming_response.list( - account_id="699d98642c564d2e855e9661899b7252", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - fallback_domain = response.parse() - assert_matches_type(SyncSinglePage[FallbackDomain], fallback_domain, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_list(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.devices.policies.fallback_domains.with_raw_response.list( - account_id="", - ) - @parametrize def test_method_get(self, client: Cloudflare) -> None: - fallback_domain = client.zero_trust.devices.policies.fallback_domains.get( + fallback_domain = client.zero_trust.devices.policies.custom.fallback_domains.get( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) @@ -123,7 +83,7 @@ def test_method_get(self, client: Cloudflare) -> None: @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: - response = client.zero_trust.devices.policies.fallback_domains.with_raw_response.get( + response = client.zero_trust.devices.policies.custom.fallback_domains.with_raw_response.get( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) @@ -135,7 +95,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: - with client.zero_trust.devices.policies.fallback_domains.with_streaming_response.get( + with client.zero_trust.devices.policies.custom.fallback_domains.with_streaming_response.get( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) as response: @@ -150,13 +110,13 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: @parametrize def test_path_params_get(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.devices.policies.fallback_domains.with_raw_response.get( + client.zero_trust.devices.policies.custom.fallback_domains.with_raw_response.get( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `policy_id` but received ''"): - client.zero_trust.devices.policies.fallback_domains.with_raw_response.get( + client.zero_trust.devices.policies.custom.fallback_domains.with_raw_response.get( policy_id="", account_id="699d98642c564d2e855e9661899b7252", ) @@ -167,7 +127,7 @@ class TestAsyncFallbackDomains: @parametrize async def test_method_update(self, async_client: AsyncCloudflare) -> None: - fallback_domain = await async_client.zero_trust.devices.policies.fallback_domains.update( + fallback_domain = await async_client.zero_trust.devices.policies.custom.fallback_domains.update( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", domains=[{"suffix": "example.com"}, {"suffix": "example.com"}, {"suffix": "example.com"}], @@ -176,7 +136,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.devices.policies.fallback_domains.with_raw_response.update( + response = await async_client.zero_trust.devices.policies.custom.fallback_domains.with_raw_response.update( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", domains=[{"suffix": "example.com"}, {"suffix": "example.com"}, {"suffix": "example.com"}], @@ -189,7 +149,7 @@ async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.devices.policies.fallback_domains.with_streaming_response.update( + async with async_client.zero_trust.devices.policies.custom.fallback_domains.with_streaming_response.update( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", domains=[{"suffix": "example.com"}, {"suffix": "example.com"}, {"suffix": "example.com"}], @@ -205,60 +165,22 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> @parametrize async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.devices.policies.fallback_domains.with_raw_response.update( + await async_client.zero_trust.devices.policies.custom.fallback_domains.with_raw_response.update( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", domains=[{"suffix": "example.com"}, {"suffix": "example.com"}, {"suffix": "example.com"}], ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `policy_id` but received ''"): - await async_client.zero_trust.devices.policies.fallback_domains.with_raw_response.update( + await async_client.zero_trust.devices.policies.custom.fallback_domains.with_raw_response.update( policy_id="", account_id="699d98642c564d2e855e9661899b7252", domains=[{"suffix": "example.com"}, {"suffix": "example.com"}, {"suffix": "example.com"}], ) - @parametrize - async def test_method_list(self, async_client: AsyncCloudflare) -> None: - fallback_domain = await async_client.zero_trust.devices.policies.fallback_domains.list( - account_id="699d98642c564d2e855e9661899b7252", - ) - assert_matches_type(AsyncSinglePage[FallbackDomain], fallback_domain, path=["response"]) - - @parametrize - async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.devices.policies.fallback_domains.with_raw_response.list( - account_id="699d98642c564d2e855e9661899b7252", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - fallback_domain = await response.parse() - assert_matches_type(AsyncSinglePage[FallbackDomain], fallback_domain, path=["response"]) - - @parametrize - async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.devices.policies.fallback_domains.with_streaming_response.list( - account_id="699d98642c564d2e855e9661899b7252", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - fallback_domain = await response.parse() - assert_matches_type(AsyncSinglePage[FallbackDomain], fallback_domain, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.devices.policies.fallback_domains.with_raw_response.list( - account_id="", - ) - @parametrize async def test_method_get(self, async_client: AsyncCloudflare) -> None: - fallback_domain = await async_client.zero_trust.devices.policies.fallback_domains.get( + fallback_domain = await async_client.zero_trust.devices.policies.custom.fallback_domains.get( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) @@ -266,7 +188,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.devices.policies.fallback_domains.with_raw_response.get( + response = await async_client.zero_trust.devices.policies.custom.fallback_domains.with_raw_response.get( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) @@ -278,7 +200,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.devices.policies.fallback_domains.with_streaming_response.get( + async with async_client.zero_trust.devices.policies.custom.fallback_domains.with_streaming_response.get( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) as response: @@ -293,13 +215,13 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No @parametrize async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.devices.policies.fallback_domains.with_raw_response.get( + await async_client.zero_trust.devices.policies.custom.fallback_domains.with_raw_response.get( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `policy_id` but received ''"): - await async_client.zero_trust.devices.policies.fallback_domains.with_raw_response.get( + await async_client.zero_trust.devices.policies.custom.fallback_domains.with_raw_response.get( policy_id="", account_id="699d98642c564d2e855e9661899b7252", ) diff --git a/tests/api_resources/zero_trust/devices/policies/test_includes.py b/tests/api_resources/zero_trust/devices/policies/custom/test_includes.py similarity index 71% rename from tests/api_resources/zero_trust/devices/policies/test_includes.py rename to tests/api_resources/zero_trust/devices/policies/custom/test_includes.py index e858168766f..1300df9b451 100644 --- a/tests/api_resources/zero_trust/devices/policies/test_includes.py +++ b/tests/api_resources/zero_trust/devices/policies/custom/test_includes.py @@ -9,10 +9,8 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type -from cloudflare.pagination import SyncSinglePage, AsyncSinglePage -from cloudflare.types.zero_trust.devices.policies import ( +from cloudflare.types.zero_trust.devices.policies.custom import ( IncludeGetResponse, - SplitTunnelInclude, IncludeUpdateResponse, ) @@ -24,7 +22,8 @@ class TestIncludes: @parametrize def test_method_update(self, client: Cloudflare) -> None: - include = client.zero_trust.devices.policies.includes.update( + include = client.zero_trust.devices.policies.custom.includes.update( + policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", body=[ { @@ -45,7 +44,8 @@ def test_method_update(self, client: Cloudflare) -> None: @parametrize def test_raw_response_update(self, client: Cloudflare) -> None: - response = client.zero_trust.devices.policies.includes.with_raw_response.update( + response = client.zero_trust.devices.policies.custom.includes.with_raw_response.update( + policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", body=[ { @@ -70,7 +70,8 @@ def test_raw_response_update(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_update(self, client: Cloudflare) -> None: - with client.zero_trust.devices.policies.includes.with_streaming_response.update( + with client.zero_trust.devices.policies.custom.includes.with_streaming_response.update( + policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", body=[ { @@ -98,7 +99,8 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: @parametrize def test_path_params_update(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.devices.policies.includes.with_raw_response.update( + client.zero_trust.devices.policies.custom.includes.with_raw_response.update( + policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", body=[ { @@ -116,47 +118,29 @@ def test_path_params_update(self, client: Cloudflare) -> None: ], ) - @parametrize - def test_method_list(self, client: Cloudflare) -> None: - include = client.zero_trust.devices.policies.includes.list( - account_id="699d98642c564d2e855e9661899b7252", - ) - assert_matches_type(SyncSinglePage[SplitTunnelInclude], include, path=["response"]) - - @parametrize - def test_raw_response_list(self, client: Cloudflare) -> None: - response = client.zero_trust.devices.policies.includes.with_raw_response.list( - account_id="699d98642c564d2e855e9661899b7252", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - include = response.parse() - assert_matches_type(SyncSinglePage[SplitTunnelInclude], include, path=["response"]) - - @parametrize - def test_streaming_response_list(self, client: Cloudflare) -> None: - with client.zero_trust.devices.policies.includes.with_streaming_response.list( - account_id="699d98642c564d2e855e9661899b7252", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - include = response.parse() - assert_matches_type(SyncSinglePage[SplitTunnelInclude], include, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_list(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.devices.policies.includes.with_raw_response.list( - account_id="", + with pytest.raises(ValueError, match=r"Expected a non-empty value for `policy_id` but received ''"): + client.zero_trust.devices.policies.custom.includes.with_raw_response.update( + policy_id="", + account_id="699d98642c564d2e855e9661899b7252", + body=[ + { + "address": "192.0.2.0/24", + "description": "Include testing domains from the tunnel", + }, + { + "address": "192.0.2.0/24", + "description": "Include testing domains from the tunnel", + }, + { + "address": "192.0.2.0/24", + "description": "Include testing domains from the tunnel", + }, + ], ) @parametrize def test_method_get(self, client: Cloudflare) -> None: - include = client.zero_trust.devices.policies.includes.get( + include = client.zero_trust.devices.policies.custom.includes.get( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) @@ -164,7 +148,7 @@ def test_method_get(self, client: Cloudflare) -> None: @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: - response = client.zero_trust.devices.policies.includes.with_raw_response.get( + response = client.zero_trust.devices.policies.custom.includes.with_raw_response.get( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) @@ -176,7 +160,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: - with client.zero_trust.devices.policies.includes.with_streaming_response.get( + with client.zero_trust.devices.policies.custom.includes.with_streaming_response.get( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) as response: @@ -191,13 +175,13 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: @parametrize def test_path_params_get(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.devices.policies.includes.with_raw_response.get( + client.zero_trust.devices.policies.custom.includes.with_raw_response.get( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `policy_id` but received ''"): - client.zero_trust.devices.policies.includes.with_raw_response.get( + client.zero_trust.devices.policies.custom.includes.with_raw_response.get( policy_id="", account_id="699d98642c564d2e855e9661899b7252", ) @@ -208,7 +192,8 @@ class TestAsyncIncludes: @parametrize async def test_method_update(self, async_client: AsyncCloudflare) -> None: - include = await async_client.zero_trust.devices.policies.includes.update( + include = await async_client.zero_trust.devices.policies.custom.includes.update( + policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", body=[ { @@ -229,7 +214,8 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.devices.policies.includes.with_raw_response.update( + response = await async_client.zero_trust.devices.policies.custom.includes.with_raw_response.update( + policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", body=[ { @@ -254,7 +240,8 @@ async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.devices.policies.includes.with_streaming_response.update( + async with async_client.zero_trust.devices.policies.custom.includes.with_streaming_response.update( + policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", body=[ { @@ -282,7 +269,8 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> @parametrize async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.devices.policies.includes.with_raw_response.update( + await async_client.zero_trust.devices.policies.custom.includes.with_raw_response.update( + policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", body=[ { @@ -300,47 +288,29 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: ], ) - @parametrize - async def test_method_list(self, async_client: AsyncCloudflare) -> None: - include = await async_client.zero_trust.devices.policies.includes.list( - account_id="699d98642c564d2e855e9661899b7252", - ) - assert_matches_type(AsyncSinglePage[SplitTunnelInclude], include, path=["response"]) - - @parametrize - async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.devices.policies.includes.with_raw_response.list( - account_id="699d98642c564d2e855e9661899b7252", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - include = await response.parse() - assert_matches_type(AsyncSinglePage[SplitTunnelInclude], include, path=["response"]) - - @parametrize - async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.devices.policies.includes.with_streaming_response.list( - account_id="699d98642c564d2e855e9661899b7252", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - include = await response.parse() - assert_matches_type(AsyncSinglePage[SplitTunnelInclude], include, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.devices.policies.includes.with_raw_response.list( - account_id="", + with pytest.raises(ValueError, match=r"Expected a non-empty value for `policy_id` but received ''"): + await async_client.zero_trust.devices.policies.custom.includes.with_raw_response.update( + policy_id="", + account_id="699d98642c564d2e855e9661899b7252", + body=[ + { + "address": "192.0.2.0/24", + "description": "Include testing domains from the tunnel", + }, + { + "address": "192.0.2.0/24", + "description": "Include testing domains from the tunnel", + }, + { + "address": "192.0.2.0/24", + "description": "Include testing domains from the tunnel", + }, + ], ) @parametrize async def test_method_get(self, async_client: AsyncCloudflare) -> None: - include = await async_client.zero_trust.devices.policies.includes.get( + include = await async_client.zero_trust.devices.policies.custom.includes.get( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) @@ -348,7 +318,7 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.devices.policies.includes.with_raw_response.get( + response = await async_client.zero_trust.devices.policies.custom.includes.with_raw_response.get( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) @@ -360,7 +330,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.devices.policies.includes.with_streaming_response.get( + async with async_client.zero_trust.devices.policies.custom.includes.with_streaming_response.get( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) as response: @@ -375,13 +345,13 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No @parametrize async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.devices.policies.includes.with_raw_response.get( + await async_client.zero_trust.devices.policies.custom.includes.with_raw_response.get( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `policy_id` but received ''"): - await async_client.zero_trust.devices.policies.includes.with_raw_response.get( + await async_client.zero_trust.devices.policies.custom.includes.with_raw_response.get( policy_id="", account_id="699d98642c564d2e855e9661899b7252", ) diff --git a/tests/api_resources/zero_trust/devices/policies/default/__init__.py b/tests/api_resources/zero_trust/devices/policies/default/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/zero_trust/devices/policies/default/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/zero_trust/devices/policies/test_certificates.py b/tests/api_resources/zero_trust/devices/policies/default/test_certificates.py old mode 100755 new mode 100644 similarity index 68% rename from tests/api_resources/zero_trust/devices/policies/test_certificates.py rename to tests/api_resources/zero_trust/devices/policies/default/test_certificates.py index 5bfe2d9b01a..b5228f9964c --- a/tests/api_resources/zero_trust/devices/policies/test_certificates.py +++ b/tests/api_resources/zero_trust/devices/policies/default/test_certificates.py @@ -9,9 +9,9 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type -from cloudflare.types.zero_trust.devices.policies import ( +from cloudflare.types.zero_trust.devices.policies.default import ( CertificateGetResponse, - CertificateUpdateResponse, + CertificateEditResponse, ) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -21,16 +21,16 @@ class TestCertificates: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) @parametrize - def test_method_update(self, client: Cloudflare) -> None: - certificate = client.zero_trust.devices.policies.certificates.update( + def test_method_edit(self, client: Cloudflare) -> None: + certificate = client.zero_trust.devices.policies.default.certificates.edit( zone_tag="699d98642c564d2e855e9661899b7252", enabled=True, ) - assert_matches_type(CertificateUpdateResponse, certificate, path=["response"]) + assert_matches_type(CertificateEditResponse, certificate, path=["response"]) @parametrize - def test_raw_response_update(self, client: Cloudflare) -> None: - response = client.zero_trust.devices.policies.certificates.with_raw_response.update( + def test_raw_response_edit(self, client: Cloudflare) -> None: + response = client.zero_trust.devices.policies.default.certificates.with_raw_response.edit( zone_tag="699d98642c564d2e855e9661899b7252", enabled=True, ) @@ -38,11 +38,11 @@ def test_raw_response_update(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" certificate = response.parse() - assert_matches_type(CertificateUpdateResponse, certificate, path=["response"]) + assert_matches_type(CertificateEditResponse, certificate, path=["response"]) @parametrize - def test_streaming_response_update(self, client: Cloudflare) -> None: - with client.zero_trust.devices.policies.certificates.with_streaming_response.update( + def test_streaming_response_edit(self, client: Cloudflare) -> None: + with client.zero_trust.devices.policies.default.certificates.with_streaming_response.edit( zone_tag="699d98642c564d2e855e9661899b7252", enabled=True, ) as response: @@ -50,28 +50,28 @@ def test_streaming_response_update(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" certificate = response.parse() - assert_matches_type(CertificateUpdateResponse, certificate, path=["response"]) + assert_matches_type(CertificateEditResponse, certificate, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize - def test_path_params_update(self, client: Cloudflare) -> None: + def test_path_params_edit(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_tag` but received ''"): - client.zero_trust.devices.policies.certificates.with_raw_response.update( + client.zero_trust.devices.policies.default.certificates.with_raw_response.edit( zone_tag="", enabled=True, ) @parametrize def test_method_get(self, client: Cloudflare) -> None: - certificate = client.zero_trust.devices.policies.certificates.get( + certificate = client.zero_trust.devices.policies.default.certificates.get( "699d98642c564d2e855e9661899b7252", ) assert_matches_type(CertificateGetResponse, certificate, path=["response"]) @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: - response = client.zero_trust.devices.policies.certificates.with_raw_response.get( + response = client.zero_trust.devices.policies.default.certificates.with_raw_response.get( "699d98642c564d2e855e9661899b7252", ) @@ -82,7 +82,7 @@ def test_raw_response_get(self, client: Cloudflare) -> None: @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: - with client.zero_trust.devices.policies.certificates.with_streaming_response.get( + with client.zero_trust.devices.policies.default.certificates.with_streaming_response.get( "699d98642c564d2e855e9661899b7252", ) as response: assert not response.is_closed @@ -96,7 +96,7 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: @parametrize def test_path_params_get(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_tag` but received ''"): - client.zero_trust.devices.policies.certificates.with_raw_response.get( + client.zero_trust.devices.policies.default.certificates.with_raw_response.get( "", ) @@ -105,16 +105,16 @@ class TestAsyncCertificates: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @parametrize - async def test_method_update(self, async_client: AsyncCloudflare) -> None: - certificate = await async_client.zero_trust.devices.policies.certificates.update( + async def test_method_edit(self, async_client: AsyncCloudflare) -> None: + certificate = await async_client.zero_trust.devices.policies.default.certificates.edit( zone_tag="699d98642c564d2e855e9661899b7252", enabled=True, ) - assert_matches_type(CertificateUpdateResponse, certificate, path=["response"]) + assert_matches_type(CertificateEditResponse, certificate, path=["response"]) @parametrize - async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.devices.policies.certificates.with_raw_response.update( + async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.devices.policies.default.certificates.with_raw_response.edit( zone_tag="699d98642c564d2e855e9661899b7252", enabled=True, ) @@ -122,11 +122,11 @@ async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" certificate = await response.parse() - assert_matches_type(CertificateUpdateResponse, certificate, path=["response"]) + assert_matches_type(CertificateEditResponse, certificate, path=["response"]) @parametrize - async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.devices.policies.certificates.with_streaming_response.update( + async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.devices.policies.default.certificates.with_streaming_response.edit( zone_tag="699d98642c564d2e855e9661899b7252", enabled=True, ) as response: @@ -134,28 +134,28 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" certificate = await response.parse() - assert_matches_type(CertificateUpdateResponse, certificate, path=["response"]) + assert_matches_type(CertificateEditResponse, certificate, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_edit(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_tag` but received ''"): - await async_client.zero_trust.devices.policies.certificates.with_raw_response.update( + await async_client.zero_trust.devices.policies.default.certificates.with_raw_response.edit( zone_tag="", enabled=True, ) @parametrize async def test_method_get(self, async_client: AsyncCloudflare) -> None: - certificate = await async_client.zero_trust.devices.policies.certificates.get( + certificate = await async_client.zero_trust.devices.policies.default.certificates.get( "699d98642c564d2e855e9661899b7252", ) assert_matches_type(CertificateGetResponse, certificate, path=["response"]) @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.devices.policies.certificates.with_raw_response.get( + response = await async_client.zero_trust.devices.policies.default.certificates.with_raw_response.get( "699d98642c564d2e855e9661899b7252", ) @@ -166,7 +166,7 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.devices.policies.certificates.with_streaming_response.get( + async with async_client.zero_trust.devices.policies.default.certificates.with_streaming_response.get( "699d98642c564d2e855e9661899b7252", ) as response: assert not response.is_closed @@ -180,6 +180,6 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No @parametrize async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_tag` but received ''"): - await async_client.zero_trust.devices.policies.certificates.with_raw_response.get( + await async_client.zero_trust.devices.policies.default.certificates.with_raw_response.get( "", ) diff --git a/tests/api_resources/zero_trust/devices/policies/default/test_excludes.py b/tests/api_resources/zero_trust/devices/policies/default/test_excludes.py new file mode 100644 index 00000000000..8a288bdcfa7 --- /dev/null +++ b/tests/api_resources/zero_trust/devices/policies/default/test_excludes.py @@ -0,0 +1,289 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, Optional, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.types.zero_trust.devices.policies.default import ( + ExcludeGetResponse, + ExcludeUpdateResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestExcludes: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + exclude = client.zero_trust.devices.policies.default.excludes.update( + account_id="699d98642c564d2e855e9661899b7252", + body=[ + { + "address": "192.0.2.0/24", + "description": "Exclude testing domains from the tunnel", + }, + { + "address": "192.0.2.0/24", + "description": "Exclude testing domains from the tunnel", + }, + { + "address": "192.0.2.0/24", + "description": "Exclude testing domains from the tunnel", + }, + ], + ) + assert_matches_type(Optional[ExcludeUpdateResponse], exclude, path=["response"]) + + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.zero_trust.devices.policies.default.excludes.with_raw_response.update( + account_id="699d98642c564d2e855e9661899b7252", + body=[ + { + "address": "192.0.2.0/24", + "description": "Exclude testing domains from the tunnel", + }, + { + "address": "192.0.2.0/24", + "description": "Exclude testing domains from the tunnel", + }, + { + "address": "192.0.2.0/24", + "description": "Exclude testing domains from the tunnel", + }, + ], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + exclude = response.parse() + assert_matches_type(Optional[ExcludeUpdateResponse], exclude, path=["response"]) + + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.zero_trust.devices.policies.default.excludes.with_streaming_response.update( + account_id="699d98642c564d2e855e9661899b7252", + body=[ + { + "address": "192.0.2.0/24", + "description": "Exclude testing domains from the tunnel", + }, + { + "address": "192.0.2.0/24", + "description": "Exclude testing domains from the tunnel", + }, + { + "address": "192.0.2.0/24", + "description": "Exclude testing domains from the tunnel", + }, + ], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + exclude = response.parse() + assert_matches_type(Optional[ExcludeUpdateResponse], exclude, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.devices.policies.default.excludes.with_raw_response.update( + account_id="", + body=[ + { + "address": "192.0.2.0/24", + "description": "Exclude testing domains from the tunnel", + }, + { + "address": "192.0.2.0/24", + "description": "Exclude testing domains from the tunnel", + }, + { + "address": "192.0.2.0/24", + "description": "Exclude testing domains from the tunnel", + }, + ], + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + exclude = client.zero_trust.devices.policies.default.excludes.get( + account_id="699d98642c564d2e855e9661899b7252", + ) + assert_matches_type(Optional[ExcludeGetResponse], exclude, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.zero_trust.devices.policies.default.excludes.with_raw_response.get( + account_id="699d98642c564d2e855e9661899b7252", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + exclude = response.parse() + assert_matches_type(Optional[ExcludeGetResponse], exclude, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.zero_trust.devices.policies.default.excludes.with_streaming_response.get( + account_id="699d98642c564d2e855e9661899b7252", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + exclude = response.parse() + assert_matches_type(Optional[ExcludeGetResponse], exclude, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.devices.policies.default.excludes.with_raw_response.get( + account_id="", + ) + + +class TestAsyncExcludes: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + exclude = await async_client.zero_trust.devices.policies.default.excludes.update( + account_id="699d98642c564d2e855e9661899b7252", + body=[ + { + "address": "192.0.2.0/24", + "description": "Exclude testing domains from the tunnel", + }, + { + "address": "192.0.2.0/24", + "description": "Exclude testing domains from the tunnel", + }, + { + "address": "192.0.2.0/24", + "description": "Exclude testing domains from the tunnel", + }, + ], + ) + assert_matches_type(Optional[ExcludeUpdateResponse], exclude, path=["response"]) + + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.devices.policies.default.excludes.with_raw_response.update( + account_id="699d98642c564d2e855e9661899b7252", + body=[ + { + "address": "192.0.2.0/24", + "description": "Exclude testing domains from the tunnel", + }, + { + "address": "192.0.2.0/24", + "description": "Exclude testing domains from the tunnel", + }, + { + "address": "192.0.2.0/24", + "description": "Exclude testing domains from the tunnel", + }, + ], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + exclude = await response.parse() + assert_matches_type(Optional[ExcludeUpdateResponse], exclude, path=["response"]) + + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.devices.policies.default.excludes.with_streaming_response.update( + account_id="699d98642c564d2e855e9661899b7252", + body=[ + { + "address": "192.0.2.0/24", + "description": "Exclude testing domains from the tunnel", + }, + { + "address": "192.0.2.0/24", + "description": "Exclude testing domains from the tunnel", + }, + { + "address": "192.0.2.0/24", + "description": "Exclude testing domains from the tunnel", + }, + ], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + exclude = await response.parse() + assert_matches_type(Optional[ExcludeUpdateResponse], exclude, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.zero_trust.devices.policies.default.excludes.with_raw_response.update( + account_id="", + body=[ + { + "address": "192.0.2.0/24", + "description": "Exclude testing domains from the tunnel", + }, + { + "address": "192.0.2.0/24", + "description": "Exclude testing domains from the tunnel", + }, + { + "address": "192.0.2.0/24", + "description": "Exclude testing domains from the tunnel", + }, + ], + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + exclude = await async_client.zero_trust.devices.policies.default.excludes.get( + account_id="699d98642c564d2e855e9661899b7252", + ) + assert_matches_type(Optional[ExcludeGetResponse], exclude, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.devices.policies.default.excludes.with_raw_response.get( + account_id="699d98642c564d2e855e9661899b7252", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + exclude = await response.parse() + assert_matches_type(Optional[ExcludeGetResponse], exclude, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.devices.policies.default.excludes.with_streaming_response.get( + account_id="699d98642c564d2e855e9661899b7252", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + exclude = await response.parse() + assert_matches_type(Optional[ExcludeGetResponse], exclude, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.zero_trust.devices.policies.default.excludes.with_raw_response.get( + account_id="", + ) diff --git a/tests/api_resources/zero_trust/devices/policies/default/test_fallback_domains.py b/tests/api_resources/zero_trust/devices/policies/default/test_fallback_domains.py new file mode 100644 index 00000000000..afdf898a751 --- /dev/null +++ b/tests/api_resources/zero_trust/devices/policies/default/test_fallback_domains.py @@ -0,0 +1,185 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, Optional, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.types.zero_trust.devices.policies.default import ( + FallbackDomainGetResponse, + FallbackDomainUpdateResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestFallbackDomains: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + fallback_domain = client.zero_trust.devices.policies.default.fallback_domains.update( + account_id="699d98642c564d2e855e9661899b7252", + domains=[{"suffix": "example.com"}, {"suffix": "example.com"}, {"suffix": "example.com"}], + ) + assert_matches_type(Optional[FallbackDomainUpdateResponse], fallback_domain, path=["response"]) + + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.zero_trust.devices.policies.default.fallback_domains.with_raw_response.update( + account_id="699d98642c564d2e855e9661899b7252", + domains=[{"suffix": "example.com"}, {"suffix": "example.com"}, {"suffix": "example.com"}], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + fallback_domain = response.parse() + assert_matches_type(Optional[FallbackDomainUpdateResponse], fallback_domain, path=["response"]) + + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.zero_trust.devices.policies.default.fallback_domains.with_streaming_response.update( + account_id="699d98642c564d2e855e9661899b7252", + domains=[{"suffix": "example.com"}, {"suffix": "example.com"}, {"suffix": "example.com"}], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + fallback_domain = response.parse() + assert_matches_type(Optional[FallbackDomainUpdateResponse], fallback_domain, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.devices.policies.default.fallback_domains.with_raw_response.update( + account_id="", + domains=[{"suffix": "example.com"}, {"suffix": "example.com"}, {"suffix": "example.com"}], + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + fallback_domain = client.zero_trust.devices.policies.default.fallback_domains.get( + account_id="699d98642c564d2e855e9661899b7252", + ) + assert_matches_type(Optional[FallbackDomainGetResponse], fallback_domain, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.zero_trust.devices.policies.default.fallback_domains.with_raw_response.get( + account_id="699d98642c564d2e855e9661899b7252", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + fallback_domain = response.parse() + assert_matches_type(Optional[FallbackDomainGetResponse], fallback_domain, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.zero_trust.devices.policies.default.fallback_domains.with_streaming_response.get( + account_id="699d98642c564d2e855e9661899b7252", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + fallback_domain = response.parse() + assert_matches_type(Optional[FallbackDomainGetResponse], fallback_domain, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.devices.policies.default.fallback_domains.with_raw_response.get( + account_id="", + ) + + +class TestAsyncFallbackDomains: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + fallback_domain = await async_client.zero_trust.devices.policies.default.fallback_domains.update( + account_id="699d98642c564d2e855e9661899b7252", + domains=[{"suffix": "example.com"}, {"suffix": "example.com"}, {"suffix": "example.com"}], + ) + assert_matches_type(Optional[FallbackDomainUpdateResponse], fallback_domain, path=["response"]) + + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.devices.policies.default.fallback_domains.with_raw_response.update( + account_id="699d98642c564d2e855e9661899b7252", + domains=[{"suffix": "example.com"}, {"suffix": "example.com"}, {"suffix": "example.com"}], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + fallback_domain = await response.parse() + assert_matches_type(Optional[FallbackDomainUpdateResponse], fallback_domain, path=["response"]) + + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.devices.policies.default.fallback_domains.with_streaming_response.update( + account_id="699d98642c564d2e855e9661899b7252", + domains=[{"suffix": "example.com"}, {"suffix": "example.com"}, {"suffix": "example.com"}], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + fallback_domain = await response.parse() + assert_matches_type(Optional[FallbackDomainUpdateResponse], fallback_domain, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.zero_trust.devices.policies.default.fallback_domains.with_raw_response.update( + account_id="", + domains=[{"suffix": "example.com"}, {"suffix": "example.com"}, {"suffix": "example.com"}], + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + fallback_domain = await async_client.zero_trust.devices.policies.default.fallback_domains.get( + account_id="699d98642c564d2e855e9661899b7252", + ) + assert_matches_type(Optional[FallbackDomainGetResponse], fallback_domain, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.devices.policies.default.fallback_domains.with_raw_response.get( + account_id="699d98642c564d2e855e9661899b7252", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + fallback_domain = await response.parse() + assert_matches_type(Optional[FallbackDomainGetResponse], fallback_domain, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.devices.policies.default.fallback_domains.with_streaming_response.get( + account_id="699d98642c564d2e855e9661899b7252", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + fallback_domain = await response.parse() + assert_matches_type(Optional[FallbackDomainGetResponse], fallback_domain, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.zero_trust.devices.policies.default.fallback_domains.with_raw_response.get( + account_id="", + ) diff --git a/tests/api_resources/zero_trust/devices/policies/default/test_includes.py b/tests/api_resources/zero_trust/devices/policies/default/test_includes.py new file mode 100644 index 00000000000..1e84b42cf83 --- /dev/null +++ b/tests/api_resources/zero_trust/devices/policies/default/test_includes.py @@ -0,0 +1,289 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, Optional, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.types.zero_trust.devices.policies.default import ( + IncludeGetResponse, + IncludeUpdateResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestIncludes: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + include = client.zero_trust.devices.policies.default.includes.update( + account_id="699d98642c564d2e855e9661899b7252", + body=[ + { + "address": "192.0.2.0/24", + "description": "Include testing domains from the tunnel", + }, + { + "address": "192.0.2.0/24", + "description": "Include testing domains from the tunnel", + }, + { + "address": "192.0.2.0/24", + "description": "Include testing domains from the tunnel", + }, + ], + ) + assert_matches_type(Optional[IncludeUpdateResponse], include, path=["response"]) + + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.zero_trust.devices.policies.default.includes.with_raw_response.update( + account_id="699d98642c564d2e855e9661899b7252", + body=[ + { + "address": "192.0.2.0/24", + "description": "Include testing domains from the tunnel", + }, + { + "address": "192.0.2.0/24", + "description": "Include testing domains from the tunnel", + }, + { + "address": "192.0.2.0/24", + "description": "Include testing domains from the tunnel", + }, + ], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + include = response.parse() + assert_matches_type(Optional[IncludeUpdateResponse], include, path=["response"]) + + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.zero_trust.devices.policies.default.includes.with_streaming_response.update( + account_id="699d98642c564d2e855e9661899b7252", + body=[ + { + "address": "192.0.2.0/24", + "description": "Include testing domains from the tunnel", + }, + { + "address": "192.0.2.0/24", + "description": "Include testing domains from the tunnel", + }, + { + "address": "192.0.2.0/24", + "description": "Include testing domains from the tunnel", + }, + ], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + include = response.parse() + assert_matches_type(Optional[IncludeUpdateResponse], include, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.devices.policies.default.includes.with_raw_response.update( + account_id="", + body=[ + { + "address": "192.0.2.0/24", + "description": "Include testing domains from the tunnel", + }, + { + "address": "192.0.2.0/24", + "description": "Include testing domains from the tunnel", + }, + { + "address": "192.0.2.0/24", + "description": "Include testing domains from the tunnel", + }, + ], + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + include = client.zero_trust.devices.policies.default.includes.get( + account_id="699d98642c564d2e855e9661899b7252", + ) + assert_matches_type(Optional[IncludeGetResponse], include, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.zero_trust.devices.policies.default.includes.with_raw_response.get( + account_id="699d98642c564d2e855e9661899b7252", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + include = response.parse() + assert_matches_type(Optional[IncludeGetResponse], include, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.zero_trust.devices.policies.default.includes.with_streaming_response.get( + account_id="699d98642c564d2e855e9661899b7252", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + include = response.parse() + assert_matches_type(Optional[IncludeGetResponse], include, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.devices.policies.default.includes.with_raw_response.get( + account_id="", + ) + + +class TestAsyncIncludes: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + include = await async_client.zero_trust.devices.policies.default.includes.update( + account_id="699d98642c564d2e855e9661899b7252", + body=[ + { + "address": "192.0.2.0/24", + "description": "Include testing domains from the tunnel", + }, + { + "address": "192.0.2.0/24", + "description": "Include testing domains from the tunnel", + }, + { + "address": "192.0.2.0/24", + "description": "Include testing domains from the tunnel", + }, + ], + ) + assert_matches_type(Optional[IncludeUpdateResponse], include, path=["response"]) + + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.devices.policies.default.includes.with_raw_response.update( + account_id="699d98642c564d2e855e9661899b7252", + body=[ + { + "address": "192.0.2.0/24", + "description": "Include testing domains from the tunnel", + }, + { + "address": "192.0.2.0/24", + "description": "Include testing domains from the tunnel", + }, + { + "address": "192.0.2.0/24", + "description": "Include testing domains from the tunnel", + }, + ], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + include = await response.parse() + assert_matches_type(Optional[IncludeUpdateResponse], include, path=["response"]) + + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.devices.policies.default.includes.with_streaming_response.update( + account_id="699d98642c564d2e855e9661899b7252", + body=[ + { + "address": "192.0.2.0/24", + "description": "Include testing domains from the tunnel", + }, + { + "address": "192.0.2.0/24", + "description": "Include testing domains from the tunnel", + }, + { + "address": "192.0.2.0/24", + "description": "Include testing domains from the tunnel", + }, + ], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + include = await response.parse() + assert_matches_type(Optional[IncludeUpdateResponse], include, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.zero_trust.devices.policies.default.includes.with_raw_response.update( + account_id="", + body=[ + { + "address": "192.0.2.0/24", + "description": "Include testing domains from the tunnel", + }, + { + "address": "192.0.2.0/24", + "description": "Include testing domains from the tunnel", + }, + { + "address": "192.0.2.0/24", + "description": "Include testing domains from the tunnel", + }, + ], + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + include = await async_client.zero_trust.devices.policies.default.includes.get( + account_id="699d98642c564d2e855e9661899b7252", + ) + assert_matches_type(Optional[IncludeGetResponse], include, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.devices.policies.default.includes.with_raw_response.get( + account_id="699d98642c564d2e855e9661899b7252", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + include = await response.parse() + assert_matches_type(Optional[IncludeGetResponse], include, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.devices.policies.default.includes.with_streaming_response.get( + account_id="699d98642c564d2e855e9661899b7252", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + include = await response.parse() + assert_matches_type(Optional[IncludeGetResponse], include, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.zero_trust.devices.policies.default.includes.with_raw_response.get( + account_id="", + ) diff --git a/tests/api_resources/zero_trust/devices/test_policies.py b/tests/api_resources/zero_trust/devices/policies/test_custom.py similarity index 75% rename from tests/api_resources/zero_trust/devices/test_policies.py rename to tests/api_resources/zero_trust/devices/policies/test_custom.py index d90ac5f9055..b88e5c32535 100644 --- a/tests/api_resources/zero_trust/devices/test_policies.py +++ b/tests/api_resources/zero_trust/devices/policies/test_custom.py @@ -10,32 +10,30 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type from cloudflare.pagination import SyncSinglePage, AsyncSinglePage -from cloudflare.types.zero_trust.devices import ( - SettingsPolicy, - PolicyDeleteResponse, -) +from cloudflare.types.zero_trust.devices import SettingsPolicy +from cloudflare.types.zero_trust.devices.policies import CustomDeleteResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -class TestPolicies: +class TestCustom: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_method_create(self, client: Cloudflare) -> None: - policy = client.zero_trust.devices.policies.create( + custom = client.zero_trust.devices.policies.custom.create( account_id="699d98642c564d2e855e9661899b7252", match='user.identity == "test@cloudflare.com"', name="Allow Developers", precedence=100, ) - assert_matches_type(Optional[SettingsPolicy], policy, path=["response"]) + assert_matches_type(Optional[SettingsPolicy], custom, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_method_create_with_all_params(self, client: Cloudflare) -> None: - policy = client.zero_trust.devices.policies.create( + custom = client.zero_trust.devices.policies.custom.create( account_id="699d98642c564d2e855e9661899b7252", match='user.identity == "test@cloudflare.com"', name="Allow Developers", @@ -59,12 +57,12 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: switch_locked=True, tunnel_protocol="wireguard", ) - assert_matches_type(Optional[SettingsPolicy], policy, path=["response"]) + assert_matches_type(Optional[SettingsPolicy], custom, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_raw_response_create(self, client: Cloudflare) -> None: - response = client.zero_trust.devices.policies.with_raw_response.create( + response = client.zero_trust.devices.policies.custom.with_raw_response.create( account_id="699d98642c564d2e855e9661899b7252", match='user.identity == "test@cloudflare.com"', name="Allow Developers", @@ -73,13 +71,13 @@ def test_raw_response_create(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - policy = response.parse() - assert_matches_type(Optional[SettingsPolicy], policy, path=["response"]) + custom = response.parse() + assert_matches_type(Optional[SettingsPolicy], custom, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_streaming_response_create(self, client: Cloudflare) -> None: - with client.zero_trust.devices.policies.with_streaming_response.create( + with client.zero_trust.devices.policies.custom.with_streaming_response.create( account_id="699d98642c564d2e855e9661899b7252", match='user.identity == "test@cloudflare.com"', name="Allow Developers", @@ -88,8 +86,8 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - policy = response.parse() - assert_matches_type(Optional[SettingsPolicy], policy, path=["response"]) + custom = response.parse() + assert_matches_type(Optional[SettingsPolicy], custom, path=["response"]) assert cast(Any, response.is_closed) is True @@ -97,7 +95,7 @@ def test_streaming_response_create(self, client: Cloudflare) -> None: @parametrize def test_path_params_create(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.devices.policies.with_raw_response.create( + client.zero_trust.devices.policies.custom.with_raw_response.create( account_id="", match='user.identity == "test@cloudflare.com"', name="Allow Developers", @@ -106,86 +104,86 @@ def test_path_params_create(self, client: Cloudflare) -> None: @parametrize def test_method_list(self, client: Cloudflare) -> None: - policy = client.zero_trust.devices.policies.list( + custom = client.zero_trust.devices.policies.custom.list( account_id="699d98642c564d2e855e9661899b7252", ) - assert_matches_type(SyncSinglePage[SettingsPolicy], policy, path=["response"]) + assert_matches_type(SyncSinglePage[SettingsPolicy], custom, path=["response"]) @parametrize def test_raw_response_list(self, client: Cloudflare) -> None: - response = client.zero_trust.devices.policies.with_raw_response.list( + response = client.zero_trust.devices.policies.custom.with_raw_response.list( account_id="699d98642c564d2e855e9661899b7252", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - policy = response.parse() - assert_matches_type(SyncSinglePage[SettingsPolicy], policy, path=["response"]) + custom = response.parse() + assert_matches_type(SyncSinglePage[SettingsPolicy], custom, path=["response"]) @parametrize def test_streaming_response_list(self, client: Cloudflare) -> None: - with client.zero_trust.devices.policies.with_streaming_response.list( + with client.zero_trust.devices.policies.custom.with_streaming_response.list( account_id="699d98642c564d2e855e9661899b7252", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - policy = response.parse() - assert_matches_type(SyncSinglePage[SettingsPolicy], policy, path=["response"]) + custom = response.parse() + assert_matches_type(SyncSinglePage[SettingsPolicy], custom, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize def test_path_params_list(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.devices.policies.with_raw_response.list( + client.zero_trust.devices.policies.custom.with_raw_response.list( account_id="", ) @parametrize def test_method_delete(self, client: Cloudflare) -> None: - policy = client.zero_trust.devices.policies.delete( + custom = client.zero_trust.devices.policies.custom.delete( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) - assert_matches_type(Optional[PolicyDeleteResponse], policy, path=["response"]) + assert_matches_type(Optional[CustomDeleteResponse], custom, path=["response"]) @parametrize def test_raw_response_delete(self, client: Cloudflare) -> None: - response = client.zero_trust.devices.policies.with_raw_response.delete( + response = client.zero_trust.devices.policies.custom.with_raw_response.delete( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - policy = response.parse() - assert_matches_type(Optional[PolicyDeleteResponse], policy, path=["response"]) + custom = response.parse() + assert_matches_type(Optional[CustomDeleteResponse], custom, path=["response"]) @parametrize def test_streaming_response_delete(self, client: Cloudflare) -> None: - with client.zero_trust.devices.policies.with_streaming_response.delete( + with client.zero_trust.devices.policies.custom.with_streaming_response.delete( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - policy = response.parse() - assert_matches_type(Optional[PolicyDeleteResponse], policy, path=["response"]) + custom = response.parse() + assert_matches_type(Optional[CustomDeleteResponse], custom, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize def test_path_params_delete(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.devices.policies.with_raw_response.delete( + client.zero_trust.devices.policies.custom.with_raw_response.delete( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `policy_id` but received ''"): - client.zero_trust.devices.policies.with_raw_response.delete( + client.zero_trust.devices.policies.custom.with_raw_response.delete( policy_id="", account_id="699d98642c564d2e855e9661899b7252", ) @@ -193,16 +191,16 @@ def test_path_params_delete(self, client: Cloudflare) -> None: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_method_edit(self, client: Cloudflare) -> None: - policy = client.zero_trust.devices.policies.edit( + custom = client.zero_trust.devices.policies.custom.edit( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) - assert_matches_type(Optional[SettingsPolicy], policy, path=["response"]) + assert_matches_type(Optional[SettingsPolicy], custom, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_method_edit_with_all_params(self, client: Cloudflare) -> None: - policy = client.zero_trust.devices.policies.edit( + custom = client.zero_trust.devices.policies.custom.edit( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", allow_mode_switch=True, @@ -225,33 +223,33 @@ def test_method_edit_with_all_params(self, client: Cloudflare) -> None: switch_locked=True, tunnel_protocol="wireguard", ) - assert_matches_type(Optional[SettingsPolicy], policy, path=["response"]) + assert_matches_type(Optional[SettingsPolicy], custom, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_raw_response_edit(self, client: Cloudflare) -> None: - response = client.zero_trust.devices.policies.with_raw_response.edit( + response = client.zero_trust.devices.policies.custom.with_raw_response.edit( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - policy = response.parse() - assert_matches_type(Optional[SettingsPolicy], policy, path=["response"]) + custom = response.parse() + assert_matches_type(Optional[SettingsPolicy], custom, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_streaming_response_edit(self, client: Cloudflare) -> None: - with client.zero_trust.devices.policies.with_streaming_response.edit( + with client.zero_trust.devices.policies.custom.with_streaming_response.edit( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - policy = response.parse() - assert_matches_type(Optional[SettingsPolicy], policy, path=["response"]) + custom = response.parse() + assert_matches_type(Optional[SettingsPolicy], custom, path=["response"]) assert cast(Any, response.is_closed) is True @@ -259,13 +257,13 @@ def test_streaming_response_edit(self, client: Cloudflare) -> None: @parametrize def test_path_params_edit(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.devices.policies.with_raw_response.edit( + client.zero_trust.devices.policies.custom.with_raw_response.edit( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `policy_id` but received ''"): - client.zero_trust.devices.policies.with_raw_response.edit( + client.zero_trust.devices.policies.custom.with_raw_response.edit( policy_id="", account_id="699d98642c564d2e855e9661899b7252", ) @@ -273,37 +271,37 @@ def test_path_params_edit(self, client: Cloudflare) -> None: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_method_get(self, client: Cloudflare) -> None: - policy = client.zero_trust.devices.policies.get( + custom = client.zero_trust.devices.policies.custom.get( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) - assert_matches_type(Optional[SettingsPolicy], policy, path=["response"]) + assert_matches_type(Optional[SettingsPolicy], custom, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_raw_response_get(self, client: Cloudflare) -> None: - response = client.zero_trust.devices.policies.with_raw_response.get( + response = client.zero_trust.devices.policies.custom.with_raw_response.get( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - policy = response.parse() - assert_matches_type(Optional[SettingsPolicy], policy, path=["response"]) + custom = response.parse() + assert_matches_type(Optional[SettingsPolicy], custom, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize def test_streaming_response_get(self, client: Cloudflare) -> None: - with client.zero_trust.devices.policies.with_streaming_response.get( + with client.zero_trust.devices.policies.custom.with_streaming_response.get( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - policy = response.parse() - assert_matches_type(Optional[SettingsPolicy], policy, path=["response"]) + custom = response.parse() + assert_matches_type(Optional[SettingsPolicy], custom, path=["response"]) assert cast(Any, response.is_closed) is True @@ -311,36 +309,36 @@ def test_streaming_response_get(self, client: Cloudflare) -> None: @parametrize def test_path_params_get(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.devices.policies.with_raw_response.get( + client.zero_trust.devices.policies.custom.with_raw_response.get( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `policy_id` but received ''"): - client.zero_trust.devices.policies.with_raw_response.get( + client.zero_trust.devices.policies.custom.with_raw_response.get( policy_id="", account_id="699d98642c564d2e855e9661899b7252", ) -class TestAsyncPolicies: +class TestAsyncCustom: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_method_create(self, async_client: AsyncCloudflare) -> None: - policy = await async_client.zero_trust.devices.policies.create( + custom = await async_client.zero_trust.devices.policies.custom.create( account_id="699d98642c564d2e855e9661899b7252", match='user.identity == "test@cloudflare.com"', name="Allow Developers", precedence=100, ) - assert_matches_type(Optional[SettingsPolicy], policy, path=["response"]) + assert_matches_type(Optional[SettingsPolicy], custom, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: - policy = await async_client.zero_trust.devices.policies.create( + custom = await async_client.zero_trust.devices.policies.custom.create( account_id="699d98642c564d2e855e9661899b7252", match='user.identity == "test@cloudflare.com"', name="Allow Developers", @@ -364,12 +362,12 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare switch_locked=True, tunnel_protocol="wireguard", ) - assert_matches_type(Optional[SettingsPolicy], policy, path=["response"]) + assert_matches_type(Optional[SettingsPolicy], custom, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.devices.policies.with_raw_response.create( + response = await async_client.zero_trust.devices.policies.custom.with_raw_response.create( account_id="699d98642c564d2e855e9661899b7252", match='user.identity == "test@cloudflare.com"', name="Allow Developers", @@ -378,13 +376,13 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - policy = await response.parse() - assert_matches_type(Optional[SettingsPolicy], policy, path=["response"]) + custom = await response.parse() + assert_matches_type(Optional[SettingsPolicy], custom, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.devices.policies.with_streaming_response.create( + async with async_client.zero_trust.devices.policies.custom.with_streaming_response.create( account_id="699d98642c564d2e855e9661899b7252", match='user.identity == "test@cloudflare.com"', name="Allow Developers", @@ -393,8 +391,8 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - policy = await response.parse() - assert_matches_type(Optional[SettingsPolicy], policy, path=["response"]) + custom = await response.parse() + assert_matches_type(Optional[SettingsPolicy], custom, path=["response"]) assert cast(Any, response.is_closed) is True @@ -402,7 +400,7 @@ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> @parametrize async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.devices.policies.with_raw_response.create( + await async_client.zero_trust.devices.policies.custom.with_raw_response.create( account_id="", match='user.identity == "test@cloudflare.com"', name="Allow Developers", @@ -411,86 +409,86 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: @parametrize async def test_method_list(self, async_client: AsyncCloudflare) -> None: - policy = await async_client.zero_trust.devices.policies.list( + custom = await async_client.zero_trust.devices.policies.custom.list( account_id="699d98642c564d2e855e9661899b7252", ) - assert_matches_type(AsyncSinglePage[SettingsPolicy], policy, path=["response"]) + assert_matches_type(AsyncSinglePage[SettingsPolicy], custom, path=["response"]) @parametrize async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.devices.policies.with_raw_response.list( + response = await async_client.zero_trust.devices.policies.custom.with_raw_response.list( account_id="699d98642c564d2e855e9661899b7252", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - policy = await response.parse() - assert_matches_type(AsyncSinglePage[SettingsPolicy], policy, path=["response"]) + custom = await response.parse() + assert_matches_type(AsyncSinglePage[SettingsPolicy], custom, path=["response"]) @parametrize async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.devices.policies.with_streaming_response.list( + async with async_client.zero_trust.devices.policies.custom.with_streaming_response.list( account_id="699d98642c564d2e855e9661899b7252", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - policy = await response.parse() - assert_matches_type(AsyncSinglePage[SettingsPolicy], policy, path=["response"]) + custom = await response.parse() + assert_matches_type(AsyncSinglePage[SettingsPolicy], custom, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.devices.policies.with_raw_response.list( + await async_client.zero_trust.devices.policies.custom.with_raw_response.list( account_id="", ) @parametrize async def test_method_delete(self, async_client: AsyncCloudflare) -> None: - policy = await async_client.zero_trust.devices.policies.delete( + custom = await async_client.zero_trust.devices.policies.custom.delete( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) - assert_matches_type(Optional[PolicyDeleteResponse], policy, path=["response"]) + assert_matches_type(Optional[CustomDeleteResponse], custom, path=["response"]) @parametrize async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.devices.policies.with_raw_response.delete( + response = await async_client.zero_trust.devices.policies.custom.with_raw_response.delete( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - policy = await response.parse() - assert_matches_type(Optional[PolicyDeleteResponse], policy, path=["response"]) + custom = await response.parse() + assert_matches_type(Optional[CustomDeleteResponse], custom, path=["response"]) @parametrize async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.devices.policies.with_streaming_response.delete( + async with async_client.zero_trust.devices.policies.custom.with_streaming_response.delete( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - policy = await response.parse() - assert_matches_type(Optional[PolicyDeleteResponse], policy, path=["response"]) + custom = await response.parse() + assert_matches_type(Optional[CustomDeleteResponse], custom, path=["response"]) assert cast(Any, response.is_closed) is True @parametrize async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.devices.policies.with_raw_response.delete( + await async_client.zero_trust.devices.policies.custom.with_raw_response.delete( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `policy_id` but received ''"): - await async_client.zero_trust.devices.policies.with_raw_response.delete( + await async_client.zero_trust.devices.policies.custom.with_raw_response.delete( policy_id="", account_id="699d98642c564d2e855e9661899b7252", ) @@ -498,16 +496,16 @@ async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_method_edit(self, async_client: AsyncCloudflare) -> None: - policy = await async_client.zero_trust.devices.policies.edit( + custom = await async_client.zero_trust.devices.policies.custom.edit( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) - assert_matches_type(Optional[SettingsPolicy], policy, path=["response"]) + assert_matches_type(Optional[SettingsPolicy], custom, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) -> None: - policy = await async_client.zero_trust.devices.policies.edit( + custom = await async_client.zero_trust.devices.policies.custom.edit( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", allow_mode_switch=True, @@ -530,33 +528,33 @@ async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) switch_locked=True, tunnel_protocol="wireguard", ) - assert_matches_type(Optional[SettingsPolicy], policy, path=["response"]) + assert_matches_type(Optional[SettingsPolicy], custom, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.devices.policies.with_raw_response.edit( + response = await async_client.zero_trust.devices.policies.custom.with_raw_response.edit( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - policy = await response.parse() - assert_matches_type(Optional[SettingsPolicy], policy, path=["response"]) + custom = await response.parse() + assert_matches_type(Optional[SettingsPolicy], custom, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.devices.policies.with_streaming_response.edit( + async with async_client.zero_trust.devices.policies.custom.with_streaming_response.edit( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - policy = await response.parse() - assert_matches_type(Optional[SettingsPolicy], policy, path=["response"]) + custom = await response.parse() + assert_matches_type(Optional[SettingsPolicy], custom, path=["response"]) assert cast(Any, response.is_closed) is True @@ -564,13 +562,13 @@ async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> N @parametrize async def test_path_params_edit(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.devices.policies.with_raw_response.edit( + await async_client.zero_trust.devices.policies.custom.with_raw_response.edit( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `policy_id` but received ''"): - await async_client.zero_trust.devices.policies.with_raw_response.edit( + await async_client.zero_trust.devices.policies.custom.with_raw_response.edit( policy_id="", account_id="699d98642c564d2e855e9661899b7252", ) @@ -578,37 +576,37 @@ async def test_path_params_edit(self, async_client: AsyncCloudflare) -> None: @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_method_get(self, async_client: AsyncCloudflare) -> None: - policy = await async_client.zero_trust.devices.policies.get( + custom = await async_client.zero_trust.devices.policies.custom.get( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) - assert_matches_type(Optional[SettingsPolicy], policy, path=["response"]) + assert_matches_type(Optional[SettingsPolicy], custom, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.devices.policies.with_raw_response.get( + response = await async_client.zero_trust.devices.policies.custom.with_raw_response.get( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - policy = await response.parse() - assert_matches_type(Optional[SettingsPolicy], policy, path=["response"]) + custom = await response.parse() + assert_matches_type(Optional[SettingsPolicy], custom, path=["response"]) @pytest.mark.skip(reason="TODO: investigate broken test") @parametrize async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.devices.policies.with_streaming_response.get( + async with async_client.zero_trust.devices.policies.custom.with_streaming_response.get( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - policy = await response.parse() - assert_matches_type(Optional[SettingsPolicy], policy, path=["response"]) + custom = await response.parse() + assert_matches_type(Optional[SettingsPolicy], custom, path=["response"]) assert cast(Any, response.is_closed) is True @@ -616,13 +614,13 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No @parametrize async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.devices.policies.with_raw_response.get( + await async_client.zero_trust.devices.policies.custom.with_raw_response.get( policy_id="f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `policy_id` but received ''"): - await async_client.zero_trust.devices.policies.with_raw_response.get( + await async_client.zero_trust.devices.policies.custom.with_raw_response.get( policy_id="", account_id="699d98642c564d2e855e9661899b7252", ) diff --git a/tests/api_resources/zero_trust/devices/policies/test_default.py b/tests/api_resources/zero_trust/devices/policies/test_default.py new file mode 100644 index 00000000000..166f4259bcc --- /dev/null +++ b/tests/api_resources/zero_trust/devices/policies/test_default.py @@ -0,0 +1,216 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, Optional, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.types.zero_trust.devices.policies import DefaultGetResponse, DefaultEditResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestDefault: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_edit(self, client: Cloudflare) -> None: + default = client.zero_trust.devices.policies.default.edit( + account_id="699d98642c564d2e855e9661899b7252", + ) + assert_matches_type(Optional[DefaultEditResponse], default, path=["response"]) + + @parametrize + def test_method_edit_with_all_params(self, client: Cloudflare) -> None: + default = client.zero_trust.devices.policies.default.edit( + account_id="699d98642c564d2e855e9661899b7252", + allow_mode_switch=True, + allow_updates=True, + allowed_to_leave=True, + auto_connect=0, + captive_portal=180, + disable_auto_fallback=True, + exclude_office_ips=True, + service_mode_v2={ + "mode": "proxy", + "port": 3000, + }, + support_url="https://1.1.1.1/help", + switch_locked=True, + tunnel_protocol="wireguard", + ) + assert_matches_type(Optional[DefaultEditResponse], default, path=["response"]) + + @parametrize + def test_raw_response_edit(self, client: Cloudflare) -> None: + response = client.zero_trust.devices.policies.default.with_raw_response.edit( + account_id="699d98642c564d2e855e9661899b7252", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + default = response.parse() + assert_matches_type(Optional[DefaultEditResponse], default, path=["response"]) + + @parametrize + def test_streaming_response_edit(self, client: Cloudflare) -> None: + with client.zero_trust.devices.policies.default.with_streaming_response.edit( + account_id="699d98642c564d2e855e9661899b7252", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + default = response.parse() + assert_matches_type(Optional[DefaultEditResponse], default, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_edit(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.devices.policies.default.with_raw_response.edit( + account_id="", + ) + + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + default = client.zero_trust.devices.policies.default.get( + account_id="699d98642c564d2e855e9661899b7252", + ) + assert_matches_type(Optional[DefaultGetResponse], default, path=["response"]) + + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.zero_trust.devices.policies.default.with_raw_response.get( + account_id="699d98642c564d2e855e9661899b7252", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + default = response.parse() + assert_matches_type(Optional[DefaultGetResponse], default, path=["response"]) + + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.zero_trust.devices.policies.default.with_streaming_response.get( + account_id="699d98642c564d2e855e9661899b7252", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + default = response.parse() + assert_matches_type(Optional[DefaultGetResponse], default, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.zero_trust.devices.policies.default.with_raw_response.get( + account_id="", + ) + + +class TestAsyncDefault: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_edit(self, async_client: AsyncCloudflare) -> None: + default = await async_client.zero_trust.devices.policies.default.edit( + account_id="699d98642c564d2e855e9661899b7252", + ) + assert_matches_type(Optional[DefaultEditResponse], default, path=["response"]) + + @parametrize + async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) -> None: + default = await async_client.zero_trust.devices.policies.default.edit( + account_id="699d98642c564d2e855e9661899b7252", + allow_mode_switch=True, + allow_updates=True, + allowed_to_leave=True, + auto_connect=0, + captive_portal=180, + disable_auto_fallback=True, + exclude_office_ips=True, + service_mode_v2={ + "mode": "proxy", + "port": 3000, + }, + support_url="https://1.1.1.1/help", + switch_locked=True, + tunnel_protocol="wireguard", + ) + assert_matches_type(Optional[DefaultEditResponse], default, path=["response"]) + + @parametrize + async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.devices.policies.default.with_raw_response.edit( + account_id="699d98642c564d2e855e9661899b7252", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + default = await response.parse() + assert_matches_type(Optional[DefaultEditResponse], default, path=["response"]) + + @parametrize + async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.devices.policies.default.with_streaming_response.edit( + account_id="699d98642c564d2e855e9661899b7252", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + default = await response.parse() + assert_matches_type(Optional[DefaultEditResponse], default, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_edit(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.zero_trust.devices.policies.default.with_raw_response.edit( + account_id="", + ) + + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + default = await async_client.zero_trust.devices.policies.default.get( + account_id="699d98642c564d2e855e9661899b7252", + ) + assert_matches_type(Optional[DefaultGetResponse], default, path=["response"]) + + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.devices.policies.default.with_raw_response.get( + account_id="699d98642c564d2e855e9661899b7252", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + default = await response.parse() + assert_matches_type(Optional[DefaultGetResponse], default, path=["response"]) + + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.devices.policies.default.with_streaming_response.get( + account_id="699d98642c564d2e855e9661899b7252", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + default = await response.parse() + assert_matches_type(Optional[DefaultGetResponse], default, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.zero_trust.devices.policies.default.with_raw_response.get( + account_id="", + ) diff --git a/tests/api_resources/zero_trust/devices/policies/test_default_policy.py b/tests/api_resources/zero_trust/devices/policies/test_default_policy.py deleted file mode 100644 index 51bc7a1bf6c..00000000000 --- a/tests/api_resources/zero_trust/devices/policies/test_default_policy.py +++ /dev/null @@ -1,98 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import os -from typing import Any, Optional, cast - -import pytest - -from cloudflare import Cloudflare, AsyncCloudflare -from tests.utils import assert_matches_type -from cloudflare.types.zero_trust.devices.policies import DefaultPolicyGetResponse - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestDefaultPolicy: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - def test_method_get(self, client: Cloudflare) -> None: - default_policy = client.zero_trust.devices.policies.default_policy.get( - account_id="699d98642c564d2e855e9661899b7252", - ) - assert_matches_type(Optional[DefaultPolicyGetResponse], default_policy, path=["response"]) - - @parametrize - def test_raw_response_get(self, client: Cloudflare) -> None: - response = client.zero_trust.devices.policies.default_policy.with_raw_response.get( - account_id="699d98642c564d2e855e9661899b7252", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - default_policy = response.parse() - assert_matches_type(Optional[DefaultPolicyGetResponse], default_policy, path=["response"]) - - @parametrize - def test_streaming_response_get(self, client: Cloudflare) -> None: - with client.zero_trust.devices.policies.default_policy.with_streaming_response.get( - account_id="699d98642c564d2e855e9661899b7252", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - default_policy = response.parse() - assert_matches_type(Optional[DefaultPolicyGetResponse], default_policy, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_get(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.zero_trust.devices.policies.default_policy.with_raw_response.get( - account_id="", - ) - - -class TestAsyncDefaultPolicy: - parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - async def test_method_get(self, async_client: AsyncCloudflare) -> None: - default_policy = await async_client.zero_trust.devices.policies.default_policy.get( - account_id="699d98642c564d2e855e9661899b7252", - ) - assert_matches_type(Optional[DefaultPolicyGetResponse], default_policy, path=["response"]) - - @parametrize - async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: - response = await async_client.zero_trust.devices.policies.default_policy.with_raw_response.get( - account_id="699d98642c564d2e855e9661899b7252", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - default_policy = await response.parse() - assert_matches_type(Optional[DefaultPolicyGetResponse], default_policy, path=["response"]) - - @parametrize - async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: - async with async_client.zero_trust.devices.policies.default_policy.with_streaming_response.get( - account_id="699d98642c564d2e855e9661899b7252", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - default_policy = await response.parse() - assert_matches_type(Optional[DefaultPolicyGetResponse], default_policy, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.zero_trust.devices.policies.default_policy.with_raw_response.get( - account_id="", - )