From 7d5572aee61a0d57a27878bbdea6e753f08d1021 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 18 Jun 2024 14:27:03 +0000 Subject: [PATCH] feat(api): OpenAPI spec update via Stainless API (#1021) --- .stats.yml | 2 +- api.md | 2 +- .../zero_trust/gateway/configurations.py | 8 +- .../zero_trust/gateway/lists/lists.py | 20 ++++- .../types/zero_trust/gateway/__init__.py | 1 + .../gateway/gateway_configuration_settings.py | 18 ++++- .../gateway_configuration_settings_param.py | 20 ++++- .../zero_trust/gateway/gateway_item_param.py | 8 +- .../zero_trust/gateway/list_list_params.py | 14 ++++ .../types/zero_trust/gateway/rule_setting.py | 17 ++-- .../zero_trust/gateway/rule_setting_param.py | 17 ++-- .../zero_trust/gateway/test_configurations.py | 4 + .../zero_trust/gateway/test_lists.py | 77 ++++++++++++++++++- .../zero_trust/gateway/test_rules.py | 4 + 14 files changed, 183 insertions(+), 29 deletions(-) create mode 100644 src/cloudflare/types/zero_trust/gateway/list_list_params.py diff --git a/.stats.yml b/.stats.yml index d1202adc94a..6d986a26f7e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1348 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a4ad69b707d0e14c7a716a22c876ab03c40d8aefa59eec101c5c52260cb860f3.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-db421d07d58c7abf1af471a342e12789def4e83543dccea6aec34b8667646028.yml diff --git a/api.md b/api.md index 9fc32242fc8..b610facf969 100644 --- a/api.md +++ b/api.md @@ -6079,7 +6079,7 @@ Methods: - client.zero_trust.gateway.lists.create(\*, account_id, \*\*params) -> Optional - client.zero_trust.gateway.lists.update(list_id, \*, account_id, \*\*params) -> Optional -- client.zero_trust.gateway.lists.list(\*, account_id) -> SyncSinglePage[GatewayList] +- client.zero_trust.gateway.lists.list(\*, account_id, \*\*params) -> SyncSinglePage[GatewayList] - client.zero_trust.gateway.lists.delete(list_id, \*, account_id) -> Optional - client.zero_trust.gateway.lists.edit(list_id, \*, account_id, \*\*params) -> Optional - client.zero_trust.gateway.lists.get(list_id, \*, account_id) -> Optional diff --git a/src/cloudflare/resources/zero_trust/gateway/configurations.py b/src/cloudflare/resources/zero_trust/gateway/configurations.py index ce316798e47..6f30fdb7210 100644 --- a/src/cloudflare/resources/zero_trust/gateway/configurations.py +++ b/src/cloudflare/resources/zero_trust/gateway/configurations.py @@ -102,8 +102,8 @@ def edit( This endpoint can update a single subcollection of settings such as `antivirus`, `tls_decrypt`, `activity_log`, `block_page`, `browser_isolation`, `fips`, `body_scanning`, or - `custom_certificate`, without updating the entire configuration object. Returns - an error if any collection of settings is not properly configured. + `certificate`, without updating the entire configuration object. Returns an + error if any collection of settings is not properly configured. Args: settings: account settings. @@ -238,8 +238,8 @@ async def edit( This endpoint can update a single subcollection of settings such as `antivirus`, `tls_decrypt`, `activity_log`, `block_page`, `browser_isolation`, `fips`, `body_scanning`, or - `custom_certificate`, without updating the entire configuration object. Returns - an error if any collection of settings is not properly configured. + `certificate`, without updating the entire configuration object. Returns an + error if any collection of settings is not properly configured. Args: settings: account settings. diff --git a/src/cloudflare/resources/zero_trust/gateway/lists/lists.py b/src/cloudflare/resources/zero_trust/gateway/lists/lists.py index 0810dafa367..20f88988e72 100644 --- a/src/cloudflare/resources/zero_trust/gateway/lists/lists.py +++ b/src/cloudflare/resources/zero_trust/gateway/lists/lists.py @@ -34,7 +34,7 @@ AsyncPaginator, make_request_options, ) -from .....types.zero_trust.gateway import list_edit_params, list_create_params, list_update_params +from .....types.zero_trust.gateway import list_edit_params, list_list_params, list_create_params, list_update_params from .....types.zero_trust.gateway.gateway_list import GatewayList from .....types.zero_trust.gateway.gateway_item_param import GatewayItemParam from .....types.zero_trust.gateway.list_create_response import ListCreateResponse @@ -173,6 +173,7 @@ def list( self, *, account_id: str, + type: Literal["SERIAL", "URL", "DOMAIN", "EMAIL", "IP"] | 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, @@ -184,6 +185,8 @@ def list( Fetches all Zero Trust lists for an account. Args: + type: The type of list. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -198,7 +201,11 @@ def list( f"/accounts/{account_id}/gateway/lists", page=SyncSinglePage[GatewayList], options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform({"type": type}, list_list_params.ListListParams), ), model=GatewayList, ) @@ -478,6 +485,7 @@ def list( self, *, account_id: str, + type: Literal["SERIAL", "URL", "DOMAIN", "EMAIL", "IP"] | 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, @@ -489,6 +497,8 @@ def list( Fetches all Zero Trust lists for an account. Args: + type: The type of list. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -503,7 +513,11 @@ def list( f"/accounts/{account_id}/gateway/lists", page=AsyncSinglePage[GatewayList], options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform({"type": type}, list_list_params.ListListParams), ), model=GatewayList, ) diff --git a/src/cloudflare/types/zero_trust/gateway/__init__.py b/src/cloudflare/types/zero_trust/gateway/__init__.py index c3abd0c2212..c462d3ec6af 100644 --- a/src/cloudflare/types/zero_trust/gateway/__init__.py +++ b/src/cloudflare/types/zero_trust/gateway/__init__.py @@ -19,6 +19,7 @@ from .logging_setting import LoggingSetting as LoggingSetting from .gateway_settings import GatewaySettings as GatewaySettings from .list_edit_params import ListEditParams as ListEditParams +from .list_list_params import ListListParams as ListListParams from .location_network import LocationNetwork as LocationNetwork from .gateway_item_param import GatewayItemParam as GatewayItemParam from .list_create_params import ListCreateParams as ListCreateParams diff --git a/src/cloudflare/types/zero_trust/gateway/gateway_configuration_settings.py b/src/cloudflare/types/zero_trust/gateway/gateway_configuration_settings.py index 13705c996f6..5504ecf870a 100644 --- a/src/cloudflare/types/zero_trust/gateway/gateway_configuration_settings.py +++ b/src/cloudflare/types/zero_trust/gateway/gateway_configuration_settings.py @@ -14,7 +14,12 @@ from .browser_isolation_settings import BrowserIsolationSettings from .custom_certificate_settings import CustomCertificateSettings -__all__ = ["GatewayConfigurationSettings"] +__all__ = ["GatewayConfigurationSettings", "Certificate"] + + +class Certificate(BaseModel): + id: str + """UUID of certificate to be used for interception.""" class GatewayConfigurationSettings(BaseModel): @@ -33,8 +38,17 @@ class GatewayConfigurationSettings(BaseModel): browser_isolation: Optional[BrowserIsolationSettings] = None """Browser isolation settings.""" + certificate: Optional[Certificate] = None + """Certificate settings for Gateway TLS interception. + + If not specified, the Cloudflare Root CA will be used. + """ + custom_certificate: Optional[CustomCertificateSettings] = None - """Custom certificate settings for BYO-PKI.""" + """Custom certificate settings for BYO-PKI. + + (deprecated and replaced by `certificate`) + """ extended_email_matching: Optional[ExtendedEmailMatching] = None """Extended e-mail matching settings.""" diff --git a/src/cloudflare/types/zero_trust/gateway/gateway_configuration_settings_param.py b/src/cloudflare/types/zero_trust/gateway/gateway_configuration_settings_param.py index 8b0b1443581..11cea789954 100644 --- a/src/cloudflare/types/zero_trust/gateway/gateway_configuration_settings_param.py +++ b/src/cloudflare/types/zero_trust/gateway/gateway_configuration_settings_param.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing_extensions import TypedDict +from typing_extensions import Required, TypedDict from .tls_settings_param import TLSSettingsParam from .fips_settings_param import FipsSettingsParam @@ -15,7 +15,12 @@ from .browser_isolation_settings_param import BrowserIsolationSettingsParam from .custom_certificate_settings_param import CustomCertificateSettingsParam -__all__ = ["GatewayConfigurationSettingsParam"] +__all__ = ["GatewayConfigurationSettingsParam", "Certificate"] + + +class Certificate(TypedDict, total=False): + id: Required[str] + """UUID of certificate to be used for interception.""" class GatewayConfigurationSettingsParam(TypedDict, total=False): @@ -34,8 +39,17 @@ class GatewayConfigurationSettingsParam(TypedDict, total=False): browser_isolation: BrowserIsolationSettingsParam """Browser isolation settings.""" + certificate: Certificate + """Certificate settings for Gateway TLS interception. + + If not specified, the Cloudflare Root CA will be used. + """ + custom_certificate: CustomCertificateSettingsParam - """Custom certificate settings for BYO-PKI.""" + """Custom certificate settings for BYO-PKI. + + (deprecated and replaced by `certificate`) + """ extended_email_matching: ExtendedEmailMatchingParam """Extended e-mail matching settings.""" diff --git a/src/cloudflare/types/zero_trust/gateway/gateway_item_param.py b/src/cloudflare/types/zero_trust/gateway/gateway_item_param.py index 5b5d081859d..819b853caa8 100644 --- a/src/cloudflare/types/zero_trust/gateway/gateway_item_param.py +++ b/src/cloudflare/types/zero_trust/gateway/gateway_item_param.py @@ -2,11 +2,17 @@ from __future__ import annotations -from typing_extensions import TypedDict +from typing import Union +from datetime import datetime +from typing_extensions import Annotated, TypedDict + +from ...._utils import PropertyInfo __all__ = ["GatewayItemParam"] class GatewayItemParam(TypedDict, total=False): + created_at: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")] + value: str """The value of the item in a list.""" diff --git a/src/cloudflare/types/zero_trust/gateway/list_list_params.py b/src/cloudflare/types/zero_trust/gateway/list_list_params.py new file mode 100644 index 00000000000..30c9d6123e6 --- /dev/null +++ b/src/cloudflare/types/zero_trust/gateway/list_list_params.py @@ -0,0 +1,14 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["ListListParams"] + + +class ListListParams(TypedDict, total=False): + account_id: Required[str] + + type: Literal["SERIAL", "URL", "DOMAIN", "EMAIL", "IP"] + """The type of list.""" diff --git a/src/cloudflare/types/zero_trust/gateway/rule_setting.py b/src/cloudflare/types/zero_trust/gateway/rule_setting.py index 9af12528729..1e87ca2204e 100644 --- a/src/cloudflare/types/zero_trust/gateway/rule_setting.py +++ b/src/cloudflare/types/zero_trust/gateway/rule_setting.py @@ -28,19 +28,19 @@ class AuditSSH(BaseModel): class BisoAdminControls(BaseModel): dcp: Optional[bool] = None - """Set to true to enable copy-pasting.""" + """Set to false to enable copy-pasting.""" dd: Optional[bool] = None - """Set to true to enable downloading.""" + """Set to false to enable downloading.""" dk: Optional[bool] = None - """Set to true to enable keyboard usage.""" + """Set to false to enable keyboard usage.""" dp: Optional[bool] = None - """Set to true to enable printing.""" + """Set to false to enable printing.""" du: Optional[bool] = None - """Set to true to enable uploading.""" + """Set to false to enable uploading.""" class CheckSession(BaseModel): @@ -153,6 +153,13 @@ class RuleSetting(BaseModel): it to indicate local egress via WARP IPs. """ + ignore_cname_category_matches: Optional[bool] = None + """Set to true, to ignore the category matches at CNAME domains in a response. + + If unchecked, the categories in this rule will be checked against all the CNAME + domain categories in a response. + """ + insecure_disable_dnssec_validation: Optional[bool] = None """INSECURE - disable DNSSEC validation (for Allow actions).""" diff --git a/src/cloudflare/types/zero_trust/gateway/rule_setting_param.py b/src/cloudflare/types/zero_trust/gateway/rule_setting_param.py index 62fe1523f29..0992e550137 100644 --- a/src/cloudflare/types/zero_trust/gateway/rule_setting_param.py +++ b/src/cloudflare/types/zero_trust/gateway/rule_setting_param.py @@ -29,19 +29,19 @@ class AuditSSH(TypedDict, total=False): class BisoAdminControls(TypedDict, total=False): dcp: bool - """Set to true to enable copy-pasting.""" + """Set to false to enable copy-pasting.""" dd: bool - """Set to true to enable downloading.""" + """Set to false to enable downloading.""" dk: bool - """Set to true to enable keyboard usage.""" + """Set to false to enable keyboard usage.""" dp: bool - """Set to true to enable printing.""" + """Set to false to enable printing.""" du: bool - """Set to true to enable uploading.""" + """Set to false to enable uploading.""" class CheckSession(TypedDict, total=False): @@ -154,6 +154,13 @@ class RuleSettingParam(TypedDict, total=False): it to indicate local egress via WARP IPs. """ + ignore_cname_category_matches: bool + """Set to true, to ignore the category matches at CNAME domains in a response. + + If unchecked, the categories in this rule will be checked against all the CNAME + domain categories in a response. + """ + insecure_disable_dnssec_validation: bool """INSECURE - disable DNSSEC validation (for Allow actions).""" diff --git a/tests/api_resources/zero_trust/gateway/test_configurations.py b/tests/api_resources/zero_trust/gateway/test_configurations.py index 62f30e964a0..795445ac228 100644 --- a/tests/api_resources/zero_trust/gateway/test_configurations.py +++ b/tests/api_resources/zero_trust/gateway/test_configurations.py @@ -60,6 +60,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: "non_identity_enabled": True, "url_browser_isolation_enabled": True, }, + "certificate": {"id": "d1b364c5-1311-466e-a194-f0e943e0799f"}, "custom_certificate": { "enabled": True, "id": "d1b364c5-1311-466e-a194-f0e943e0799f", @@ -142,6 +143,7 @@ def test_method_edit_with_all_params(self, client: Cloudflare) -> None: "non_identity_enabled": True, "url_browser_isolation_enabled": True, }, + "certificate": {"id": "d1b364c5-1311-466e-a194-f0e943e0799f"}, "custom_certificate": { "enabled": True, "id": "d1b364c5-1311-466e-a194-f0e943e0799f", @@ -266,6 +268,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare "non_identity_enabled": True, "url_browser_isolation_enabled": True, }, + "certificate": {"id": "d1b364c5-1311-466e-a194-f0e943e0799f"}, "custom_certificate": { "enabled": True, "id": "d1b364c5-1311-466e-a194-f0e943e0799f", @@ -348,6 +351,7 @@ async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) "non_identity_enabled": True, "url_browser_isolation_enabled": True, }, + "certificate": {"id": "d1b364c5-1311-466e-a194-f0e943e0799f"}, "custom_certificate": { "enabled": True, "id": "d1b364c5-1311-466e-a194-f0e943e0799f", diff --git a/tests/api_resources/zero_trust/gateway/test_lists.py b/tests/api_resources/zero_trust/gateway/test_lists.py index cfd4e978d0f..d7fdc097741 100644 --- a/tests/api_resources/zero_trust/gateway/test_lists.py +++ b/tests/api_resources/zero_trust/gateway/test_lists.py @@ -9,6 +9,7 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type +from cloudflare._utils import parse_datetime from cloudflare.pagination import SyncSinglePage, AsyncSinglePage from cloudflare.types.zero_trust.gateway import ( GatewayList, @@ -38,7 +39,20 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: name="Admin Serial Numbers", type="SERIAL", description="The serial numbers for administrators", - items=[{"value": "8GE8721REF"}, {"value": "8GE8721REF"}, {"value": "8GE8721REF"}], + items=[ + { + "created_at": parse_datetime("2014-01-01T05:20:00.12345Z"), + "value": "8GE8721REF", + }, + { + "created_at": parse_datetime("2014-01-01T05:20:00.12345Z"), + "value": "8GE8721REF", + }, + { + "created_at": parse_datetime("2014-01-01T05:20:00.12345Z"), + "value": "8GE8721REF", + }, + ], ) assert_matches_type(Optional[ListCreateResponse], list_, path=["response"]) @@ -149,6 +163,14 @@ def test_method_list(self, client: Cloudflare) -> None: ) assert_matches_type(SyncSinglePage[GatewayList], list_, path=["response"]) + @parametrize + def test_method_list_with_all_params(self, client: Cloudflare) -> None: + list_ = client.zero_trust.gateway.lists.list( + account_id="699d98642c564d2e855e9661899b7252", + type="SERIAL", + ) + assert_matches_type(SyncSinglePage[GatewayList], list_, path=["response"]) + @parametrize def test_raw_response_list(self, client: Cloudflare) -> None: response = client.zero_trust.gateway.lists.with_raw_response.list( @@ -241,7 +263,20 @@ def test_method_edit_with_all_params(self, client: Cloudflare) -> None: list_ = client.zero_trust.gateway.lists.edit( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", - append=[{"value": "8GE8721REF"}, {"value": "8GE8721REF"}, {"value": "8GE8721REF"}], + append=[ + { + "created_at": parse_datetime("2014-01-01T05:20:00.12345Z"), + "value": "8GE8721REF", + }, + { + "created_at": parse_datetime("2014-01-01T05:20:00.12345Z"), + "value": "8GE8721REF", + }, + { + "created_at": parse_datetime("2014-01-01T05:20:00.12345Z"), + "value": "8GE8721REF", + }, + ], remove=["8GE8721REF", "8GE8721REF", "8GE8721REF"], ) assert_matches_type(Optional[GatewayList], list_, path=["response"]) @@ -354,7 +389,20 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare name="Admin Serial Numbers", type="SERIAL", description="The serial numbers for administrators", - items=[{"value": "8GE8721REF"}, {"value": "8GE8721REF"}, {"value": "8GE8721REF"}], + items=[ + { + "created_at": parse_datetime("2014-01-01T05:20:00.12345Z"), + "value": "8GE8721REF", + }, + { + "created_at": parse_datetime("2014-01-01T05:20:00.12345Z"), + "value": "8GE8721REF", + }, + { + "created_at": parse_datetime("2014-01-01T05:20:00.12345Z"), + "value": "8GE8721REF", + }, + ], ) assert_matches_type(Optional[ListCreateResponse], list_, path=["response"]) @@ -465,6 +513,14 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None: ) assert_matches_type(AsyncSinglePage[GatewayList], list_, path=["response"]) + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: + list_ = await async_client.zero_trust.gateway.lists.list( + account_id="699d98642c564d2e855e9661899b7252", + type="SERIAL", + ) + assert_matches_type(AsyncSinglePage[GatewayList], list_, path=["response"]) + @parametrize async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: response = await async_client.zero_trust.gateway.lists.with_raw_response.list( @@ -557,7 +613,20 @@ async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) list_ = await async_client.zero_trust.gateway.lists.edit( "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", - append=[{"value": "8GE8721REF"}, {"value": "8GE8721REF"}, {"value": "8GE8721REF"}], + append=[ + { + "created_at": parse_datetime("2014-01-01T05:20:00.12345Z"), + "value": "8GE8721REF", + }, + { + "created_at": parse_datetime("2014-01-01T05:20:00.12345Z"), + "value": "8GE8721REF", + }, + { + "created_at": parse_datetime("2014-01-01T05:20:00.12345Z"), + "value": "8GE8721REF", + }, + ], remove=["8GE8721REF", "8GE8721REF", "8GE8721REF"], ) assert_matches_type(Optional[GatewayList], list_, path=["response"]) diff --git a/tests/api_resources/zero_trust/gateway/test_rules.py b/tests/api_resources/zero_trust/gateway/test_rules.py index b83694ffb9f..924ce1fa37b 100644 --- a/tests/api_resources/zero_trust/gateway/test_rules.py +++ b/tests/api_resources/zero_trust/gateway/test_rules.py @@ -110,6 +110,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: "ipv4_fallback": "192.0.2.3", "ipv6": "2001:DB8::/64", }, + "ignore_cname_category_matches": True, "insecure_disable_dnssec_validation": False, "ip_categories": True, "ip_indicator_feeds": True, @@ -270,6 +271,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: "ipv4_fallback": "192.0.2.3", "ipv6": "2001:DB8::/64", }, + "ignore_cname_category_matches": True, "insecure_disable_dnssec_validation": False, "ip_categories": True, "ip_indicator_feeds": True, @@ -577,6 +579,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare "ipv4_fallback": "192.0.2.3", "ipv6": "2001:DB8::/64", }, + "ignore_cname_category_matches": True, "insecure_disable_dnssec_validation": False, "ip_categories": True, "ip_indicator_feeds": True, @@ -737,6 +740,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare "ipv4_fallback": "192.0.2.3", "ipv6": "2001:DB8::/64", }, + "ignore_cname_category_matches": True, "insecure_disable_dnssec_validation": False, "ip_categories": True, "ip_indicator_feeds": True,